diff options
| author | David Lönnhager <david.l@mullvad.net> | 2022-10-12 11:27:05 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2022-10-17 10:47:36 +0200 |
| commit | 360bbf0c8479a2e19041203c9568fc00785b6e32 (patch) | |
| tree | 442cc688fd24cdda7dde56fb4836d816cf568211 | |
| parent | 8e2e85e2c41268ce69e363add25ec2c375da00a8 (diff) | |
| download | mullvadvpn-360bbf0c8479a2e19041203c9568fc00785b6e32.tar.xz mullvadvpn-360bbf0c8479a2e19041203c9568fc00785b6e32.zip | |
Simplify obfuscation endpoint formatting
| -rw-r--r-- | mullvad-management-interface/src/types.rs | 13 | ||||
| -rw-r--r-- | talpid-types/src/net/mod.rs | 10 |
2 files changed, 12 insertions, 11 deletions
diff --git a/mullvad-management-interface/src/types.rs b/mullvad-management-interface/src/types.rs index 7f5c06aa2c..06c842c12e 100644 --- a/mullvad-management-interface/src/types.rs +++ b/mullvad-management-interface/src/types.rs @@ -1,7 +1,7 @@ pub use prost_types::{Duration, Timestamp}; use mullvad_types::relay_constraints::Constraint; -use std::{convert::TryFrom, str::FromStr}; +use std::{convert::TryFrom, net::SocketAddr, str::FromStr}; use talpid_types::{net::wireguard, ErrorExt}; #[allow(clippy::derive_partial_eq_without_eq)] @@ -417,10 +417,13 @@ impl TryFrom<TunnelEndpoint> for talpid_types::net::TunnelEndpoint { .map(|obfs_ep| { Ok(talpid_net::ObfuscationEndpoint { endpoint: talpid_net::Endpoint { - address: arg_from_str( - &obfs_ep.address, - "invalid obfuscation endpoint address", - )?, + address: SocketAddr::new( + arg_from_str( + &obfs_ep.address, + "invalid obfuscation endpoint address", + )?, + obfs_ep.port as u16, + ), protocol: try_transport_protocol_from_i32(obfs_ep.protocol)?, }, obfuscation_type: match ObfuscationType::from_i32(obfs_ep.obfuscation_type) diff --git a/talpid-types/src/net/mod.rs b/talpid-types/src/net/mod.rs index 20ef780f5c..7e2ef2d808 100644 --- a/talpid-types/src/net/mod.rs +++ b/talpid-types/src/net/mod.rs @@ -179,10 +179,9 @@ pub enum ObfuscationType { impl fmt::Display for ObfuscationType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - let obfuscation = match self { - ObfuscationType::Udp2Tcp => "Udp2Tcp", - }; - write!(f, "{}", obfuscation) + match self { + ObfuscationType::Udp2Tcp => "Udp2Tcp".fmt(f), + } } } @@ -214,8 +213,7 @@ impl From<&ObfuscatorConfig> for ObfuscationEndpoint { impl fmt::Display for ObfuscationEndpoint { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - write!(f, "{} {}", self.obfuscation_type, self.endpoint)?; - Ok(()) + write!(f, "{} {}", self.obfuscation_type, self.endpoint) } } |
