diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-09-04 09:47:43 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-09-05 07:08:22 -0300 |
| commit | 433f34813b2085ce6c20387c8eeb5818fa3dfd8f (patch) | |
| tree | 32861b1710287918b3c5b99481f3d1a864608056 | |
| parent | 76e75265ee135ed44e7fefb594101314655e45d0 (diff) | |
| download | mullvadvpn-433f34813b2085ce6c20387c8eeb5818fa3dfd8f.tar.xz mullvadvpn-433f34813b2085ce6c20387c8eeb5818fa3dfd8f.zip | |
Move `enable_ipv6` to `TunnelOptions`
| -rw-r--r-- | gui/packages/desktop/src/renderer/app.js | 2 | ||||
| -rw-r--r-- | gui/packages/desktop/src/renderer/lib/daemon-rpc.js | 10 | ||||
| -rw-r--r-- | mullvad-cli/src/cmds/tunnel.rs | 6 | ||||
| -rw-r--r-- | mullvad-daemon/src/settings.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/process/openvpn.rs | 10 | ||||
| -rw-r--r-- | talpid-types/src/net.rs | 29 |
6 files changed, 31 insertions, 30 deletions
diff --git a/gui/packages/desktop/src/renderer/app.js b/gui/packages/desktop/src/renderer/app.js index 06af1598fd..a1427605e3 100644 --- a/gui/packages/desktop/src/renderer/app.js +++ b/gui/packages/desktop/src/renderer/app.js @@ -410,7 +410,7 @@ export default class AppRenderer { async _fetchTunnelOptions() { const actions = this._reduxActions; const tunnelOptions = await this._daemonRpc.getTunnelOptions(); - actions.settings.updateEnableIpv6(tunnelOptions.openvpn.enableIpv6); + actions.settings.updateEnableIpv6(tunnelOptions.enableIpv6); } async _fetchVersionInfo() { diff --git a/gui/packages/desktop/src/renderer/lib/daemon-rpc.js b/gui/packages/desktop/src/renderer/lib/daemon-rpc.js index 637f149cab..e87f51930b 100644 --- a/gui/packages/desktop/src/renderer/lib/daemon-rpc.js +++ b/gui/packages/desktop/src/renderer/lib/daemon-rpc.js @@ -206,14 +206,12 @@ const RelayListSchema = object({ }); export type TunnelOptions = { - openvpn: { - enableIpv6: boolean, - }, + enableIpv6: boolean, }; const TunnelOptionsSchema = object({ + enable_ipv6: boolean, openvpn: object({ - enable_ipv6: boolean, mssfix: maybe(number), }), }); @@ -439,9 +437,7 @@ export class DaemonRpc implements DaemonRpcProtocol { const validatedObject = validate(TunnelOptionsSchema, response); return { - openvpn: { - enableIpv6: validatedObject.openvpn.enable_ipv6, - }, + enableIpv6: validatedObject.enable_ipv6, }; } catch (error) { throw new ResponseParseError('Invalid response from get_tunnel_options', error); diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs index eb965f6b70..b86effd837 100644 --- a/mullvad-cli/src/cmds/tunnel.rs +++ b/mullvad-cli/src/cmds/tunnel.rs @@ -125,11 +125,7 @@ impl Tunnel { println!("Common tunnel options"); println!( "\tIPv6: {}", - if options.openvpn.enable_ipv6 { - "on" - } else { - "off" - } + if options.enable_ipv6 { "on" } else { "off" } ); } diff --git a/mullvad-daemon/src/settings.rs b/mullvad-daemon/src/settings.rs index a51002d782..216d18f4d8 100644 --- a/mullvad-daemon/src/settings.rs +++ b/mullvad-daemon/src/settings.rs @@ -181,8 +181,8 @@ impl Settings { } pub fn set_enable_ipv6(&mut self, enable_ipv6: bool) -> Result<bool> { - if self.tunnel_options.openvpn.enable_ipv6 != enable_ipv6 { - self.tunnel_options.openvpn.enable_ipv6 = enable_ipv6; + if self.tunnel_options.enable_ipv6 != enable_ipv6 { + self.tunnel_options.enable_ipv6 = enable_ipv6; self.save().map(|_| true) } else { Ok(false) diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs index 8c3fae8f6a..550d6c4169 100644 --- a/talpid-core/src/process/openvpn.rs +++ b/talpid-core/src/process/openvpn.rs @@ -53,6 +53,7 @@ pub struct OpenVpnCommand { log: Option<PathBuf>, tunnel_options: net::OpenVpnTunnelOptions, tunnel_alias: Option<OsString>, + enable_ipv6: bool, } impl OpenVpnCommand { @@ -71,6 +72,7 @@ impl OpenVpnCommand { log: None, tunnel_options: net::OpenVpnTunnelOptions::default(), tunnel_alias: None, + enable_ipv6: true, } } @@ -142,6 +144,12 @@ impl OpenVpnCommand { self } + /// Configures if IPv6 should be allowed in the tunnel. + pub fn enable_ipv6(&mut self, enable_ipv6: bool) -> &mut Self { + self.enable_ipv6 = enable_ipv6; + self + } + /// Returns all arguments that the subprocess would be spawned with. pub fn get_arguments(&self) -> Vec<OsString> { let mut args: Vec<OsString> = Self::base_arguments().iter().map(OsString::from).collect(); @@ -184,7 +192,7 @@ impl OpenVpnCommand { args.push(OsString::from(mssfix.to_string())); } - if !self.tunnel_options.enable_ipv6 { + if !self.enable_ipv6 { args.push(OsString::from("--pull-filter")); args.push(OsString::from("ignore")); args.push(OsString::from("route-ipv6")); diff --git a/talpid-types/src/net.rs b/talpid-types/src/net.rs index 296045fd05..554b1e5917 100644 --- a/talpid-types/src/net.rs +++ b/talpid-types/src/net.rs @@ -128,32 +128,33 @@ impl Error for TransportProtocolParseError { /// TunnelOptions holds optional settings for tunnels, that are to be applied to any tunnel of the /// appropriate type. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(default)] pub struct TunnelOptions { /// openvpn holds OpenVPN specific tunnel options. pub openvpn: OpenVpnTunnelOptions, + /// Enable configuration of IPv6 on the tunnel interface, allowing IPv6 communication to be + /// forwarded through the tunnel. By default, this is set to `true`. + pub enable_ipv6: bool, +} + +impl Default for TunnelOptions { + fn default() -> Self { + TunnelOptions { + openvpn: OpenVpnTunnelOptions::default(), + enable_ipv6: true, + } + } } /// OpenVpnTunnelOptions contains options for an openvpn tunnel that should be applied irrespective /// of the relay parameters - i.e. have nothing to do with the particular OpenVPN server, but do /// affect the connection. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] #[serde(default)] pub struct OpenVpnTunnelOptions { /// Optional argument for openvpn to try and limit TCP packet size, /// as discussed [here](https://openvpn.net/archive/openvpn-users/2003-11/msg00154.html) pub mssfix: Option<u16>, - /// Enable configuration of IPv6 on the tunnel interface, allowing IPv6 communication to be - /// forwarded through the tunnel. By default, this is set to `true`. - pub enable_ipv6: bool, -} - -impl Default for OpenVpnTunnelOptions { - fn default() -> Self { - OpenVpnTunnelOptions { - mssfix: None, - enable_ipv6: true, - } - } } |
