diff --git a/src/options.rs b/src/options.rs index 9bfd82c..abf32e4 100644 --- a/src/options.rs +++ b/src/options.rs @@ -105,6 +105,9 @@ pub(crate) struct Options { #[cfg(feature = "smtp")] #[clap(flatten, next_help_heading = "SMTP")] pub smtp: crate::plugins::smtp::options::Options, + #[cfg(feature = "socks5")] + #[clap(flatten, next_help_heading = "SOCKS5")] + pub socks5: crate::plugins::socks5::options::Options, #[cfg(feature = "pop3")] #[clap(flatten, next_help_heading = "POP3")] pub pop3: crate::plugins::pop3::options::Options, diff --git a/src/plugins/samba/mod.rs b/src/plugins/samba/mod.rs index 72b2ce1..a2a3941 100644 --- a/src/plugins/samba/mod.rs +++ b/src/plugins/samba/mod.rs @@ -58,7 +58,7 @@ impl SMB { .no_auto_anonymous_login(false) .one_share_per_server(true), ) - .map_err(|e| format!("error creating client for {}: {}", share, e.to_string())) + .map_err(|e| format!("error creating client for {}: {}", share, e)) } async fn get_share_for(&self, target: &str) -> Result { @@ -97,10 +97,10 @@ impl SMB { } } - return Err(format!( + Err(format!( "could not find private share for {}, provide one with --smb-share", target - )); + )) } } diff --git a/src/plugins/socks5/mod.rs b/src/plugins/socks5/mod.rs index 344340e..5063327 100644 --- a/src/plugins/socks5/mod.rs +++ b/src/plugins/socks5/mod.rs @@ -10,17 +10,25 @@ use crate::Plugin; use crate::creds::Credentials; +pub(crate) mod options; + #[ctor] fn register() { crate::plugins::manager::register("socks5", Box::new(Socks5::new())); } #[derive(Clone)] -pub(crate) struct Socks5 {} +pub(crate) struct Socks5 { + remote_address: String, + remote_port: u16, +} impl Socks5 { pub fn new() -> Self { - Socks5 {} + Socks5 { + remote_address: "ifcfg.co".to_owned(), + remote_port: 80, + } } } @@ -30,7 +38,10 @@ impl Plugin for Socks5 { "SOCKS5 password authentication." } - fn setup(&mut self, _opts: &Options) -> Result<(), Error> { + fn setup(&mut self, opts: &Options) -> Result<(), Error> { + self.remote_address = opts.socks5.socks5_address.clone(); + self.remote_port = opts.socks5.socks5_port; + Ok(()) } @@ -40,8 +51,8 @@ impl Plugin for Socks5 { timeout, fast_socks5::client::Socks5Stream::connect_with_password( address.clone(), - "ifcfg.co".to_owned(), - 80, + self.remote_address.clone(), + self.remote_port, creds.username.clone(), creds.password.clone(), fast_socks5::client::Config::default(), diff --git a/src/plugins/socks5/options.rs b/src/plugins/socks5/options.rs new file mode 100644 index 0000000..95f9a17 --- /dev/null +++ b/src/plugins/socks5/options.rs @@ -0,0 +1,13 @@ +use clap::Parser; +use serde::{Deserialize, Serialize}; + +#[derive(Parser, Debug, Serialize, Deserialize, Clone, Default)] +#[group(skip)] +pub(crate) struct Options { + #[clap(long, default_value = "ifcfg.co")] + /// Remote address to test the proxying for. + pub socks5_address: String, + #[clap(long, default_value_t = 80)] + /// Remote port to test the proxying for. + pub socks5_port: u16, +}