|
|
@@ -24,14 +24,15 @@ func fetchIP(url string) (net.IP, error) {
|
|
24
|
24
|
}
|
|
25
|
25
|
defer resp.Body.Close() // nolint: errcheck
|
|
26
|
26
|
|
|
27
|
|
- respData, err := ioutil.ReadAll(resp.Body)
|
|
|
27
|
+ respDataBytes, err := ioutil.ReadAll(resp.Body)
|
|
28
|
28
|
if err != nil {
|
|
29
|
29
|
return nil, err
|
|
30
|
30
|
}
|
|
|
31
|
+ respData := strings.TrimSpace(string(respDataBytes))
|
|
31
|
32
|
|
|
32
|
|
- ip := net.ParseIP(strings.TrimSpace(string(respData)))
|
|
|
33
|
+ ip := net.ParseIP(respData)
|
|
33
|
34
|
if ip == nil {
|
|
34
|
|
- return nil, errors.Errorf("ifconfig.co returns incorrect IP %s", resp)
|
|
|
35
|
+ return nil, errors.Errorf("ifconfig.co returns incorrect IP %s", respData)
|
|
35
|
36
|
}
|
|
36
|
37
|
|
|
37
|
38
|
return ip, nil
|