From 1b1fb71e44d0e192c1c1645f6d2c9c3df6f64a6a Mon Sep 17 00:00:00 2001 From: Asim Date: Sat, 29 Oct 2016 21:34:15 +0100 Subject: [PATCH] move function --- transport/http_transport.go | 78 ++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/transport/http_transport.go b/transport/http_transport.go index 57084d08..2eb74bd8 100644 --- a/transport/http_transport.go +++ b/transport/http_transport.go @@ -56,6 +56,45 @@ type httpTransportListener struct { listener net.Listener } +func getIPAddrs() []string { + ifaces, err := net.Interfaces() + if err != nil { + return nil + } + + var ipAddrs []string + + for _, i := range ifaces { + addrs, err := i.Addrs() + if err != nil { + continue + } + + for _, addr := range addrs { + var ip net.IP + switch v := addr.(type) { + case *net.IPNet: + ip = v.IP + case *net.IPAddr: + ip = v.IP + } + + if ip == nil { + continue + } + + ip = ip.To4() + if ip == nil { + continue + } + + ipAddrs = append(ipAddrs, ip.String()) + } + } + + return ipAddrs +} + func listen(addr string, fn func(string) (net.Listener, error)) (net.Listener, error) { // host:port || host:min-max parts := strings.Split(addr, ":") @@ -479,45 +518,6 @@ func (h *httpTransport) String() string { return "http" } -func getIPAddrs() []string { - ifaces, err := net.Interfaces() - if err != nil { - return nil - } - - var ipAddrs []string - - for _, i := range ifaces { - addrs, err := i.Addrs() - if err != nil { - continue - } - - for _, addr := range addrs { - var ip net.IP - switch v := addr.(type) { - case *net.IPNet: - ip = v.IP - case *net.IPAddr: - ip = v.IP - } - - if ip == nil { - continue - } - - ip = ip.To4() - if ip == nil { - continue - } - - ipAddrs = append(ipAddrs, ip.String()) - } - } - - return ipAddrs -} - func newHTTPTransport(opts ...Option) *httpTransport { var options Options for _, o := range opts {