Attempt to avoid setting the domain to something that isn't an IP address

This commit is contained in:
Kevin MacMartin 2024-06-24 22:59:12 -04:00
parent 720bb3707f
commit ed4428e846

View file

@ -7,6 +7,7 @@ import (
"strings"
"sync"
"time"
"net"
"git.darkcloud.ca/kevin/name-dyndns/api"
"git.darkcloud.ca/kevin/name-dyndns/log"
@ -28,6 +29,9 @@ func contains(c api.Config, val string) bool {
}
func updateDNSRecord(a api.API, domain, recordID string, newRecord api.DNSRecord) error {
addr := net.ParseIP(record.Content)
if addr != nil {
log.Logger.Printf("Deleting DNS record for %s.\n", newRecord.Name)
err := a.DeleteDNSRecord(domain, newRecord.RecordID)
if err != nil {
@ -46,6 +50,9 @@ func updateDNSRecord(a api.API, domain, recordID string, newRecord api.DNSRecord
}
return a.CreateDNSRecord(domain, newRecord)
} else {
log.Logger.Printf("Unable to parse IP: %s\n", newRecord)
}
}
func runConfig(c api.Config, daemon bool) {