Compare commits
2 commits
7a54e0b4e0
...
ed4428e846
Author | SHA1 | Date | |
---|---|---|---|
|
ed4428e846 | ||
|
720bb3707f |
2 changed files with 26 additions and 19 deletions
|
@ -7,9 +7,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"net"
|
||||||
|
|
||||||
"git.darkcloud.ca/kmacmart/name-dyndns/api"
|
"git.darkcloud.ca/kevin/name-dyndns/api"
|
||||||
"git.darkcloud.ca/kmacmart/name-dyndns/log"
|
"git.darkcloud.ca/kevin/name-dyndns/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
@ -28,6 +29,9 @@ 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)
|
||||||
|
|
||||||
|
if addr != nil {
|
||||||
log.Logger.Printf("Deleting DNS record for %s.\n", newRecord.Name)
|
log.Logger.Printf("Deleting DNS record for %s.\n", newRecord.Name)
|
||||||
err := a.DeleteDNSRecord(domain, newRecord.RecordID)
|
err := a.DeleteDNSRecord(domain, newRecord.RecordID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -46,6 +50,9 @@ func updateDNSRecord(a api.API, domain, recordID string, newRecord api.DNSRecord
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.CreateDNSRecord(domain, newRecord)
|
return a.CreateDNSRecord(domain, newRecord)
|
||||||
|
} else {
|
||||||
|
log.Logger.Printf("Unable to parse IP: %s\n", newRecord)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runConfig(c api.Config, daemon bool) {
|
func runConfig(c api.Config, daemon bool) {
|
||||||
|
|
6
main.go
6
main.go
|
@ -3,9 +3,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.darkcloud.ca/kmacmart/name-dyndns/api"
|
"git.darkcloud.ca/kevin/name-dyndns/api"
|
||||||
"git.darkcloud.ca/kmacmart/name-dyndns/dyndns"
|
"git.darkcloud.ca/kevin/name-dyndns/dyndns"
|
||||||
"git.darkcloud.ca/kmacmart/name-dyndns/log"
|
"git.darkcloud.ca/kevin/name-dyndns/log"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue