|
|
@ -30,10 +30,7 @@ pub enum DestinationHost { |
|
|
impl std::fmt::Display for DestinationHost { |
|
|
impl std::fmt::Display for DestinationHost { |
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
|
|
match self { |
|
|
match self { |
|
|
DestinationHost::Address(addr) => match addr { |
|
|
DestinationHost::Address(addr) => addr.fmt(f), |
|
|
IpAddr::V4(_) => addr.fmt(f), |
|
|
|
|
|
IpAddr::V6(_) => write!(f, "[{}]", addr), |
|
|
|
|
|
}, |
|
|
|
|
|
Hostname(name) => name.fmt(f), |
|
|
Hostname(name) => name.fmt(f), |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -69,7 +66,11 @@ impl From<SocketAddr> for Destination { |
|
|
|
|
|
|
|
|
impl std::fmt::Display for Destination { |
|
|
impl std::fmt::Display for Destination { |
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
|
|
write!(f, "{}:{}", self.host, self.port) |
|
|
if let DestinationHost::Address(IpAddr::V6(addr)) = self.host { |
|
|
|
|
|
write!(f, "[{}]:{}", addr, self.port) |
|
|
|
|
|
} else { |
|
|
|
|
|
write!(f, "{}:{}", self.host, self.port) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|