summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2024-10-21 13:14:26 +0200
committerMarkus Pettersson <markus.pettersson@mullvad.net>2024-10-23 14:59:46 +0200
commita9d5994b0fb425c5a3eabc0591e341be308bdfb7 (patch)
tree52811e4748c04469769b7b5c0634f9fef798f40e
parent9e99d2aa2d9df2d39002c15e75ccf44ccb7ead20 (diff)
downloadmullvadvpn-a9d5994b0fb425c5a3eabc0591e341be308bdfb7.tar.xz
mullvadvpn-a9d5994b0fb425c5a3eabc0591e341be308bdfb7.zip
Do not implement `std::fmt::Display` for `ProxyConfig`
Use the Debug implementation in the one case where the Display implementation was used.
-rw-r--r--mullvad-api/src/proxy.rs27
-rw-r--r--mullvad-daemon/src/api.rs9
2 files changed, 4 insertions, 32 deletions
diff --git a/mullvad-api/src/proxy.rs b/mullvad-api/src/proxy.rs
index 3cf38acab0..279a289289 100644
--- a/mullvad-api/src/proxy.rs
+++ b/mullvad-api/src/proxy.rs
@@ -1,7 +1,7 @@
use hyper_util::client::legacy::connect::{Connected, Connection};
use serde::{Deserialize, Serialize};
use std::{
- fmt, io,
+ io,
net::SocketAddr,
path::Path,
pin::Pin,
@@ -61,15 +61,6 @@ pub enum ApiConnectionMode {
Proxied(ProxyConfig),
}
-impl fmt::Display for ApiConnectionMode {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
- match self {
- ApiConnectionMode::Direct => write!(f, "unproxied"),
- ApiConnectionMode::Proxied(settings) => settings.fmt(f),
- }
- }
-}
-
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub enum ProxyConfig {
Shadowsocks(proxy::Shadowsocks),
@@ -97,22 +88,6 @@ impl ProxyConfig {
}
}
-impl fmt::Display for ProxyConfig {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
- let endpoint = self.get_endpoint();
- match self {
- ProxyConfig::Shadowsocks(_) => write!(f, "Shadowsocks {}", endpoint),
- ProxyConfig::Socks5Remote(_) => write!(f, "Socks5 {}", endpoint),
- ProxyConfig::Socks5Local(local) => {
- write!(f, "Socks5 {} via localhost:{}", endpoint, local.local_port)
- }
- ProxyConfig::EncryptedDnsProxy(proxy) => {
- write!(f, "ApiSusan {}", proxy.addr)
- }
- }
- }
-}
-
impl From<proxy::CustomProxy> for ProxyConfig {
fn from(value: proxy::CustomProxy) -> Self {
match value {
diff --git a/mullvad-daemon/src/api.rs b/mullvad-daemon/src/api.rs
index 87bf660a79..f9e7fb12c6 100644
--- a/mullvad-daemon/src/api.rs
+++ b/mullvad-daemon/src/api.rs
@@ -425,13 +425,10 @@ impl AccessModeSelector {
// Save the new connection mode to cache!
let cache_dir = self.cache_dir.clone();
- let new_connection_mode = resolved.connection_mode.clone();
+ let connection_mode = resolved.connection_mode.clone();
tokio::spawn(async move {
- if new_connection_mode.save(&cache_dir).await.is_err() {
- log::warn!(
- "Failed to save {connection_mode} to cache",
- connection_mode = new_connection_mode
- )
+ if connection_mode.save(&cache_dir).await.is_err() {
+ log::warn!("Failed to save {connection_mode:#?} to cache")
}
});