summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOdd Stranne <odd@mullvad.net>2019-02-06 14:49:30 +0100
committerOdd Stranne <odd@mullvad.net>2019-02-15 15:06:51 +0100
commit6a5b4ea61ab95211167b4759c46d4fb0bf6ccf22 (patch)
tree3f73e8a4a2ad62cff87f6555e0c7268b82f45c96
parentaab22540c2a8e275a5d263d0c0b54237ec46d5b4 (diff)
downloadmullvadvpn-6a5b4ea61ab95211167b4759c46d4fb0bf6ccf22.tar.xz
mullvadvpn-6a5b4ea61ab95211167b4759c46d4fb0bf6ccf22.zip
Update OpenVpnCommand with Shadowsocks logic
-rw-r--r--talpid-core/src/process/openvpn.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs
index e636d85929..24d69d3926 100644
--- a/talpid-core/src/process/openvpn.rs
+++ b/talpid-core/src/process/openvpn.rs
@@ -64,6 +64,7 @@ pub struct OpenVpnCommand {
tunnel_options: net::openvpn::TunnelOptions,
tunnel_alias: Option<OsString>,
enable_ipv6: bool,
+ proxy_port: Option<u16>,
}
impl OpenVpnCommand {
@@ -84,6 +85,7 @@ impl OpenVpnCommand {
tunnel_options: net::openvpn::TunnelOptions::default(),
tunnel_alias: None,
enable_ipv6: true,
+ proxy_port: None,
}
}
@@ -162,6 +164,13 @@ impl OpenVpnCommand {
self
}
+ /// Sets the local proxy port bound to.
+ /// In case of dynamic port selection, this will only be known after the proxy has been started.
+ pub fn proxy_port(&mut self, proxy_port: u16) -> &mut Self {
+ self.proxy_port = Some(proxy_port);
+ self
+ }
+
/// Build a runnable expression from the current state of the command.
pub fn build(&self) -> duct::Expression {
log::debug!("Building expression: {}", &self);
@@ -302,7 +311,21 @@ impl OpenVpnCommand {
args.push("255.255.255.255".to_owned());
args.push("net_gateway".to_owned());
}
- Some(net::openvpn::ProxySettings::Shadowsocks(ref _ss)) => {} // TODO: fix
+ Some(net::openvpn::ProxySettings::Shadowsocks(ref ss)) => {
+ args.push("--socks-proxy".to_owned());
+ args.push("127.0.0.1".to_owned());
+
+ if let Some(ref proxy_port) = self.proxy_port {
+ args.push(proxy_port.to_string());
+ } else {
+ panic!("Dynamic proxy port was not registered with OpenVpnCommand");
+ }
+
+ args.push("--route".to_owned());
+ args.push(ss.peer.ip().to_string());
+ args.push("255.255.255.255".to_owned());
+ args.push("net_gateway".to_owned());
+ }
None => {}
};
args