1
0
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:
Timothy 2014-05-12 19:04:05 +08:00
parent 9507da5924
commit 06dd9a89a5
2 changed files with 24 additions and 1 deletions

20
dns_handler.go Normal file
View 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
}

View File

@ -27,6 +27,9 @@ func main() {
func dns_loop(setting Settings, loop chan bool) {
fmt.Println("Inside the loop...")
time.Sleep(time.Second * 10)
//time.Sleep(time.Second * 60 * 5)
time.Sleep(time.Second * 5)
fmt.Println(GetCurrentIP(setting.IP_Url))
loop <- false
}