parent
ef6eb7a96a
commit
937f77b355
31
errorBox.go
31
errorBox.go
|
@ -27,7 +27,7 @@ type errorBox struct {
|
||||||
|
|
||||||
type anError struct {
|
type anError struct {
|
||||||
kind string // what kind of error is it?
|
kind string // what kind of error is it?
|
||||||
ip string
|
aaaa string
|
||||||
status string
|
status string
|
||||||
|
|
||||||
kindLabel *gui.Node
|
kindLabel *gui.Node
|
||||||
|
@ -62,20 +62,43 @@ func (eb *errorBox) add(kind string, ip string) bool {
|
||||||
|
|
||||||
anErr := new(anError)
|
anErr := new(anError)
|
||||||
anErr.kind = kind
|
anErr.kind = kind
|
||||||
|
anErr.aaaa = ip
|
||||||
|
|
||||||
anErr.kindLabel = eb.grid.NewLabel(kind)
|
anErr.kindLabel = eb.grid.NewLabel(kind)
|
||||||
anErr.ipLabel = eb.grid.NewLabel(ip)
|
anErr.ipLabel = eb.grid.NewLabel(ip)
|
||||||
anErr.statusLabel = eb.grid.NewLabel("")
|
anErr.statusLabel = eb.grid.NewLabel("")
|
||||||
anErr.button = eb.grid.NewButton(kind, func() {
|
anErr.button = eb.grid.NewButton(kind, func() {
|
||||||
log.Log(WARN, "got", kind, "here. IP =", ip)
|
log.Log(WARN, "got", kind, "here. IP =", ip)
|
||||||
eb.fix(kind, ip)
|
eb.fix(tmp)
|
||||||
})
|
})
|
||||||
eb.fixes[tmp] = anErr
|
eb.fixes[tmp] = anErr
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eb *errorBox) fix(name string, ip string) bool {
|
func (eb *errorBox) fix(key string) bool {
|
||||||
log.Log(WARN, "should try to fix", name, "here. IP =", ip)
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
fix.go
19
fix.go
|
@ -8,8 +8,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func fix() bool {
|
func fix() bool {
|
||||||
log.Log(CHANGE, "")
|
|
||||||
|
|
||||||
// make and toggle the fixWindow display
|
// make and toggle the fixWindow display
|
||||||
if me.fixWindow == nil {
|
if me.fixWindow == nil {
|
||||||
me.fixWindow = smartwindow.New()
|
me.fixWindow = smartwindow.New()
|
||||||
|
@ -120,16 +118,25 @@ func fixIPv6dns() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteFromDNS(aaaa string) 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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func addToDNS(aaaa string) bool {
|
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()
|
api := me.statusDNS.API()
|
||||||
log.Log(CHANGE, "what is your API provider?", api)
|
log.Log(CHANGE, "your API provider is =", api)
|
||||||
if api == "cloudflare" {
|
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()
|
hostname := me.statusOS.GetHostname()
|
||||||
return cloudflare.Create("wit.com", hostname, aaaa)
|
return cloudflare.Create("wit.com", hostname, aaaa)
|
||||||
}
|
}
|
||||||
|
|
34
gui.go
34
gui.go
|
@ -69,7 +69,7 @@ func mainWindow(title string) {
|
||||||
gr := me.window.Box().NewGroup("dns update")
|
gr := me.window.Box().NewGroup("dns update")
|
||||||
|
|
||||||
// This is where you figure out what to do next to fix the problems
|
// 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() {
|
if ! fix() {
|
||||||
log.Log(CHANGE, "boo. IPv6 isn't working yet")
|
log.Log(CHANGE, "boo. IPv6 isn't working yet")
|
||||||
return
|
return
|
||||||
|
@ -80,7 +80,6 @@ func mainWindow(title string) {
|
||||||
// me.hostname.Set(hostname)
|
// me.hostname.Set(hostname)
|
||||||
me.hostnameStatus.Set("WORKING")
|
me.hostnameStatus.Set("WORKING")
|
||||||
me.DnsStatus.Set("WORKING")
|
me.DnsStatus.Set("WORKING")
|
||||||
// me.fixButton.Disable()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
statusGrid(me.window.Box())
|
statusGrid(me.window.Box())
|
||||||
|
@ -155,33 +154,6 @@ func updateDNS() {
|
||||||
me.digStatus.Update()
|
me.digStatus.Update()
|
||||||
me.statusDNS.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.Ready() {
|
||||||
if me.digStatus.IPv6() {
|
if me.digStatus.IPv6() {
|
||||||
me.statusIPv6.Set("IPv6 WORKING")
|
me.statusIPv6.Set("IPv6 WORKING")
|
||||||
|
@ -190,10 +162,6 @@ func updateDNS() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// me.fix.Enable()
|
|
||||||
|
|
||||||
|
|
||||||
// lookup the NS records for your domain
|
// lookup the NS records for your domain
|
||||||
// if your host is test.wit.com, find the NS resource records for wit.com
|
// if your host is test.wit.com, find the NS resource records for wit.com
|
||||||
lookupNS(me.statusOS.GetDomainName())
|
lookupNS(me.statusOS.GetDomainName())
|
||||||
|
|
Loading…
Reference in New Issue