Skip to content

Commit

Permalink
Add CLI for Shadowsocks obfuscation
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Aug 26, 2024
1 parent 423bd57 commit 4cf00a6
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions mullvad-cli/src/cmds/obfuscation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use clap::Subcommand;
use mullvad_management_interface::MullvadProxyClient;
use mullvad_types::{
constraints::Constraint,
relay_constraints::{ObfuscationSettings, SelectedObfuscation, Udp2TcpObfuscationSettings},
relay_constraints::{
ObfuscationSettings, SelectedObfuscation, ShadowsocksSettings, Udp2TcpObfuscationSettings,
},
};

#[derive(Subcommand, Debug)]
Expand All @@ -18,16 +20,22 @@ pub enum Obfuscation {

#[derive(Subcommand, Debug, Clone)]
pub enum SetCommands {
/// Specifies if obfuscation should be used with WireGuard connections.
/// And if so, what obfuscation protocol it should use.
/// Specify which obfuscation protocol to use, if any.
Mode { mode: SelectedObfuscation },

/// Specifies the config for the udp2tcp obfuscator.
/// Configure udp2tcp obfuscation.
Udp2tcp {
/// Port to use, or 'any'
#[arg(long, short = 'p')]
port: Constraint<u16>,
},

/// Configure Shadowsocks obfuscation.
Shadowsocks {
/// Port to use, or 'any'
#[arg(long, short = 'p')]
port: Constraint<u16>,
},
}

impl Obfuscation {
Expand All @@ -41,6 +49,7 @@ impl Obfuscation {
obfuscation_settings.selected_obfuscation
);
println!("udp2tcp settings: {}", obfuscation_settings.udp2tcp);
println!("Shadowsocks settings: {}", obfuscation_settings.shadowsocks);
Ok(())
}
Obfuscation::Set(subcmd) => Self::set(subcmd).await,
Expand All @@ -66,6 +75,13 @@ impl Obfuscation {
})
.await?;
}
SetCommands::Shadowsocks { port } => {
rpc.set_obfuscation_settings(ObfuscationSettings {
shadowsocks: ShadowsocksSettings { port },
..current_settings
})
.await?;
}
}

println!("Updated obfuscation settings");
Expand Down

0 comments on commit 4cf00a6

Please sign in to comment.