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
|
||||||
|
}
|
5
godns.go
5
godns.go
@ -27,6 +27,9 @@ func main() {
|
|||||||
|
|
||||||
func dns_loop(setting Settings, loop chan bool) {
|
func dns_loop(setting Settings, loop chan bool) {
|
||||||
fmt.Println("Inside the loop...")
|
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
|
loop <- false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user