mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-22 06:49:08 +00:00
Fix formatting
IPv6 addresses without ports are not enclosed in brackets. They only get enclosed in brackets in combination with a port.
This commit is contained in:
parent
d4410264e6
commit
e6e6c70006
1 changed files with 6 additions and 5 deletions
|
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue