mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-09 23:34:26 +00:00
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:
|
||||
addresses = append(addresses, v.IP.String())
|
||||
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
Block a user