diff --git a/Cargo.toml b/Cargo.toml index 0195d52..fa562b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tun2" -version = "3.1.5" +version = "3.1.6" edition = "2021" authors = ["meh. ", "@ssrlive"] license = "WTFPL" diff --git a/src/address.rs b/src/address.rs index 957c1fa..5f19d70 100644 --- a/src/address.rs +++ b/src/address.rs @@ -83,10 +83,7 @@ impl<'a> ToAddress for &'a Ipv4Addr { impl ToAddress for IpAddr { fn to_address(&self) -> Result { - match self { - IpAddr::V4(value) => Ok(IpAddr::V4(*value)), - IpAddr::V6(value) => Ok(IpAddr::V6(*value)), - } + Ok(*self) } } @@ -110,10 +107,7 @@ impl<'a> ToAddress for &'a SocketAddrV4 { impl ToAddress for SocketAddr { fn to_address(&self) -> Result { - match self { - SocketAddr::V4(value) => Ok(IpAddr::V4(*value.ip())), - SocketAddr::V6(value) => Ok(IpAddr::V6(*value.ip())), - } + Ok(self.ip()) } } diff --git a/src/platform/windows/device.rs b/src/platform/windows/device.rs index 23df0be..b5a42ca 100644 --- a/src/platform/windows/device.rs +++ b/src/platform/windows/device.rs @@ -165,10 +165,7 @@ impl AbstractDevice for Device { let addresses = tun.session.get_adapter().get_addresses()?; addresses .iter() - .find_map(|a| match a { - std::net::IpAddr::V4(a) => Some(std::net::IpAddr::V4(*a)), - _ => None, - }) + .find_map(|a| Some(*a)) .ok_or(Error::InvalidConfig) } Driver::Tap(_tap) => unimplemented!(), @@ -196,10 +193,7 @@ impl AbstractDevice for Device { .get_adapter() .get_gateways()? .iter() - .find_map(|a| match a { - std::net::IpAddr::V4(a) => Some(std::net::IpAddr::V4(*a)), - _ => None, - }) + .find_map(|a| Some(*a)) .ok_or(Error::InvalidConfig), Driver::Tap(_tap) => unimplemented!(), }