mirror of
https://gitlab.durp.info/durfy/apps/durpdns.git
synced 2026-05-07 07:50:33 -05:00
Add timeout
This commit is contained in:
parent
9446758739
commit
06c9569e82
1 changed files with 14 additions and 2 deletions
16
main.go
16
main.go
|
|
@ -63,6 +63,15 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = updateDNSRecords(
|
||||||
|
client,
|
||||||
|
config.CloudflareZoneID,
|
||||||
|
ExistingIP.IPAddress,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("Your public IP address is:", ExistingIP.IPAddress)
|
fmt.Println("Your public IP address is:", ExistingIP.IPAddress)
|
||||||
|
|
||||||
do:
|
do:
|
||||||
|
|
@ -70,7 +79,7 @@ do:
|
||||||
CurrentIP, err := getIP()
|
CurrentIP, err := getIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
break
|
continue do
|
||||||
}
|
}
|
||||||
|
|
||||||
if ExistingIP.IPAddress != CurrentIP.IPAddress {
|
if ExistingIP.IPAddress != CurrentIP.IPAddress {
|
||||||
|
|
@ -101,8 +110,11 @@ do:
|
||||||
|
|
||||||
func getIP() (*IPResponse, error) {
|
func getIP() (*IPResponse, error) {
|
||||||
|
|
||||||
|
client := &http.Client{
|
||||||
|
Timeout: time.Second * 5,
|
||||||
|
}
|
||||||
var ip IPResponse
|
var ip IPResponse
|
||||||
resp, err := http.Get("https://myip.wtf/json")
|
resp, err := client.Get("https://myip.wtf/json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue