mirror of
https://github.com/m1k1o/neko.git
synced 2025-06-03 11:22:37 +02:00
potential fix for #25
This commit is contained in:
parent
f422db4eb5
commit
3d1341cfe1
6 changed files with 74 additions and 23 deletions
24
server/internal/utils/ip.go
Normal file
24
server/internal/utils/ip.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue