mirror of
https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git
synced 2024-08-30 17:42:10 +00:00
correct some missing "checkError" calls and add more log messages
This commit is contained in:
parent
684cdc3a3d
commit
b83ab75472
@ -94,10 +94,12 @@ func GetConfig() ClientConfig {
|
|||||||
configFile = flag.Args()[0]
|
configFile = flag.Args()[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("Using Config file: %s", configFile)
|
||||||
|
|
||||||
getfile, err := ioutil.ReadFile(configFile)
|
getfile, err := ioutil.ReadFile(configFile)
|
||||||
checkError(err)
|
checkError(err)
|
||||||
var config ClientConfig
|
var config ClientConfig
|
||||||
json.Unmarshal(getfile, &config)
|
err = json.Unmarshal(getfile, &config)
|
||||||
checkError(err)
|
checkError(err)
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
@ -130,6 +132,7 @@ func CheckLocalIPs() (ipv4, ipv6 net.IP) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if config.UseIPv4 == nil || *(config.UseIPv4) {
|
if config.UseIPv4 == nil || *(config.UseIPv4) {
|
||||||
|
log.Printf("Checking IPv4 with URL: %s", ipv4CheckURL)
|
||||||
ipv4String, _ = getURLBody(ipv4CheckURL)
|
ipv4String, _ = getURLBody(ipv4CheckURL)
|
||||||
if ipv4String == "" {
|
if ipv4String == "" {
|
||||||
log.Println("No IPv4 address found. Consider disabling IPv4 checks in the config `\"useIPv4\": false`")
|
log.Println("No IPv4 address found. Consider disabling IPv4 checks in the config `\"useIPv4\": false`")
|
||||||
@ -147,6 +150,7 @@ func CheckLocalIPs() (ipv4, ipv6 net.IP) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if config.UseIPv6 == nil || *(config.UseIPv6) {
|
if config.UseIPv6 == nil || *(config.UseIPv6) {
|
||||||
|
log.Printf("Checking IPv6 with URL: %s", ipv6CheckURL)
|
||||||
ipv6String, _ = getURLBody(ipv6CheckURL)
|
ipv6String, _ = getURLBody(ipv6CheckURL)
|
||||||
if ipv6String == "" {
|
if ipv6String == "" {
|
||||||
log.Println("No IPv6 address found. Consider disabling IPv6 checks in the config `\"useIPv6\": false`")
|
log.Println("No IPv6 address found. Consider disabling IPv6 checks in the config `\"useIPv6\": false`")
|
||||||
@ -203,10 +207,11 @@ func getPage(url string) DOResponse {
|
|||||||
checkError(err)
|
checkError(err)
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
body, err := ioutil.ReadAll(response.Body)
|
body, err := ioutil.ReadAll(response.Body)
|
||||||
|
checkError(err)
|
||||||
// log.Println(string(body))
|
// log.Println(string(body))
|
||||||
var jsonDOResponse DOResponse
|
var jsonDOResponse DOResponse
|
||||||
e := json.Unmarshal(body, &jsonDOResponse)
|
err = json.Unmarshal(body, &jsonDOResponse)
|
||||||
checkError(e)
|
checkError(err)
|
||||||
return jsonDOResponse
|
return jsonDOResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,6 +291,7 @@ func UpdateRecords(domain Domain, ipv4, ipv6 net.IP) {
|
|||||||
checkError(err)
|
checkError(err)
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
body, err := ioutil.ReadAll(response.Body)
|
body, err := ioutil.ReadAll(response.Body)
|
||||||
|
checkError(err)
|
||||||
log.Printf("%s: DO update response for %s: %s", domain.Domain, doRecord.Name, string(body))
|
log.Printf("%s: DO update response for %s: %s", domain.Domain, doRecord.Name, string(body))
|
||||||
updated++
|
updated++
|
||||||
}
|
}
|
||||||
@ -325,14 +331,14 @@ func toIPv6String(ip net.IP) (currentIP string) {
|
|||||||
return currentIP
|
return currentIP
|
||||||
}
|
}
|
||||||
|
|
||||||
func areZero(bs []byte) bool {
|
// func areZero(bs []byte) bool {
|
||||||
for _, b := range bs {
|
// for _, b := range bs {
|
||||||
if b != 0 {
|
// if b != 0 {
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config = GetConfig()
|
config = GetConfig()
|
||||||
|
Loading…
Reference in New Issue
Block a user