Split fallback_scheme into launch and connect choices

pull/137/head
Chip Senkbeil 2 years ago
parent 1ee2684d08
commit 44b0dc065c
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- `replace_scheme` method to `Destination`
### Fixed
@ -16,6 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Map` implementation of `Display` now escapes `\` and `"`
- `Map` implementation of `FromStr` now handles escaped `\` and `"`
- Split `fallback_scheme` for `DistantManagerConfig` into
`launch_fallback_scheme` (defaulting to ssh) and `connect_fallback_scheme`
(defaulting to distant); this means that subsequent use of
`distant client launch [user@]host[:port]` will now default to ssh instead of
failing due to lack of distant launch handler
## [0.17.1] - 2022-08-16
### Added

@ -29,6 +29,14 @@ impl Destination {
self.0.scheme().map(Scheme::as_str)
}
/// Replaces the current scheme of the destination with the provided scheme, returning the old
/// scheme as a string if it existed
pub fn replace_scheme(&mut self, scheme: &str) -> Result<Option<String>, URIReferenceError> {
self.0
.set_scheme(Some(Scheme::try_from(scheme).map(Scheme::into_owned)?))
.map(|s| s.map(|s| s.to_string()))
}
/// Returns the host of the destination as a string
pub fn to_host_string(&self) -> String {
// NOTE: We guarantee that there is a host for a destination during construction

@ -148,9 +148,9 @@ impl DistantManager {
None => {
trace!(
"Using fallback scheme of {}",
self.config.fallback_scheme.as_str()
self.config.launch_fallback_scheme.as_str()
);
self.config.fallback_scheme.as_str()
self.config.launch_fallback_scheme.as_str()
}
}
.to_lowercase();
@ -193,9 +193,9 @@ impl DistantManager {
None => {
trace!(
"Using fallback scheme of {}",
self.config.fallback_scheme.as_str()
self.config.connect_fallback_scheme.as_str()
);
self.config.fallback_scheme.as_str()
self.config.connect_fallback_scheme.as_str()
}
}
.to_lowercase();

@ -2,8 +2,11 @@ use crate::{BoxedConnectHandler, BoxedLaunchHandler};
use std::collections::HashMap;
pub struct DistantManagerConfig {
/// Scheme to use when none is provided in a destination
pub fallback_scheme: String,
/// Scheme to use when none is provided in a destination for launch
pub launch_fallback_scheme: String,
/// Scheme to use when none is provided in a destination for connect
pub connect_fallback_scheme: String,
/// Buffer size for queue of incoming connections before blocking
pub connection_buffer_size: usize,
@ -21,7 +24,12 @@ pub struct DistantManagerConfig {
impl Default for DistantManagerConfig {
fn default() -> Self {
Self {
fallback_scheme: "distant".to_string(),
// Default to using ssh to launch distant
launch_fallback_scheme: "ssh".to_string(),
// Default to distant server when connecting
connect_fallback_scheme: "distant".to_string(),
connection_buffer_size: 100,
user: false,
launch_handlers: HashMap::new(),

@ -421,7 +421,7 @@ impl ClientSubcommand {
config: launcher_config,
network,
format,
destination,
mut destination,
..
} => {
let network = network.merge(config.network);
@ -445,6 +445,17 @@ impl ClientSubcommand {
// Grab the host we are connecting to for later use
let host = destination.to_host_string();
// If we have no scheme on launch, we need to fill it in with something
//
// TODO: Can we have the server support this instead of the client? Right now, the
// server is failing because it cannot parse //localhost/ as it fails with
// an invalid IPv4 or registered name character error on host
if destination.scheme().is_none() {
destination
.replace_scheme("ssh")
.context("Failed to set a default scheme for a scheme-less destination")?;
}
// Start the server using our manager
debug!("Launching server at {} with {}", destination, extra);
let mut new_destination = client

Loading…
Cancel
Save