Compare commits

..

No commits in common. "ed4428e84667a01a420710afac71e5161ae19b8d" and "7a54e0b4e0d9b2bacf9195bfa9d1ebf0e26249f6" have entirely different histories.

2 changed files with 22 additions and 29 deletions

View file

@ -7,10 +7,9 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"net"
"git.darkcloud.ca/kevin/name-dyndns/api" "git.darkcloud.ca/kmacmart/name-dyndns/api"
"git.darkcloud.ca/kevin/name-dyndns/log" "git.darkcloud.ca/kmacmart/name-dyndns/log"
) )
var wg sync.WaitGroup var wg sync.WaitGroup
@ -29,30 +28,24 @@ func contains(c api.Config, val string) bool {
} }
func updateDNSRecord(a api.API, domain, recordID string, newRecord api.DNSRecord) error { func updateDNSRecord(a api.API, domain, recordID string, newRecord api.DNSRecord) error {
addr := net.ParseIP(record.Content) log.Logger.Printf("Deleting DNS record for %s.\n", newRecord.Name)
err := a.DeleteDNSRecord(domain, newRecord.RecordID)
if addr != nil { if err != nil {
log.Logger.Printf("Deleting DNS record for %s.\n", newRecord.Name) return err
err := a.DeleteDNSRecord(domain, newRecord.RecordID)
if err != nil {
return err
}
log.Logger.Printf("Creating DNS record for %s: %s\n", newRecord.Name, newRecord)
// Remove the domain from the DNSRecord name.
// This is an unfortunate inconsistency from the API
// implementation (returns full name, but only requires host)
if newRecord.Name == domain {
newRecord.Name = ""
} else {
newRecord.Name = strings.TrimSuffix(newRecord.Name, fmt.Sprintf(".%s", domain))
}
return a.CreateDNSRecord(domain, newRecord)
} else {
log.Logger.Printf("Unable to parse IP: %s\n", newRecord)
} }
log.Logger.Printf("Creating DNS record for %s: %s\n", newRecord.Name, newRecord)
// Remove the domain from the DNSRecord name.
// This is an unfortunate inconsistency from the API
// implementation (returns full name, but only requires host)
if newRecord.Name == domain {
newRecord.Name = ""
} else {
newRecord.Name = strings.TrimSuffix(newRecord.Name, fmt.Sprintf(".%s", domain))
}
return a.CreateDNSRecord(domain, newRecord)
} }
func runConfig(c api.Config, daemon bool) { func runConfig(c api.Config, daemon bool) {

View file

@ -3,9 +3,9 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"git.darkcloud.ca/kevin/name-dyndns/api" "git.darkcloud.ca/kmacmart/name-dyndns/api"
"git.darkcloud.ca/kevin/name-dyndns/dyndns" "git.darkcloud.ca/kmacmart/name-dyndns/dyndns"
"git.darkcloud.ca/kevin/name-dyndns/log" "git.darkcloud.ca/kmacmart/name-dyndns/log"
"os" "os"
) )