mod authentication;
mod basic;
mod command;
mod connection;
mod control;
mod environment;
mod forwarding;
mod proxy;
mod security;
mod ui;
use crate::ssh::ssh_config::types::SshHostConfig;
use anyhow::Result;
pub fn parse_option(
host: &mut SshHostConfig,
keyword: &str,
args: &[String],
line_number: usize,
) -> Result<()> {
match keyword {
"hostname" | "user" | "port" => basic::parse_basic_option(host, keyword, args, line_number),
"identityfile"
| "identitiesonly"
| "addkeystoagent"
| "identityagent"
| "pubkeyacceptedalgorithms"
| "certificatefile"
| "pubkeyauthentication"
| "passwordauthentication"
| "kbdinteractiveauthentication"
| "gssapiauthentication"
| "preferredauthentications"
| "hostbasedauthentication"
| "hostbasedacceptedalgorithms"
| "numberofpasswordprompts"
| "enablesshkeysign"
| "usekeychain" => {
authentication::parse_authentication_option(host, keyword, args, line_number)
}
"stricthostkeychecking"
| "userknownhostsfile"
| "globalknownhostsfile"
| "hostkeyalgorithms"
| "kexalgorithms"
| "ciphers"
| "macs"
| "casignaturealgorithms"
| "nohostauthenticationforlocalhost"
| "hashknownhosts"
| "checkhostip"
| "visualhostkey"
| "hostkeyalias"
| "verifyhostkeydns"
| "updatehostkeys"
| "requiredrsasize"
| "fingerprinthash" => security::parse_security_option(host, keyword, args, line_number),
"forwardagent"
| "forwardx11"
| "localforward"
| "remoteforward"
| "dynamicforward"
| "gatewayports"
| "exitonforwardfailure"
| "permitremoteopen"
| "clearallforwardings"
| "forwardx11timeout"
| "forwardx11trusted" => {
forwarding::parse_forwarding_option(host, keyword, args, line_number)
}
"serveraliveinterval"
| "serveralivecountmax"
| "connecttimeout"
| "connectionattempts"
| "batchmode"
| "compression"
| "tcpkeepalive"
| "addressfamily"
| "bindaddress"
| "bindinterface"
| "ipqos"
| "rekeylimit" => connection::parse_connection_option(host, keyword, args, line_number),
"proxyjump" | "proxycommand" | "proxyusefdpass" => {
proxy::parse_proxy_option(host, keyword, args, line_number)
}
"controlmaster" | "controlpath" | "controlpersist" => {
control::parse_control_option(host, keyword, args, line_number)
}
"sendenv" | "setenv" => {
environment::parse_environment_option(host, keyword, args, line_number)
}
"requesttty" | "escapechar" | "loglevel" | "syslogfacility" | "protocol" => {
ui::parse_ui_option(host, keyword, args, line_number)
}
"permitlocalcommand"
| "localcommand"
| "remotecommand"
| "knownhostscommand"
| "forkafterauthentication"
| "sessiontype"
| "stdinnull" => command::parse_command_option(host, keyword, args, line_number),
_ => {
tracing::warn!(
"Unknown SSH config option '{}' at line {}",
keyword,
line_number
);
Ok(())
}
}
}