remove the From implement

This commit is contained in:
ssrlive 2023-03-23 21:39:27 +08:00
parent e3e402d8ce
commit 32403c5423

View file

@ -60,20 +60,6 @@ impl TryFrom<Destination> for SocketAddr {
} }
} }
impl From<&Destination> for SocketAddr {
fn from(value: &Destination) -> Self {
SocketAddr::new(
match value.host {
DestinationHost::Address(addr) => addr,
Hostname(_) => {
panic!("Failed to convert hostname destination into socket address")
}
},
value.port,
)
}
}
impl From<SocketAddr> for Destination { impl From<SocketAddr> for Destination {
fn from(addr: SocketAddr) -> Self { fn from(addr: SocketAddr) -> Self {
Self { Self {
@ -438,7 +424,8 @@ impl<'a> TunToProxy<'a> {
let resolved_conn = match &self.options.virtdns { let resolved_conn = match &self.options.virtdns {
None => connection.clone(), None => connection.clone(),
Some(virt_dns) => { Some(virt_dns) => {
match virt_dns.ip_to_name(&SocketAddr::from(&connection.dst).ip()) { let ip = SocketAddr::try_from(connection.dst.clone()).unwrap().ip();
match virt_dns.ip_to_name(&ip) {
None => connection.clone(), None => connection.clone(),
Some(name) => connection.to_named(name.clone()), Some(name) => connection.to_named(name.clone()),
} }