knows which AAAA records are broken!

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-06 19:58:58 -06:00
parent 53fbb4cb85
commit cefe15539f
8 changed files with 90 additions and 68 deletions

66
args.go
View File

@ -22,62 +22,32 @@ var NOW log.LogFlag
var INFO log.LogFlag var INFO log.LogFlag
var NET log.LogFlag var NET log.LogFlag
var DNS log.LogFlag var DNS log.LogFlag
var PROC log.LogFlag var WARN log.LogFlag
var SPEW log.LogFlag var SPEW log.LogFlag
var CHANGE log.LogFlag var CHANGE log.LogFlag
var STATUS log.LogFlag var STATUS log.LogFlag
func myreg(f *log.LogFlag, b bool, name string, desc string) {
f.B = b
f.Subsystem = "go.wit.com/control-panels/dns"
f.Short = "cpdns"
f.Desc = desc
f.Name = name
f.Register()
}
func init() { func init() {
arg.MustParse(&args) arg.MustParse(&args)
// fmt.Println(args.Foo, args.Bar, args.User) // fmt.Println(args.Foo, args.Bar, args.User)
NOW.B = false myreg(&NOW, true, "NOW", "temp debugging stuff")
NOW.Name = "NOW" myreg(&INFO, false, "INFO", "normal debugging stuff")
NOW.Subsystem = "cpdns" myreg(&NET, false, "NET", "Network logging")
NOW.Desc = "temp debugging stuff" myreg(&DNS, false, "DNS", "dnsStatus.update()")
NOW.Register() myreg(&WARN, true, "WARN", "bad things")
myreg(&SPEW, false, "SPEW", "spew stuff")
INFO.B = false myreg(&CHANGE, true, "CHANGE", "when host or dns change")
INFO.Name = "INFO" myreg(&STATUS, false, "STATUS", "updateStatus()")
INFO.Subsystem = "cpdns"
INFO.Desc = "normal debugging stuff"
INFO.Register()
NET.B = false
NET.Name = "NET"
NET.Subsystem = "cpdns"
NET.Desc = "Network logging"
NET.Register()
DNS.B = false
DNS.Name = "DNS"
DNS.Subsystem = "cpdns"
DNS.Desc = "dnsStatus.update()"
DNS.Register()
PROC.B = false
PROC.Name = "PROC"
PROC.Subsystem = "cpdns"
PROC.Desc = "/proc logging"
PROC.Register()
SPEW.B = false
SPEW.Name = "SPEW"
SPEW.Subsystem = "cpdns"
SPEW.Desc = "spew logging"
SPEW.Register()
CHANGE.B = true
CHANGE.Name = "CHANGE"
CHANGE.Subsystem = "cpdns"
CHANGE.Desc = "show droplet state changes"
CHANGE.Register()
STATUS.B = false
STATUS.Name = "STATUS"
STATUS.Subsystem = "cpdns"
STATUS.Desc = "updateStatus()"
STATUS.Register()
if debugger.ArgDebug() { if debugger.ArgDebug() {
log.Log(true, "INIT() gui debug == true") log.Log(true, "INIT() gui debug == true")

4
dns.go
View File

@ -113,10 +113,10 @@ func lookupNS(domain string) {
} }
tmp = shell.Chomp(tmp) tmp = shell.Chomp(tmp)
if (tmp != me.status.NSrr.Get()) { if (tmp != me.statusDNS.NSrr.Get()) {
me.changed = true me.changed = true
log.Log(CHANGE, "lookupNS() setting changed to me.NSrr =", tmp) log.Log(CHANGE, "lookupNS() setting changed to me.NSrr =", tmp)
me.status.NSrr.Set(tmp) me.statusDNS.NSrr.Set(tmp)
} }
} }

65
fix.go
View File

@ -7,7 +7,7 @@ import (
func fix() bool { func fix() bool {
log.Warn("") log.Warn("")
if ! me.status.Ready() { if ! me.statusDNS.Ready() {
log.Warn("The IPv6 Control Panel is not Ready() yet") log.Warn("The IPv6 Control Panel is not Ready() yet")
return false return false
} }
@ -30,10 +30,10 @@ func fix() bool {
log.Warn("You must first figure out why you can't look up IPv6 addresses") log.Warn("You must first figure out why you can't look up IPv6 addresses")
return false return false
} }
if ! me.status.IPv4() { if ! me.statusDNS.IPv4() {
log.Warn("You do not have real IPv4 addresses. Nothing to fix here") log.Warn("You do not have real IPv4 addresses. Nothing to fix here")
} }
if ! me.status.IPv6() { if ! me.statusDNS.IPv6() {
log.Warn("IPv6 DNS is broken. Check what is broken here") log.Warn("IPv6 DNS is broken. Check what is broken here")
fixIPv6dns() fixIPv6dns()
return false return false
@ -44,12 +44,63 @@ func fix() bool {
func fixIPv6dns() { func fixIPv6dns() {
log.Warn("What are my IPv6 addresses?") log.Warn("What are my IPv6 addresses?")
for _, aaaa := range me.statusOS.GetIPv6os() { osAAAA := make(map[string]string)
log.Warn("FOUND AAAA ip", aaaa) dnsAAAA := make(map[string]string)
for _, aaaa := range me.statusOS.GetIPv6() {
log.Warn("FOUND OS AAAA ip", aaaa)
osAAAA[aaaa] = "os"
} }
log.Warn("What are the AAAA resource records in DNS?") log.Warn("What are the AAAA resource records in DNS?")
for _, aaaa := range me.status.GetIPv6dns() { for _, aaaa := range me.statusDNS.GetIPv6() {
log.Warn("FOUND AAAA ip", aaaa) log.Warn("FOUND DNS AAAA ip", aaaa)
dnsAAAA[aaaa] = "dns"
}
// remove old DNS entries first
for aaaa, _ := range dnsAAAA {
if osAAAA[aaaa] == "dns" {
log.Warn("DNS AAAA is not in OS", aaaa)
if deleteFromDNS(aaaa) {
log.Warn("Delete AAAA", aaaa, "Worked")
} else {
log.Warn("Delete AAAA", aaaa, "Failed")
}
} else {
log.Warn("DNS AAAA is in OS", aaaa)
}
}
// now add new DNS entries
for aaaa, _ := range osAAAA {
if dnsAAAA[aaaa] == "dns" {
log.Warn("OS AAAA is in DNS", aaaa)
} else {
log.Warn("OS AAAA is not in DNS", aaaa)
if addToDNS(aaaa) {
log.Warn("Add AAAA", aaaa, "Worked")
} else {
log.Warn("Add AAAA", aaaa, "Failed")
}
}
} }
} }
func deleteFromDNS(aaaa string) bool {
log.Warn("deleteFromDNS", aaaa)
return false
}
func addToDNS(aaaa string) bool {
log.Warn("TODO: Add this to DNS !!!!", aaaa)
log.Warn("what is your API provider?")
return false
}
func exists(m map[string]bool, s string) bool {
if _, ok := m[s]; ok {
return true
}
return false
}

6
gui.go
View File

@ -162,8 +162,8 @@ func mainWindow(title string) {
gr = me.window.Box().NewGroup("debugging") gr = me.window.Box().NewGroup("debugging")
gr.NewButton("hostname status", func () { gr.NewButton("hostname status", func () {
if ! me.status.Ready() {return} if ! me.statusDNS.Ready() {return}
me.status.window.Toggle() me.statusDNS.window.Toggle()
}) })
gr.NewButton("linuxstatus.New()", func () { gr.NewButton("linuxstatus.New()", func () {
@ -245,7 +245,7 @@ func statusGrid(n *gui.Node) {
// run everything because something has changed // run everything because something has changed
func updateDNS() { func updateDNS() {
me.digStatus.Update() me.digStatus.Update()
me.status.Update() me.statusDNS.Update()
// log.Println("digAAAA()") // log.Println("digAAAA()")

View File

@ -40,6 +40,7 @@ type hostnameStatus struct {
// what the current IP address your network has given you // what the current IP address your network has given you
currentIPv4 *gadgets.OneLiner currentIPv4 *gadgets.OneLiner
currentIPv6 *gadgets.OneLiner currentIPv6 *gadgets.OneLiner
currentAAAA string
// what the DNS servers have // what the DNS servers have
NSrr *gadgets.OneLiner NSrr *gadgets.OneLiner
@ -279,9 +280,9 @@ func (hs *hostnameStatus) missingAAAA() bool {
} }
*/ */
func (hs *hostnameStatus) GetIPv6dns() []string { func (hs *hostnameStatus) GetIPv6() []string {
tmp := hs.dnsAAAA.Get() if ! hs.Ready() { return nil}
return strings.Split(tmp, "\n") return strings.Split(hs.currentAAAA, "\n")
} }
func (hs *hostnameStatus) updateStatus() { func (hs *hostnameStatus) updateStatus() {
@ -314,7 +315,7 @@ func (hs *hostnameStatus) updateStatus() {
// hs.dnsAction.SetText("DELETE") // hs.dnsAction.SetText("DELETE")
} }
} }
hs.set(hs.dnsAAAA, s) hs.currentAAAA = strings.Join(vals, "\n")
vals = lookupDoH(me.statusOS.GetHostname(), "A") vals = lookupDoH(me.statusOS.GetHostname(), "A")
log.Log(STATUS, "IPv4 Addresses for ", me.statusOS.GetHostname(), "=", vals) log.Log(STATUS, "IPv4 Addresses for ", me.statusOS.GetHostname(), "=", vals)

View File

@ -65,7 +65,8 @@ func (ls *LinuxStatus) setHostShort() {
} }
} }
func (ls *LinuxStatus) GetIPv6os() []string { func (ls *LinuxStatus) GetIPv6() []string {
if ! me.Ready() {return nil}
tmp := me.workingIPv6.Get() tmp := me.workingIPv6.Get()
return strings.Split(tmp, "\n") return strings.Split(tmp, "\n")
} }

View File

@ -46,7 +46,7 @@ func main() {
setupControlPanelWindow() setupControlPanelWindow()
me.digStatus = NewDigStatusWindow(me.myGui) me.digStatus = NewDigStatusWindow(me.myGui)
me.status = NewHostnameStatusWindow(me.myGui) me.statusDNS = NewHostnameStatusWindow(me.myGui)
linuxstatus.New() linuxstatus.New()

View File

@ -20,7 +20,7 @@ type Host struct {
window *gadgets.BasicWindow // the main window window *gadgets.BasicWindow // the main window
debug *gadgets.BasicWindow // the debug window debug *gadgets.BasicWindow // the debug window
status *hostnameStatus // keeps track of the hostname and it's status statusDNS *hostnameStatus // keeps track of the hostname and it's status
statusOS *linuxstatus.LinuxStatus // what the Linux OS sees statusOS *linuxstatus.LinuxStatus // what the Linux OS sees
digStatus *digStatus // window of the results of DNS lookups digStatus *digStatus // window of the results of DNS lookups
@ -46,7 +46,6 @@ type Host struct {
ipv4s map[string]dns.RR ipv4s map[string]dns.RR
ipv6s map[string]dns.RR ipv6s map[string]dns.RR
// DNS stuff // DNS stuff
DnsAPI *gui.Node // what DNS API to use? DnsAPI *gui.Node // what DNS API to use?
DnsAAAA *gadgets.OneLiner // the actual DNS AAAA results DnsAAAA *gadgets.OneLiner // the actual DNS AAAA results