()
| 61 | ) |
| 62 | |
| 63 | func init() { |
| 64 | if ipAddrs := LookupIPTimeout(Hostname, 30*time.Millisecond); len(ipAddrs) != 0 { |
| 65 | for _, ip := range ipAddrs { |
| 66 | if ip.IsGlobalUnicast() { |
| 67 | HostIPs = append(HostIPs, ip.String()) |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | if ifAddrs, _ := net.InterfaceAddrs(); len(ifAddrs) != 0 { |
| 72 | for i := range ifAddrs { |
| 73 | var ip net.IP |
| 74 | switch in := ifAddrs[i].(type) { |
| 75 | case *net.IPNet: |
| 76 | ip = in.IP |
| 77 | case *net.IPAddr: |
| 78 | ip = in.IP |
| 79 | } |
| 80 | if ip.IsGlobalUnicast() { |
| 81 | InterfaceIPs = append(InterfaceIPs, ip.String()) |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | func ReplaceUnspecifiedIP(network string, listenAddr, globalAddr string) (string, error) { |
| 88 | if globalAddr == "" { |
nothing calls this directly
no test coverage detected