summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2022-08-29 13:14:58 +0200
committerDavid Lönnhager <david.l@mullvad.net>2022-08-29 13:14:58 +0200
commitef4ef3846b621013fa9d29b77e9399153064f7d0 (patch)
tree52b6cb7829421d8db3d0a70b381ed6990e2ebe33
parent3bca72f9f698eafb75c3c9e0490096a4fbafb9fb (diff)
parentb5594552dd9205b1edda27fe692d48eb39f267b2 (diff)
downloadmullvadvpn-ef4ef3846b621013fa9d29b77e9399153064f7d0.tar.xz
mullvadvpn-ef4ef3846b621013fa9d29b77e9399153064f7d0.zip
Merge branch 'fix-clippy-fail'
-rw-r--r--android/translations-converter/src/normalize.rs4
-rw-r--r--mullvad-api/src/lib.rs5
-rw-r--r--mullvad-api/src/proxy.rs4
-rw-r--r--mullvad-daemon/src/device/mod.rs8
-rw-r--r--mullvad-management-interface/src/types.rs7
-rw-r--r--mullvad-relay-selector/src/lib.rs3
-rw-r--r--mullvad-types/src/device.rs10
-rw-r--r--mullvad-types/src/settings/mod.rs8
-rw-r--r--mullvad-types/src/states.rs2
-rw-r--r--mullvad-types/src/wireguard.rs6
-rw-r--r--talpid-core/src/tunnel/openvpn/mod.rs1
-rw-r--r--talpid-core/src/tunnel/wireguard/stats.rs2
-rw-r--r--talpid-core/src/tunnel_state_machine/disconnecting_state.rs2
-rw-r--r--talpid-core/src/tunnel_state_machine/error_state.rs2
-rw-r--r--talpid-openvpn-plugin/src/processing.rs1
-rw-r--r--talpid-tunnel-config-client/src/lib.rs1
-rw-r--r--talpid-types/src/tunnel.rs14
17 files changed, 42 insertions, 38 deletions
diff --git a/android/translations-converter/src/normalize.rs b/android/translations-converter/src/normalize.rs
index ffeddbc6f7..4896e6d25c 100644
--- a/android/translations-converter/src/normalize.rs
+++ b/android/translations-converter/src/normalize.rs
@@ -21,7 +21,7 @@ mod android {
impl Normalize for StringValue {
fn normalize(&self) -> String {
// Unescape apostrophes
- let value = APOSTROPHES.replace_all(&*self, "'");
+ let value = APOSTROPHES.replace_all(self, "'");
// Unescape double quotes
let value = DOUBLE_QUOTES.replace_all(&value, r#"""#);
// Mark where parameters are positioned, removing the parameter index
@@ -47,7 +47,7 @@ mod gettext {
impl Normalize for MsgString {
fn normalize(&self) -> String {
// Use a single common apostrophe character
- let string = APOSTROPHE_VARIATION.replace_all(&*self, "'");
+ let string = APOSTROPHE_VARIATION.replace_all(self, "'");
// Mark where parameters are positioned, removing the parameter name
let string = PARAMETERS.replace_all(&string, "%");
// Remove escaped single-quotes
diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs
index b0222ca244..12ca3d45e4 100644
--- a/mullvad-api/src/lib.rs
+++ b/mullvad-api/src/lib.rs
@@ -236,7 +236,7 @@ impl Runtime {
new_address_callback: impl ApiEndpointUpdateCallback + Send + Sync + 'static,
#[cfg(target_os = "android")] socket_bypass_tx: Option<mpsc::Sender<SocketBypassRequest>>,
) -> rest::RequestServiceHandle {
- let service_handle = rest::RequestService::spawn(
+ rest::RequestService::spawn(
sni_hostname,
self.api_availability.handle(),
self.address_cache.clone(),
@@ -245,8 +245,7 @@ impl Runtime {
#[cfg(target_os = "android")]
socket_bypass_tx,
)
- .await;
- service_handle
+ .await
}
/// Returns a request factory initialized to create requests for the master API
diff --git a/mullvad-api/src/proxy.rs b/mullvad-api/src/proxy.rs
index cc7ee3aa6c..2f3764e7e6 100644
--- a/mullvad-api/src/proxy.rs
+++ b/mullvad-api/src/proxy.rs
@@ -19,7 +19,7 @@ use tokio::{
const CURRENT_CONFIG_FILENAME: &str = "api-endpoint.json";
-#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
+#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub enum ApiConnectionMode {
/// Connect directly to the target.
Direct,
@@ -36,7 +36,7 @@ impl fmt::Display for ApiConnectionMode {
}
}
-#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
+#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub enum ProxyConfig {
Shadowsocks(ShadowsocksProxySettings),
}
diff --git a/mullvad-daemon/src/device/mod.rs b/mullvad-daemon/src/device/mod.rs
index 93dbac49ca..aa301ca85d 100644
--- a/mullvad-daemon/src/device/mod.rs
+++ b/mullvad-daemon/src/device/mod.rs
@@ -74,7 +74,7 @@ pub enum Error {
}
/// Contains the current device state.
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
+#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum PrivateDeviceState {
LoggedIn(PrivateAccountAndDevice),
@@ -135,7 +135,7 @@ impl From<PrivateDeviceState> for DeviceState {
}
/// Same as [PrivateDevice] but also contains the associated account token.
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
+#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
pub struct PrivateAccountAndDevice {
pub account_token: AccountToken,
pub device: PrivateDevice,
@@ -151,7 +151,7 @@ impl From<PrivateAccountAndDevice> for AccountAndDevice {
}
/// Device type that contains private data.
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
+#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
pub struct PrivateDevice {
pub id: DeviceId,
pub name: DeviceName,
@@ -281,7 +281,7 @@ impl Error {
pub fn unpack(&self) -> &Error {
if let Error::ResponseFailure(ref inner) = self {
- &*inner
+ inner
} else {
self
}
diff --git a/mullvad-management-interface/src/types.rs b/mullvad-management-interface/src/types.rs
index 4ea8a9729e..3d9d7928f1 100644
--- a/mullvad-management-interface/src/types.rs
+++ b/mullvad-management-interface/src/types.rs
@@ -4,7 +4,12 @@ use mullvad_types::relay_constraints::Constraint;
use std::convert::TryFrom;
use talpid_types::{net::wireguard, ErrorExt};
-tonic::include_proto!("mullvad_daemon.management_interface");
+#[allow(clippy::derive_partial_eq_without_eq)]
+mod proto {
+ tonic::include_proto!("mullvad_daemon.management_interface");
+}
+
+pub use proto::*;
impl From<mullvad_types::location::GeoIpLocation> for GeoIpLocation {
fn from(geoip: mullvad_types::location::GeoIpLocation) -> GeoIpLocation {
diff --git a/mullvad-relay-selector/src/lib.rs b/mullvad-relay-selector/src/lib.rs
index bed781eff7..94725e767e 100644
--- a/mullvad-relay-selector/src/lib.rs
+++ b/mullvad-relay-selector/src/lib.rs
@@ -1116,7 +1116,7 @@ impl RelaySelector {
relays: &'a [RelayType],
weight_fn: impl Fn(&RelayType) -> u64,
) -> Option<&'a RelayType> {
- let total_weight: u64 = relays.iter().map(|relay| weight_fn(relay)).sum();
+ let total_weight: u64 = relays.iter().map(&weight_fn).sum();
let mut rng = rand::thread_rng();
if total_weight == 0 {
relays.choose(&mut rng)
@@ -1131,7 +1131,6 @@ impl RelaySelector {
i = i.saturating_sub(weight_fn(relay));
i == 0
})
- .map(|relay| relay)
.expect("At least one relay must've had a weight above 0"),
)
}
diff --git a/mullvad-types/src/device.rs b/mullvad-types/src/device.rs
index 38dd528fd5..5c64bdf44d 100644
--- a/mullvad-types/src/device.rs
+++ b/mullvad-types/src/device.rs
@@ -13,7 +13,7 @@ pub type DeviceId = String;
pub type DeviceName = String;
/// Contains data for a device returned by the API.
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
+#[derive(Debug, Clone, Deserialize, Serialize)]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
pub struct Device {
@@ -28,8 +28,6 @@ pub struct Device {
pub created: DateTime<Utc>,
}
-impl Eq for Device {}
-
impl Device {
/// Return name with each word capitalized: "Happy Seagull" instead of "happy seagull"
pub fn pretty_name(&self) -> String {
@@ -52,7 +50,7 @@ impl Device {
}
/// Ports associated with a device.
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
+#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
pub struct DevicePort {
@@ -67,7 +65,7 @@ impl fmt::Display for DevicePort {
}
/// Contains a device state.
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
+#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
@@ -87,7 +85,7 @@ impl DeviceState {
}
/// A [Device] and its associated account token.
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
+#[derive(Debug, Clone, Deserialize, Serialize)]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
pub struct AccountAndDevice {
diff --git a/mullvad-types/src/settings/mod.rs b/mullvad-types/src/settings/mod.rs
index d7cc62e605..3896dd6055 100644
--- a/mullvad-types/src/settings/mod.rs
+++ b/mullvad-types/src/settings/mod.rs
@@ -22,7 +22,7 @@ mod dns;
/// being added to `mullvad-daemon`.
pub const CURRENT_SETTINGS_VERSION: SettingsVersion = SettingsVersion::V6;
-#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)]
+#[derive(Debug, PartialEq, Eq, PartialOrd, Clone, Copy)]
#[repr(u32)]
pub enum SettingsVersion {
V2 = 2,
@@ -61,7 +61,7 @@ impl Serialize for SettingsVersion {
}
/// Mullvad daemon settings.
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
+#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(default)]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
@@ -107,7 +107,7 @@ fn out_of_range_wg_migration_rand_num() -> f32 {
}
#[cfg(windows)]
-#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq)]
+#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct SplitTunnelSettings {
/// Toggles split tunneling on or off
pub enable_exclusions: bool,
@@ -185,7 +185,7 @@ impl Settings {
}
/// TunnelOptions holds configuration data that applies to all kinds of tunnels.
-#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
diff --git a/mullvad-types/src/states.rs b/mullvad-types/src/states.rs
index 2d139eee3d..f6131711cb 100644
--- a/mullvad-types/src/states.rs
+++ b/mullvad-types/src/states.rs
@@ -28,7 +28,7 @@ impl fmt::Display for TargetState {
}
/// Represents the state the client tunnel is in.
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[serde(tag = "state", content = "details")]
#[cfg_attr(target_os = "android", derive(IntoJava))]
diff --git a/mullvad-types/src/wireguard.rs b/mullvad-types/src/wireguard.rs
index 612becf010..fac2adf0d3 100644
--- a/mullvad-types/src/wireguard.rs
+++ b/mullvad-types/src/wireguard.rs
@@ -15,7 +15,7 @@ pub const DEFAULT_ROTATION_INTERVAL: Duration = if cfg!(target_os = "android") {
};
/// Contains account specific wireguard data
-#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
+#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct WireguardData {
pub private_key: wireguard::PrivateKey,
pub addresses: AssociatedAddresses,
@@ -114,7 +114,7 @@ impl Default for RotationInterval {
}
}
-#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(
@@ -142,7 +142,7 @@ pub struct PublicKey {
/// Contains a pair of local link addresses that are paired with a specific wireguard
/// public/private keypair.
-#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct AssociatedAddresses {
pub ipv4_address: ipnetwork::Ipv4Network,
pub ipv6_address: ipnetwork::Ipv6Network,
diff --git a/talpid-core/src/tunnel/openvpn/mod.rs b/talpid-core/src/tunnel/openvpn/mod.rs
index 95bcac3295..8a8581df40 100644
--- a/talpid-core/src/tunnel/openvpn/mod.rs
+++ b/talpid-core/src/tunnel/openvpn/mod.rs
@@ -826,6 +826,7 @@ mod event_server {
Request, Response,
};
+ #[allow(clippy::derive_partial_eq_without_eq)]
mod proto {
tonic::include_proto!("talpid_openvpn_plugin");
}
diff --git a/talpid-core/src/tunnel/wireguard/stats.rs b/talpid-core/src/tunnel/wireguard/stats.rs
index cec033f611..bd7b578545 100644
--- a/talpid-core/src/tunnel/wireguard/stats.rs
+++ b/talpid-core/src/tunnel/wireguard/stats.rs
@@ -17,7 +17,7 @@ pub enum Error {
}
/// Contains bytes sent and received through a tunnel
-#[derive(Default, Debug, PartialEq, Clone, Copy)]
+#[derive(Default, Debug, PartialEq, Eq, Clone, Copy)]
pub struct Stats {
pub tx_bytes: u64,
pub rx_bytes: u64,
diff --git a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs
index 8e7e85fd36..954de76034 100644
--- a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs
+++ b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs
@@ -78,7 +78,7 @@ impl DisconnectingState {
}
Some(TunnelCommand::IsOffline(is_offline)) => {
shared_values.is_offline = is_offline;
- if !is_offline && reason == ErrorStateCause::IsOffline {
+ if !is_offline && matches!(reason, ErrorStateCause::IsOffline) {
AfterDisconnect::Reconnect(0)
} else {
AfterDisconnect::Block(reason)
diff --git a/talpid-core/src/tunnel_state_machine/error_state.rs b/talpid-core/src/tunnel_state_machine/error_state.rs
index a11e49d859..b12beecff4 100644
--- a/talpid-core/src/tunnel_state_machine/error_state.rs
+++ b/talpid-core/src/tunnel_state_machine/error_state.rs
@@ -178,7 +178,7 @@ impl TunnelState for ErrorState {
}
Some(TunnelCommand::IsOffline(is_offline)) => {
shared_values.is_offline = is_offline;
- if !is_offline && self.block_reason == ErrorStateCause::IsOffline {
+ if !is_offline && matches!(self.block_reason, ErrorStateCause::IsOffline) {
Self::reset_dns(shared_values);
NewState(ConnectingState::enter(shared_values, 0))
} else {
diff --git a/talpid-openvpn-plugin/src/processing.rs b/talpid-openvpn-plugin/src/processing.rs
index ba0b76a34d..0f3c869446 100644
--- a/talpid-openvpn-plugin/src/processing.rs
+++ b/talpid-openvpn-plugin/src/processing.rs
@@ -10,6 +10,7 @@ use tonic::{
use tokio::runtime::{self, Runtime};
+#[allow(clippy::derive_partial_eq_without_eq)]
mod proto {
tonic::include_proto!("talpid_openvpn_plugin");
}
diff --git a/talpid-tunnel-config-client/src/lib.rs b/talpid-tunnel-config-client/src/lib.rs
index 9ab7f6b9d0..b1356aba1b 100644
--- a/talpid-tunnel-config-client/src/lib.rs
+++ b/talpid-tunnel-config-client/src/lib.rs
@@ -4,6 +4,7 @@ use tonic::transport::Channel;
mod kem;
+#[allow(clippy::derive_partial_eq_without_eq)]
mod proto {
tonic::include_proto!("tunnel_config");
}
diff --git a/talpid-types/src/tunnel.rs b/talpid-types/src/tunnel.rs
index af84e35390..31f78c2894 100644
--- a/talpid-types/src/tunnel.rs
+++ b/talpid-types/src/tunnel.rs
@@ -8,7 +8,7 @@ use std::net::IpAddr;
/// Event emitted from the states in `talpid_core::tunnel_state_machine` when the tunnel state
/// machine enters a new state.
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug)]
pub enum TunnelStateTransition {
/// No connection is established and network is unsecured.
Disconnected,
@@ -23,7 +23,7 @@ pub enum TunnelStateTransition {
}
/// Action that will be taken after disconnection is complete.
-#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
+#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.talpid.tunnel"))]
@@ -34,7 +34,7 @@ pub enum ActionAfterDisconnect {
}
/// Represents the tunnel state machine entering an error state during a [`TunnelStateTransition`].
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.talpid.tunnel"))]
@@ -75,7 +75,7 @@ impl ErrorState {
}
/// Reason for the tunnel state machine entering an [`ErrorState`].
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[serde(tag = "reason", content = "details")]
#[cfg_attr(target_os = "android", derive(IntoJava))]
@@ -117,7 +117,7 @@ impl ErrorStateCause {
}
/// Errors that can occur when generating tunnel parameters.
-#[derive(err_derive::Error, Debug, Serialize, Clone, PartialEq, Deserialize)]
+#[derive(err_derive::Error, Debug, Serialize, Clone, Deserialize)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(target_os = "android", derive(IntoJava))]
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.talpid.tunnel"))]
@@ -138,14 +138,14 @@ pub enum ParameterGenerationError {
/// Application that prevents setting the firewall policy.
#[cfg(windows)]
-#[derive(Debug, Serialize, Clone, PartialEq, Deserialize)]
+#[derive(Debug, Serialize, Clone, Deserialize)]
pub struct BlockingApplication {
pub name: String,
pub pid: u32,
}
/// Errors that can occur when setting the firewall policy.
-#[derive(err_derive::Error, Debug, Serialize, Clone, PartialEq, Deserialize)]
+#[derive(err_derive::Error, Debug, Serialize, Clone, Deserialize)]
#[serde(rename_all = "snake_case")]
#[serde(tag = "reason", content = "details")]
#[cfg_attr(target_os = "android", derive(IntoJava))]