summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-07 11:23:51 -0600
committerJeff Carr <[email protected]>2024-01-07 11:23:51 -0600
commit937f77b3558702a2e0ff76fbb1a8ef91242302c8 (patch)
treeb87f038e9605ea345faaf5cde6fc73ca0c3f4e29
parentef6eb7a96aa4aee7c16ba5e7320bde4ffd79acc0 (diff)
delete works
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--errorBox.go31
-rw-r--r--fix.go19
-rw-r--r--gui.go34
3 files changed, 41 insertions, 43 deletions
diff --git a/errorBox.go b/errorBox.go
index 0353393..638e84c 100644
--- a/errorBox.go
+++ b/errorBox.go
@@ -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
}
diff --git a/fix.go b/fix.go
index 599a6d8..1231f61 100644
--- a/fix.go
+++ b/fix.go
@@ -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)
}
diff --git a/gui.go b/gui.go
index 4746f20..dd93c5c 100644
--- a/gui.go
+++ b/gui.go
@@ -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())