summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src
diff options
context:
space:
mode:
authorOdd Stranne <odd@mullvad.net>2019-02-05 21:02:52 +0100
committerOdd Stranne <odd@mullvad.net>2019-02-15 15:06:51 +0100
commit58411be7cccf213d6ea5998ed84ce18740825258 (patch)
tree1e12a40f2a1ce335e7ba1be7f677c381b06b9253 /mullvad-cli/src
parentc0bc2d0aaa8e37fdf34dfb4cb2bcf7c7cebe0208 (diff)
downloadmullvadvpn-58411be7cccf213d6ea5998ed84ce18740825258.tar.xz
mullvadvpn-58411be7cccf213d6ea5998ed84ce18740825258.zip
Add Shadowsocks in CLI
Diffstat (limited to 'mullvad-cli/src')
-rw-r--r--mullvad-cli/src/cmds/tunnel.rs63
1 files changed, 62 insertions, 1 deletions
diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs
index 5887148abe..bbd1a0e2a1 100644
--- a/mullvad-cli/src/cmds/tunnel.rs
+++ b/mullvad-cli/src/cmds/tunnel.rs
@@ -2,7 +2,7 @@ use crate::{new_rpc_client, Command, Result};
use clap::value_t;
use mullvad_types::settings::TunnelOptions;
-use talpid_types::net::openvpn;
+use talpid_types::net::openvpn::{self, SHADOWSOCKS_CIPHERS};
use std::net::{IpAddr, SocketAddr};
@@ -144,6 +144,35 @@ fn create_openvpn_proxy_subcommand() -> clap::App<'static, 'static> {
.required(true)
.index(4),
),
+ )
+ .subcommand(
+ clap::SubCommand::with_name("shadowsocks")
+ .about("Configure bundled Shadowsocks proxy")
+ .arg(
+ clap::Arg::with_name("remote-ip")
+ .help("Specifies the IP of the remote Shadowsocks server")
+ .required(true)
+ .index(1),
+ )
+ .arg(
+ clap::Arg::with_name("remote-port")
+ .help("Specifies the port of the remote Shadowsocks server")
+ .default_value("443")
+ .index(2),
+ )
+ .arg(
+ clap::Arg::with_name("password")
+ .help("Specifies the password on the remote Shadowsocks server")
+ .default_value("23#dfsbbb")
+ .index(3),
+ )
+ .arg(
+ clap::Arg::with_name("cipher")
+ .help("Specifies the cipher to use")
+ .default_value("chacha20")
+ .possible_values(SHADOWSOCKS_CIPHERS)
+ .index(4),
+ ),
),
)
}
@@ -301,6 +330,8 @@ impl Tunnel {
Self::print_local_proxy(&local_proxy)
} else if let openvpn::ProxySettings::Remote(remote_proxy) = proxy {
Self::print_remote_proxy(&remote_proxy)
+ } else if let openvpn::ProxySettings::Shadowsocks(shadowsocks_proxy) = proxy {
+ Self::print_shadowsocks_proxy(&shadowsocks_proxy)
} else {
unreachable!("unhandled proxy type");
}
@@ -330,6 +361,14 @@ impl Tunnel {
}
}
+ fn print_shadowsocks_proxy(proxy: &openvpn::ShadowsocksProxySettings) {
+ println!("proxy: Shadowsocks");
+ println!(" peer IP: {}", proxy.peer.ip());
+ println!(" peer port: {}", proxy.peer.port());
+ println!(" password: {}", proxy.password);
+ println!(" cipher: {}", proxy.cipher);
+ }
+
fn process_openvpn_proxy_unset() -> Result<()> {
let mut rpc = new_rpc_client()?;
rpc.set_openvpn_proxy(None)?;
@@ -388,6 +427,28 @@ impl Tunnel {
let mut rpc = new_rpc_client()?;
rpc.set_openvpn_proxy(Some(packed_proxy))?;
+ } else if let Some(args) = matches.subcommand_matches("shadowsocks") {
+ let remote_ip =
+ value_t!(args.value_of("remote-ip"), IpAddr).unwrap_or_else(|e| e.exit());
+ let remote_port =
+ value_t!(args.value_of("remote-port"), u16).unwrap_or_else(|e| e.exit());
+ let password = args.value_of("password").unwrap().to_string();
+ let cipher = args.value_of("cipher").unwrap().to_string();
+
+ let proxy = openvpn::ShadowsocksProxySettings {
+ peer: SocketAddr::new(remote_ip, remote_port),
+ password,
+ cipher,
+ };
+
+ let packed_proxy = openvpn::ProxySettings::Shadowsocks(proxy);
+
+ if let Err(error) = openvpn::ProxySettingsValidation::validate(&packed_proxy) {
+ panic!(error);
+ }
+
+ let mut rpc = new_rpc_client()?;
+ rpc.set_openvpn_proxy(Some(packed_proxy))?;
} else {
unreachable!("unhandled proxy type");
}