MCPcopy Create free account
hub / github.com/codeexpress/respounder / getValidIPv4Addr

Function getValidIPv4Addr

respounder.go:217–226  ·  view source on GitHub ↗

From all the IP addresses of this interface, extract the IPv4 address where we'll bind to

(addrs []net.Addr)

Source from the content-addressed store, hash-verified

215// From all the IP addresses of this interface,
216// extract the IPv4 address where we'll bind to
217func getValidIPv4Addr(addrs []net.Addr) net.IP {
218 var ip net.IP
219 for _, addr := range addrs { // amongst all addrs,
220 ip = addr.(*net.IPNet).IP.To4() // pick the IPv4 addr
221 if ip != nil && ip.String() != "127.0.0.1" {
222 break
223 }
224 }
225 return ip
226}
227
228// parses cmd line flag and set appropriate variables
229func initFlags() {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected