diff options
Diffstat (limited to 'mullvad-cli/src')
| -rw-r--r-- | mullvad-cli/src/cmds/tunnel.rs | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs index bf7172c655..a0c86fe1f0 100644 --- a/mullvad-cli/src/cmds/tunnel.rs +++ b/mullvad-cli/src/cmds/tunnel.rs @@ -22,6 +22,13 @@ impl Command for Tunnel { .subcommand( clap::SubCommand::with_name("set") .subcommand( + clap::SubCommand::with_name("ipv6").arg( + clap::Arg::with_name("enable") + .required(true) + .takes_value(true) + .possible_values(&["on", "off"]), + ), + ).subcommand( clap::SubCommand::with_name("mssfix").arg( clap::Arg::with_name("mssfix") .help( @@ -60,23 +67,38 @@ impl Tunnel { } fn set_openvpn_option(matches: &clap::ArgMatches) -> Result<()> { - if let Some(mssfix_args) = matches.subcommand_matches("mssfix") { - let mssfix_str = mssfix_args.value_of("mssfix").unwrap(); - let mssfix: Option<u16> = if mssfix_str == "" { - None - } else { - Some(mssfix_str.parse()?) - }; - - let mut rpc = DaemonRpcClient::new()?; - rpc.set_openvpn_mssfix(mssfix)?; - println!("mssfix parameter updated"); - Ok(()) + if let Some(ipv6_args) = matches.subcommand_matches("ipv6") { + Self::set_openvpn_enable_ipv6_option(ipv6_args) + } else if let Some(mssfix_args) = matches.subcommand_matches("mssfix") { + Self::set_openvpn_mssfix_option(mssfix_args) } else { unreachable!("Invalid option passed to 'openvpn set'"); } } + fn set_openvpn_enable_ipv6_option(args: &clap::ArgMatches) -> Result<()> { + let enabled = args.value_of("enable").unwrap() == "on"; + + let mut rpc = DaemonRpcClient::new()?; + rpc.set_openvpn_enable_ipv6(enabled)?; + println!("enable_ipv6 parameter updated"); + Ok(()) + } + + fn set_openvpn_mssfix_option(args: &clap::ArgMatches) -> Result<()> { + let mssfix_str = args.value_of("mssfix").unwrap(); + let mssfix: Option<u16> = if mssfix_str == "" { + None + } else { + Some(mssfix_str.parse()?) + }; + + let mut rpc = DaemonRpcClient::new()?; + rpc.set_openvpn_mssfix(mssfix)?; + println!("mssfix parameter updated"); + Ok(()) + } + fn get_tunnel_options() -> Result<TunnelOptions> { let mut rpc = DaemonRpcClient::new()?; Ok(rpc.get_tunnel_options()?) @@ -90,5 +112,9 @@ impl Tunnel { .mssfix .map_or_else(|| "UNSET".to_string(), |v| v.to_string()) ); + println!( + "\tIPv6: {}", + if options.enable_ipv6 { "on" } else { "off" } + ); } } |
