MCPcopy
hub / github.com/istio/istio / getLocalIP

Function getLocalIP

pkg/ctrlz/ctrlz.go:82–97  ·  view source on GitHub ↗

getLocalIP returns a non loopback local IP of the host

()

Source from the content-addressed store, hash-verified

80
81// getLocalIP returns a non loopback local IP of the host
82func getLocalIP() string {
83 addrs, err := net.InterfaceAddrs()
84 if err != nil {
85 return ""
86 }
87
88 for _, address := range addrs {
89 // check the address type and if it is not a loopback then return it
90 if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
91 if ipnet.IP.To4() != nil {
92 return ipnet.IP.String()
93 }
94 }
95 }
96 return ""
97}
98
99type topic struct {
100 Name string

Callers 2

getHomeInfoFunction · 0.70
RunFunction · 0.70

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…