Show IPv6 addresses with `[` and `]`
So that users can open IPv6 URLs on web browsers.
This commit is contained in:
parent
a0f6e8d051
commit
5d2cdd2768
|
@ -221,10 +221,13 @@ func listAddresses() (addresses []string) {
|
|||
for _, ifAddr := range ifAddrs {
|
||||
switch v := ifAddr.(type) {
|
||||
case *net.IPNet:
|
||||
if v.IP.To4() == nil {
|
||||
addresses = append(addresses, "["+v.IP.String()+"]")
|
||||
} else {
|
||||
addresses = append(addresses, v.IP.String())
|
||||
}
|
||||
case *net.IPAddr:
|
||||
addresses = append(addresses, v.IP.To16().String())
|
||||
addresses = append(addresses, v.IP.To4().String())
|
||||
addresses = append(addresses, v.IP.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue