logic for comparing OS and DNS IPv6 addresses
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
837a8a4be4
commit
74bfddc1e4
|
@ -321,10 +321,55 @@ func (hs *hostnameStatus) updateStatus() {
|
|||
} else {
|
||||
hs.status.Set("BROKEN")
|
||||
}
|
||||
|
||||
if hs.verifyIPv6() {
|
||||
hs.statusIPv6.Set("WORKING")
|
||||
} else {
|
||||
hs.statusIPv6.Set("BROKEN")
|
||||
}
|
||||
}
|
||||
|
||||
// lookup the DNS provider
|
||||
// hs.dnsAPI.Set(me.DnsAPI.S)
|
||||
lookupNSprovider("wit.com")
|
||||
func (hs *hostnameStatus) verifyIPv6() bool {
|
||||
var working bool = true
|
||||
osAAAA := make(map[string]string)
|
||||
dnsAAAA := make(map[string]string)
|
||||
|
||||
log.Log(INFO, "What are the AAAA resource records in the OS?")
|
||||
tmp := me.statusOS.GetIPv6()
|
||||
if len(tmp) == 0 {
|
||||
// you don't have any IPv6 addresses in your OS right now
|
||||
return false
|
||||
}
|
||||
for _, aaaa := range me.statusOS.GetIPv6() {
|
||||
log.Log(INFO, "FOUND OS AAAA ip", aaaa)
|
||||
osAAAA[aaaa] = "os"
|
||||
}
|
||||
|
||||
log.Log(INFO, "What are the AAAA resource records in DNS?")
|
||||
for _, aaaa := range me.statusDNS.GetIPv6() {
|
||||
log.Log(INFO, "FOUND DNS AAAA ip", aaaa)
|
||||
dnsAAAA[aaaa] = "dns"
|
||||
}
|
||||
|
||||
for aaaa, _ := range dnsAAAA {
|
||||
if osAAAA[aaaa] == "os" {
|
||||
log.Log(INFO, "DNS AAAA is in OS", aaaa)
|
||||
} else {
|
||||
working = false
|
||||
log.Log(INFO, "DNS AAAA is not in OS", aaaa)
|
||||
}
|
||||
}
|
||||
|
||||
for aaaa, _ := range osAAAA {
|
||||
if dnsAAAA[aaaa] == "dns" {
|
||||
log.Log(INFO, "OS AAAA is in DNS", aaaa)
|
||||
} else {
|
||||
working = false
|
||||
log.Log(INFO, "OS AAAA is not in DNS", aaaa)
|
||||
}
|
||||
}
|
||||
|
||||
return working
|
||||
}
|
||||
|
||||
func (hs *hostnameStatus) Show() {
|
||||
|
|
6
main.go
6
main.go
|
@ -88,7 +88,7 @@ func main() {
|
|||
|
||||
lastProvider := "unknown"
|
||||
go myTicker(10 * time.Second, "DNSloop", func() {
|
||||
log.Log(CHANGE, "me.statusDNS.Update() START")
|
||||
log.Log(INFO, "me.statusDNS.Update() START")
|
||||
me.statusDNS.Update()
|
||||
|
||||
provider := me.statusDNS.GetDNSapi()
|
||||
|
@ -127,7 +127,7 @@ func main() {
|
|||
})
|
||||
|
||||
// check the four known things to see if they are all WORKING
|
||||
myTicker(3 * time.Second, "MAIN LOOP", func() {
|
||||
myTicker(10 * time.Second, "MAIN LOOP", func() {
|
||||
if me.hostnameStatus.GetText() != "WORKING" {
|
||||
log.Log(CHANGE, "The hostname is not WORKING yet", me.hostnameStatus.GetText())
|
||||
return
|
||||
|
@ -144,7 +144,7 @@ func main() {
|
|||
log.Log(CHANGE, "The DNS API provider is not yet working", me.DnsAPIstatus.GetText())
|
||||
return
|
||||
}
|
||||
log.Log(CHANGE, "EVERYTHING IS WORKING. YOU HAVE IPv6 BLISS")
|
||||
log.Log(CHANGE, "EVERYTHING IS WORKING. YOU HAVE IPv6 BLISS. TODO: don't check so often now")
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue