delete works

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-07 11:23:51 -06:00
parent ef6eb7a96a
commit 937f77b355
3 changed files with 41 additions and 43 deletions

View File

@ -27,7 +27,7 @@ type errorBox struct {
type anError struct {
kind string // what kind of error is it?
ip string
aaaa string
status string
kindLabel *gui.Node
@ -62,20 +62,43 @@ func (eb *errorBox) add(kind string, ip string) bool {
anErr := new(anError)
anErr.kind = kind
anErr.aaaa = ip
anErr.kindLabel = eb.grid.NewLabel(kind)
anErr.ipLabel = eb.grid.NewLabel(ip)
anErr.statusLabel = eb.grid.NewLabel("")
anErr.button = eb.grid.NewButton(kind, func() {
log.Log(WARN, "got", kind, "here. IP =", ip)
eb.fix(kind, ip)
eb.fix(tmp)
})
eb.fixes[tmp] = anErr
return false
}
func (eb *errorBox) fix(name string, ip string) bool {
log.Log(WARN, "should try to fix", name, "here. IP =", ip)
func (eb *errorBox) fix(key string) bool {
if eb.fixes[key] == nil {
log.Log(WARN, "Unknown error. could not find key =", key)
log.Log(WARN, "TODO: probably remove this error. key =", key)
return true
}
myErr := eb.fixes[key]
log.Log(WARN, "should try to fix", myErr.kind, "here. IP =", myErr.aaaa)
if myErr.kind == "DELETE" {
if deleteFromDNS(myErr.aaaa) {
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Worked")
} else {
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Failed")
}
return true
}
if myErr.kind == "CREATE" {
if addToDNS(myErr.aaaa) {
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Worked")
} else {
log.Log(INFO, "Delete AAAA", myErr.aaaa, "Failed")
}
return true
}
return false
}

19
fix.go
View File

@ -8,8 +8,6 @@ import (
)
func fix() bool {
log.Log(CHANGE, "")
// make and toggle the fixWindow display
if me.fixWindow == nil {
me.fixWindow = smartwindow.New()
@ -120,16 +118,25 @@ func fixIPv6dns() bool {
}
func deleteFromDNS(aaaa string) bool {
log.Log(CHANGE, "deleteFromDNS", aaaa)
log.Log(CHANGE, "Delete this from DNS !!!!", aaaa)
api := me.statusDNS.API()
log.Log(CHANGE, "your API provider is =", api)
if api == "cloudflare" {
log.Log(CHANGE, "Let's try a DELETE via the Cloudflare API")
hostname := me.statusOS.GetHostname()
b, response := cloudflare.Delete("wit.com", hostname, aaaa)
log.Log(CHANGE, "response was:", response)
return b
}
return false
}
func addToDNS(aaaa string) bool {
log.Log(CHANGE, "TODO: Add this to DNS !!!!", aaaa)
log.Log(CHANGE, "Add this to DNS !!!!", aaaa)
api := me.statusDNS.API()
log.Log(CHANGE, "what is your API provider?", api)
log.Log(CHANGE, "your API provider is =", api)
if api == "cloudflare" {
log.Log(CHANGE, "Let's try an ADD via the Cloudflare API")
log.Log(CHANGE, "Let's try a CREATE via the Cloudflare API")
hostname := me.statusOS.GetHostname()
return cloudflare.Create("wit.com", hostname, aaaa)
}

34
gui.go
View File

@ -69,7 +69,7 @@ func mainWindow(title string) {
gr := me.window.Box().NewGroup("dns update")
// This is where you figure out what to do next to fix the problems
me.fixButton = gr.NewButton("fix", func () {
me.fixButton = gr.NewButton("Check Errors", func () {
if ! fix() {
log.Log(CHANGE, "boo. IPv6 isn't working yet")
return
@ -80,7 +80,6 @@ func mainWindow(title string) {
// me.hostname.Set(hostname)
me.hostnameStatus.Set("WORKING")
me.DnsStatus.Set("WORKING")
// me.fixButton.Disable()
})
statusGrid(me.window.Box())
@ -155,33 +154,6 @@ func updateDNS() {
me.digStatus.Update()
me.statusDNS.Update()
// log.Println("digAAAA()")
/*
if me.statusOS.ValidHostname() {
var aaaa []string
h := me.statusOS.GetHostname()
aaaa = digAAAA(h)
log.Log(INFO, "digAAAA() for", h, "=", aaaa)
// log.Println(SPEW, me)
if (aaaa == nil) {
log.Warn("There are no DNS AAAA records for hostname: ", h)
// me.DnsAAAA.Set("(none)")
if (cloudflare.CFdialog.TypeNode != nil) {
cloudflare.CFdialog.TypeNode.SetText("AAAA new")
}
if (cloudflare.CFdialog.NameNode != nil) {
cloudflare.CFdialog.NameNode.SetText(h)
}
}
}
*/
// status := displayDNS() // update the GUI based on dig results
// me.DnsStatus.SetText(status)
if me.digStatus.Ready() {
if me.digStatus.IPv6() {
me.statusIPv6.Set("IPv6 WORKING")
@ -190,10 +162,6 @@ func updateDNS() {
}
}
// me.fix.Enable()
// lookup the NS records for your domain
// if your host is test.wit.com, find the NS resource records for wit.com
lookupNS(me.statusOS.GetDomainName())