Skip to content

Commit

Permalink
fix: added forgotten socks5 options
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Dec 18, 2023
1 parent 5e8331d commit 961931b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/samba/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Error> {
Expand Down Expand Up @@ -97,10 +97,10 @@ impl SMB {
}
}

return Err(format!(
Err(format!(
"could not find private share for {}, provide one with --smb-share",
target
));
))
}
}

Expand Down
21 changes: 16 additions & 5 deletions src/plugins/socks5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}

Expand All @@ -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(())
}

Expand All @@ -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(),
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/socks5/options.rs
Original file line number Diff line number Diff line change
@@ -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,
}

0 comments on commit 961931b

Please sign in to comment.