MCPcopy
hub / github.com/CodisLabs/codis / init

Function init

pkg/utils/resolver.go:63–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61)
62
63func 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
87func ReplaceUnspecifiedIP(network string, listenAddr, globalAddr string) (string, error) {
88 if globalAddr == "" {

Callers

nothing calls this directly

Calls 2

LookupIPTimeoutFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected