summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2019-04-04 15:07:02 +0200
committerLinus Färnstrand <linus@mullvad.net>2019-04-04 15:44:45 +0200
commit4352b0adaabbfdbf92c55691b05c47984b2e2a95 (patch)
treec5afe605414f9701790d90df0bf4173c6c0cfe60 /mullvad-cli/src
parent2b2b0e3087ac4dcdc7ac1ae14a243ef182710a91 (diff)
downloadmullvadvpn-4352b0adaabbfdbf92c55691b05c47984b2e2a95.tar.xz
mullvadvpn-4352b0adaabbfdbf92c55691b05c47984b2e2a95.zip
Add #![deny(rust_2018_idioms)] to all crates and fix warnings
Diffstat (limited to 'mullvad-cli/src')
-rw-r--r--mullvad-cli/src/cmds/account.rs2
-rw-r--r--mullvad-cli/src/cmds/auto_connect.rs2
-rw-r--r--mullvad-cli/src/cmds/block_when_disconnected.rs2
-rw-r--r--mullvad-cli/src/cmds/connect.rs2
-rw-r--r--mullvad-cli/src/cmds/disconnect.rs2
-rw-r--r--mullvad-cli/src/cmds/lan.rs2
-rw-r--r--mullvad-cli/src/cmds/relay.rs14
-rw-r--r--mullvad-cli/src/cmds/status.rs2
-rw-r--r--mullvad-cli/src/cmds/tunnel.rs20
-rw-r--r--mullvad-cli/src/cmds/version.rs2
-rw-r--r--mullvad-cli/src/main.rs4
11 files changed, 28 insertions, 26 deletions
diff --git a/mullvad-cli/src/cmds/account.rs b/mullvad-cli/src/cmds/account.rs
index c980cca936..a480f95bde 100644
--- a/mullvad-cli/src/cmds/account.rs
+++ b/mullvad-cli/src/cmds/account.rs
@@ -32,7 +32,7 @@ impl Command for Account {
)
}
- fn run(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
if let Some(set_matches) = matches.subcommand_matches("set") {
let token = value_t_or_exit!(set_matches.value_of("token"), String);
self.set(Some(token))
diff --git a/mullvad-cli/src/cmds/auto_connect.rs b/mullvad-cli/src/cmds/auto_connect.rs
index 92a08a0ebf..6deccc9260 100644
--- a/mullvad-cli/src/cmds/auto_connect.rs
+++ b/mullvad-cli/src/cmds/auto_connect.rs
@@ -27,7 +27,7 @@ impl Command for AutoConnect {
)
}
- fn run(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
if let Some(set_matches) = matches.subcommand_matches("set") {
let auto_connect = value_t_or_exit!(set_matches.value_of("policy"), String);
self.set(auto_connect == "on")
diff --git a/mullvad-cli/src/cmds/block_when_disconnected.rs b/mullvad-cli/src/cmds/block_when_disconnected.rs
index 8e74a16d1e..ad7dc00d4c 100644
--- a/mullvad-cli/src/cmds/block_when_disconnected.rs
+++ b/mullvad-cli/src/cmds/block_when_disconnected.rs
@@ -27,7 +27,7 @@ impl Command for BlockWhenDisconnected {
)
}
- fn run(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
if let Some(set_matches) = matches.subcommand_matches("set") {
let block_when_disconnected = value_t_or_exit!(set_matches.value_of("policy"), String);
self.set(block_when_disconnected == "on")
diff --git a/mullvad-cli/src/cmds/connect.rs b/mullvad-cli/src/cmds/connect.rs
index d75c1b2195..422b207c33 100644
--- a/mullvad-cli/src/cmds/connect.rs
+++ b/mullvad-cli/src/cmds/connect.rs
@@ -13,7 +13,7 @@ impl Command for Connect {
.about("Command the client to start establishing a VPN tunnel")
}
- fn run(&self, _matches: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, _matches: &clap::ArgMatches<'_>) -> Result<()> {
let mut rpc = new_rpc_client()?;
if let Err(e) = rpc.connect() {
eprintln!("{}", e.display_chain());
diff --git a/mullvad-cli/src/cmds/disconnect.rs b/mullvad-cli/src/cmds/disconnect.rs
index 5375ad0535..bf85f80310 100644
--- a/mullvad-cli/src/cmds/disconnect.rs
+++ b/mullvad-cli/src/cmds/disconnect.rs
@@ -12,7 +12,7 @@ impl Command for Disconnect {
.about("Command the client to disconnect the VPN tunnel")
}
- fn run(&self, _matches: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, _matches: &clap::ArgMatches<'_>) -> Result<()> {
let mut rpc = new_rpc_client()?;
rpc.disconnect()?;
Ok(())
diff --git a/mullvad-cli/src/cmds/lan.rs b/mullvad-cli/src/cmds/lan.rs
index 44efd92f5c..437a5acaad 100644
--- a/mullvad-cli/src/cmds/lan.rs
+++ b/mullvad-cli/src/cmds/lan.rs
@@ -27,7 +27,7 @@ impl Command for Lan {
)
}
- fn run(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
if let Some(set_matches) = matches.subcommand_matches("set") {
let allow_lan = value_t_or_exit!(set_matches.value_of("policy"), String);
self.set(allow_lan == "allow")
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs
index 0d2c5c3bca..33783d309f 100644
--- a/mullvad-cli/src/cmds/relay.rs
+++ b/mullvad-cli/src/cmds/relay.rs
@@ -165,7 +165,7 @@ impl Command for Relay {
)
}
- fn run(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
if let Some(set_matches) = matches.subcommand_matches("set") {
self.set(set_matches)
} else if matches.subcommand_matches("get").is_some() {
@@ -188,7 +188,7 @@ impl Relay {
Ok(())
}
- fn set(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn set(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
if let Some(custom_matches) = matches.subcommand_matches("custom") {
self.set_custom(custom_matches)
} else if let Some(location_matches) = matches.subcommand_matches("location") {
@@ -200,7 +200,7 @@ impl Relay {
}
}
- fn set_custom(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn set_custom(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
let custom_endpoint = match matches.subcommand() {
("openvpn", Some(openvpn_matches)) => Self::read_custom_openvpn_relay(openvpn_matches),
("wireguard", Some(wg_matches)) => Self::read_custom_wireguard_relay(wg_matches),
@@ -209,7 +209,7 @@ impl Relay {
self.update_constraints(RelaySettingsUpdate::CustomTunnelEndpoint(custom_endpoint))
}
- fn read_custom_openvpn_relay(matches: &clap::ArgMatches) -> CustomTunnelEndpoint {
+ fn read_custom_openvpn_relay(matches: &clap::ArgMatches<'_>) -> CustomTunnelEndpoint {
let host = value_t!(matches.value_of("host"), String).unwrap_or_else(|e| e.exit());
let port = value_t!(matches.value_of("port"), u16).unwrap_or_else(|e| e.exit());
let username = value_t!(matches.value_of("username"), String).unwrap_or_else(|e| e.exit());
@@ -226,7 +226,7 @@ impl Relay {
)
}
- fn read_custom_wireguard_relay(matches: &clap::ArgMatches) -> CustomTunnelEndpoint {
+ fn read_custom_wireguard_relay(matches: &clap::ArgMatches<'_>) -> CustomTunnelEndpoint {
let host = value_t!(matches.value_of("host"), String).unwrap_or_else(|e| e.exit());
let port = value_t!(matches.value_of("port"), u16).unwrap_or_else(|e| e.exit());
let addresses = values_t!(matches.values_of("addr"), IpAddr).unwrap_or_else(|e| e.exit());
@@ -288,7 +288,7 @@ impl Relay {
key
}
- fn set_location(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn set_location(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
let country = matches.value_of("country").unwrap();
let city = matches.value_of("city");
let hostname = matches.value_of("hostname");
@@ -327,7 +327,7 @@ impl Relay {
}))
}
- fn set_tunnel(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn set_tunnel(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
let vpn_protocol = matches.value_of("vpn protocol").unwrap();
let port = parse_port_constraint(matches.value_of("port").unwrap())?;
let protocol = parse_protocol_constraint(matches.value_of("transport protocol").unwrap());
diff --git a/mullvad-cli/src/cmds/status.rs b/mullvad-cli/src/cmds/status.rs
index 862514a9f4..9310707825 100644
--- a/mullvad-cli/src/cmds/status.rs
+++ b/mullvad-cli/src/cmds/status.rs
@@ -25,7 +25,7 @@ impl Command for Status {
)
}
- fn run(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
let mut rpc = new_rpc_client()?;
let state = rpc.get_state()?;
diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs
index 4cc4af4867..2521a06838 100644
--- a/mullvad-cli/src/cmds/tunnel.rs
+++ b/mullvad-cli/src/cmds/tunnel.rs
@@ -22,7 +22,7 @@ impl Command for Tunnel {
.subcommand(create_ipv6_subcommand())
}
- fn run(&self, matches: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()> {
match matches.subcommand() {
("openvpn", Some(openvpn_matches)) => Self::handle_openvpn_cmd(openvpn_matches),
("wireguard", Some(wg_matches)) => Self::handle_wireguard_cmd(wg_matches),
@@ -187,7 +187,7 @@ fn create_ipv6_subcommand() -> clap::App<'static, 'static> {
}
impl Tunnel {
- fn handle_openvpn_cmd(matches: &clap::ArgMatches) -> Result<()> {
+ fn handle_openvpn_cmd(matches: &clap::ArgMatches<'_>) -> Result<()> {
match matches.subcommand() {
("mssfix", Some(mssfix_matches)) => Self::handle_openvpn_mssfix_cmd(mssfix_matches),
("proxy", Some(proxy_matches)) => Self::handle_openvpn_proxy_cmd(proxy_matches),
@@ -195,7 +195,7 @@ impl Tunnel {
}
}
- fn handle_openvpn_mssfix_cmd(matches: &clap::ArgMatches) -> Result<()> {
+ fn handle_openvpn_mssfix_cmd(matches: &clap::ArgMatches<'_>) -> Result<()> {
match matches.subcommand() {
("get", Some(_)) => Self::process_openvpn_mssfix_get(),
("unset", Some(_)) => Self::process_openvpn_mssfix_unset(),
@@ -204,7 +204,7 @@ impl Tunnel {
}
}
- fn handle_openvpn_proxy_cmd(matches: &clap::ArgMatches) -> Result<()> {
+ fn handle_openvpn_proxy_cmd(matches: &clap::ArgMatches<'_>) -> Result<()> {
match matches.subcommand() {
("get", Some(_)) => Self::process_openvpn_proxy_get(),
("unset", Some(_)) => Self::process_openvpn_proxy_unset(),
@@ -213,7 +213,7 @@ impl Tunnel {
}
}
- fn handle_wireguard_cmd(matches: &clap::ArgMatches) -> Result<()> {
+ fn handle_wireguard_cmd(matches: &clap::ArgMatches<'_>) -> Result<()> {
match matches.subcommand() {
("mtu", Some(matches)) => match matches.subcommand() {
("get", _) => Self::process_wireguard_mtu_get(),
@@ -244,7 +244,7 @@ impl Tunnel {
Ok(())
}
- fn process_wireguard_mtu_set(matches: &clap::ArgMatches) -> Result<()> {
+ fn process_wireguard_mtu_set(matches: &clap::ArgMatches<'_>) -> Result<()> {
let mtu = value_t!(matches.value_of("mtu"), u16).unwrap_or_else(|e| e.exit());
let mut rpc = new_rpc_client()?;
rpc.set_wireguard_mtu(Some(mtu))?;
@@ -281,7 +281,7 @@ impl Tunnel {
rpc.generate_wireguard_key().map_err(|e| e.into())
}
- fn handle_ipv6_cmd(matches: &clap::ArgMatches) -> Result<()> {
+ fn handle_ipv6_cmd(matches: &clap::ArgMatches<'_>) -> Result<()> {
if matches.subcommand_matches("get").is_some() {
Self::process_ipv6_get()
} else if let Some(m) = matches.subcommand_matches("set") {
@@ -315,7 +315,7 @@ impl Tunnel {
Ok(())
}
- fn process_openvpn_mssfix_set(matches: &clap::ArgMatches) -> Result<()> {
+ fn process_openvpn_mssfix_set(matches: &clap::ArgMatches<'_>) -> Result<()> {
let new_value = value_t!(matches.value_of("mssfix"), u16).unwrap_or_else(|e| e.exit());
let mut rpc = new_rpc_client()?;
rpc.set_openvpn_mssfix(Some(new_value))?;
@@ -376,7 +376,7 @@ impl Tunnel {
Ok(())
}
- fn process_openvpn_proxy_set(matches: &clap::ArgMatches) -> Result<()> {
+ fn process_openvpn_proxy_set(matches: &clap::ArgMatches<'_>) -> Result<()> {
if let Some(args) = matches.subcommand_matches("local") {
let local_port =
value_t!(args.value_of("local-port"), u16).unwrap_or_else(|e| e.exit());
@@ -471,7 +471,7 @@ impl Tunnel {
Ok(())
}
- fn process_ipv6_set(matches: &clap::ArgMatches) -> Result<()> {
+ fn process_ipv6_set(matches: &clap::ArgMatches<'_>) -> Result<()> {
let enabled = matches.value_of("enable").unwrap() == "on";
let mut rpc = new_rpc_client()?;
diff --git a/mullvad-cli/src/cmds/version.rs b/mullvad-cli/src/cmds/version.rs
index 136e2a6aa2..2566f10f18 100644
--- a/mullvad-cli/src/cmds/version.rs
+++ b/mullvad-cli/src/cmds/version.rs
@@ -12,7 +12,7 @@ impl Command for Version {
.about("Shows current version, and the currently supported versions")
}
- fn run(&self, _: &clap::ArgMatches) -> Result<()> {
+ fn run(&self, _: &clap::ArgMatches<'_>) -> Result<()> {
let mut rpc = new_rpc_client()?;
let current_version = rpc.get_current_version()?;
println!("Current version: {}", current_version);
diff --git a/mullvad-cli/src/main.rs b/mullvad-cli/src/main.rs
index 733e3a136d..389d98506c 100644
--- a/mullvad-cli/src/main.rs
+++ b/mullvad-cli/src/main.rs
@@ -6,6 +6,8 @@
//! GNU General Public License as published by the Free Software Foundation, either version 3 of
//! the License, or (at your option) any later version.
+#![deny(rust_2018_idioms)]
+
#[macro_use]
extern crate error_chain;
@@ -76,5 +78,5 @@ pub trait Command {
fn clap_subcommand(&self) -> clap::App<'static, 'static>;
- fn run(&self, matches: &clap::ArgMatches) -> Result<()>;
+ fn run(&self, matches: &clap::ArgMatches<'_>) -> Result<()>;
}