Skip to main content

resolve_tunnel_mode

Function resolve_tunnel_mode 

Source
pub fn resolve_tunnel_mode(
    socks5: bool,
    remote_socket: Option<String>,
    reverse: bool,
    remote_host: Option<String>,
    remote_port: Option<u16>,
) -> Result<TunnelMode, SshCliError>
Expand description

Resolves the tunnel mode from the mutually exclusive mode flags.

Pure: no registry, no socket, no clock. The positional arguments mean different things per mode — remote_host is a destination for a local forward and a server bind address under --reverse — so getting this wrong points the tunnel somewhere the caller never asked for. Keeping the decision in one testable function is what lets every combination be covered without a server.

§Errors

crate::errors::SshCliError::InvalidArgument (exit 64) when a mode is given arguments it cannot use, or is missing arguments it requires.