MCPcopy Index your code
hub / github.com/koding/kite / publicIP

Function publicIP

registerurl.go:80–100  ·  view source on GitHub ↗

publicIP returns an IP that is supposed to be Public.

()

Source from the content-addressed store, hash-verified

78
79// publicIP returns an IP that is supposed to be Public.
80func publicIP() (net.IP, error) {
81 resp, err := http.Get(publicEcho)
82 if err != nil {
83 return nil, err
84 }
85 defer resp.Body.Close()
86
87 // The ip address is 16 chars long, we read more
88 // to account for excessive whitespace.
89 p, err := ioutil.ReadAll(io.LimitReader(resp.Body, 24))
90 if err != nil {
91 return nil, err
92 }
93
94 n := net.ParseIP(string(bytes.TrimSpace(p)))
95 if n == nil {
96 return nil, fmt.Errorf("cannot parse ip %s", p)
97 }
98
99 return n, nil
100}

Callers 1

RegisterURLMethod · 0.85

Calls 2

GetMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected