Show alternative URLs when address is 0.0.0.0
This commit is contained in:
28
server/list_address.go
Normal file
28
server/list_address.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func listAddresses() (addresses []string) {
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
addresses = make([]string, 0, len(ifaces))
|
||||
|
||||
for _, iface := range ifaces {
|
||||
ifAddrs, _ := iface.Addrs()
|
||||
for _, ifAddr := range ifAddrs {
|
||||
switch v := ifAddr.(type) {
|
||||
case *net.IPNet:
|
||||
addresses = append(addresses, v.IP.String())
|
||||
case *net.IPAddr:
|
||||
addresses = append(addresses, v.IP.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return addresses
|
||||
}
|
||||
Reference in New Issue
Block a user