potential fix for #25

This commit is contained in:
Craig 2020-02-10 07:13:40 +00:00
parent f422db4eb5
commit 3d1341cfe1
6 changed files with 74 additions and 23 deletions

View file

@ -0,0 +1,24 @@
package utils
import (
"bytes"
"io/ioutil"
"net/http"
)
// dig @resolver1.opendns.com ANY myip.opendns.com +short -4
func GetIP() (string, error) {
rsp, err := http.Get("http://checkip.amazonaws.com")
if err != nil {
return "", err
}
defer rsp.Body.Close()
buf, err := ioutil.ReadAll(rsp.Body)
if err != nil {
return "", err
}
return string(bytes.TrimSpace(buf)), nil
}