MCPcopy Create free account
hub / github.com/ethstorage/es-node / GetLocalPublicIPv4

Function GetLocalPublicIPv4

ethstorage/p2p/node.go:329–345  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

327}
328
329func GetLocalPublicIPv4() net.IP {
330 addresses, err := net.InterfaceAddrs()
331 if err != nil {
332 return nil
333 }
334
335 for _, addr := range addresses {
336 ipnet, ok := addr.(*net.IPNet)
337 if !ok || ipnet.IP.To4() == nil {
338 continue
339 }
340 if ipnet.IP.IsGlobalUnicast() && !ipnet.IP.IsPrivate() {
341 return ipnet.IP.To4()
342 }
343 }
344 return nil
345}

Callers 2

SendEmailFunction · 0.92
initMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected