mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
add get current IP func
This commit is contained in:
parent
9507da5924
commit
06dd9a89a5
20
dns_handler.go
Normal file
20
dns_handler.go
Normal file
@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetCurrentIP(url string) (string, error) {
|
||||
response, err := http.Get(url)
|
||||
defer response.Body.Close()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Cannot get IP...")
|
||||
return "", err
|
||||
}
|
||||
|
||||
body, _ := ioutil.ReadAll(response.Body)
|
||||
return string(body), nil
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user