errors are always displayed
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
e14bd65844
commit
b1c311a1e2
5
Makefile
5
Makefile
|
@ -4,6 +4,11 @@ run: build
|
|||
# ./control-panel-dns >/tmp/witgui.log.stderr 2>&1
|
||||
./control-panel-dns
|
||||
|
||||
redomod:
|
||||
rm -f go.*
|
||||
go mod init
|
||||
go mod tidy
|
||||
|
||||
install:
|
||||
go install -v go.wit.com/control-panel-dns@latest
|
||||
# go install -v go.wit.com/control-panel-dns@latest
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type errorBox struct {
|
||||
name string // the problem name
|
||||
ready bool
|
||||
|
||||
parent *gui.Node
|
||||
group *gui.Node
|
||||
|
@ -49,11 +49,17 @@ func NewErrorBox(p *gui.Node, name string, ip string) *errorBox {
|
|||
eb.grid.NewLabel("")
|
||||
|
||||
eb.fixes = make(map[string]*anError)
|
||||
eb.ready = true
|
||||
return eb
|
||||
}
|
||||
|
||||
func (eb *errorBox) Ready() bool {
|
||||
if eb == nil {return false}
|
||||
return eb.ready
|
||||
}
|
||||
|
||||
func (eb *errorBox) add(kind string, ip string) bool {
|
||||
if ! eb.Ready() {return false}
|
||||
tmp := kind + " " + ip
|
||||
if eb.fixes[tmp] != nil {
|
||||
log.Log(WARN, "Error is already here", kind, ip)
|
||||
|
|
13
fix.go
13
fix.go
|
@ -150,19 +150,10 @@ func exists(m map[string]bool, s string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
var myErrorBox *errorBox
|
||||
|
||||
func addToFixWindow(t string, ip string) {
|
||||
log.Log(INFO, "addToFixWindow() START")
|
||||
if me.fixWindow == nil {
|
||||
log.Log(WARN, "addToFixWindow() fixWindow == nil. Can't add the error", t, ip)
|
||||
return
|
||||
}
|
||||
if myErrorBox == nil {
|
||||
box := me.fixWindow.Box()
|
||||
myErrorBox = NewErrorBox(box, t, ip)
|
||||
}
|
||||
myErrorBox.add(t, ip)
|
||||
if ! me.problems.Ready() { return }
|
||||
me.problems.add(t, ip)
|
||||
log.Log(INFO, "addToFixWindow() END")
|
||||
}
|
||||
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,3 +1,3 @@
|
|||
module go.wit.com/control-panels/dns
|
||||
module go.wit.com/apps/control-panel-dns
|
||||
|
||||
go 1.21.4
|
||||
|
|
43
gui.go
43
gui.go
|
@ -81,41 +81,15 @@ func myDefaultExit(n *gui.Node) {
|
|||
|
||||
func mainWindow(title string) {
|
||||
me.window = gadgets.NewBasicWindow(me.myGui, title)
|
||||
me.window.Vertical()
|
||||
|
||||
gr := me.window.Box().NewGroup("dns update")
|
||||
hbox := me.window.Box().NewBox("bw hbox", true)
|
||||
|
||||
// This is where you figure out what to do next to fix the problems
|
||||
me.fixButton = gr.NewButton("Check Errors", func () {
|
||||
if ! fix() {
|
||||
log.Log(CHANGE, "boo. IPv6 isn't working yet")
|
||||
return
|
||||
}
|
||||
log.Log(CHANGE, "IPv6 WORKED")
|
||||
// update everything here visually for the user
|
||||
// hostname := me.statusOS.GetHostname()
|
||||
// me.hostname.Set(hostname)
|
||||
me.hostnameStatus.Set("WORKING")
|
||||
me.DnsStatus.Set("WORKING")
|
||||
me.fixButton.SetText("No Errors!")
|
||||
me.fixButton.Disable()
|
||||
})
|
||||
statusGrid(hbox)
|
||||
|
||||
statusGrid(me.window.Box())
|
||||
// some artificial padding to make the last row of buttons look less wierd
|
||||
gr := hbox.NewGroup("Development and Debugging Windows")
|
||||
|
||||
gr = me.window.Box().NewGroup("")
|
||||
/*
|
||||
me.statusDNSbutton = gr.NewButton("hostname status", func () {
|
||||
if ! me.statusDNS.Ready() {return}
|
||||
me.statusDNS.window.Toggle()
|
||||
})
|
||||
gr.NewButton("Linux Status", func () {
|
||||
me.statusOS.Toggle()
|
||||
})
|
||||
gr.NewButton("resolver status", func () {
|
||||
if ! me.digStatus.Ready() {return}
|
||||
me.digStatus.window.Toggle()
|
||||
})
|
||||
*/
|
||||
gr.NewButton("Debug", func () {
|
||||
me.debug.Toggle()
|
||||
})
|
||||
|
@ -143,6 +117,10 @@ func mainWindow(title string) {
|
|||
}
|
||||
me.fixWindow.Toggle()
|
||||
})
|
||||
|
||||
// These are your problems
|
||||
me.problems = NewErrorBox(me.window.Box(), "Errors", "has problems?")
|
||||
me.problems.add("SOMETHING", "1:1:1:1:3")
|
||||
}
|
||||
|
||||
|
||||
|
@ -188,7 +166,4 @@ func statusGrid(n *gui.Node) {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
n.NewGroup("NOTES")
|
||||
|
||||
}
|
||||
|
|
|
@ -224,27 +224,6 @@ func (hs *hostnameStatus) existsAAAA(s string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
/*
|
||||
// figure out if I'm missing any IPv6 address in DNS
|
||||
func (hs *hostnameStatus) missingAAAA() bool {
|
||||
var aaaa []string
|
||||
aaaa = dhcpAAAA()
|
||||
for _, s := range aaaa {
|
||||
log.Log(NET, "my actual AAAA = ",s)
|
||||
if hs.existsAAAA(s) {
|
||||
log.Log(NOW, "my actual AAAA already exists in DNS =",s)
|
||||
} else {
|
||||
log.Log(NOW, "my actual AAAA is missing from DNS",s)
|
||||
hs.dnsValue.SetText(s)
|
||||
hs.dnsAction.SetText("CREATE")
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
*/
|
||||
|
||||
func (hs *hostnameStatus) GetIPv6() []string {
|
||||
if ! hs.Ready() { return nil}
|
||||
return strings.Split(hs.dnsAAAA.Get(), "\n")
|
||||
|
@ -322,10 +301,21 @@ func (hs *hostnameStatus) updateStatus() {
|
|||
hs.status.Set("BROKEN")
|
||||
}
|
||||
|
||||
last := hs.statusIPv6.Get()
|
||||
if hs.verifyIPv6() {
|
||||
hs.statusIPv6.Set("WORKING")
|
||||
if last != "WORKING" {
|
||||
log.Log(CHANGE, "Your DNS IPv6 has started working.", me.statusOS.GetHostname(), "should now work")
|
||||
hs.changed = true
|
||||
hs.statusIPv6.Set("WORKING")
|
||||
me.DnsStatus.SetText("WORKING")
|
||||
}
|
||||
} else {
|
||||
hs.statusIPv6.Set("BROKEN")
|
||||
if last != "BROKEN" {
|
||||
log.Log(CHANGE, "Your DNS entries for IPv6 have BROKEN")
|
||||
hs.changed = true
|
||||
hs.statusIPv6.Set("BROKEN")
|
||||
me.DnsStatus.SetText("BROKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,6 +347,7 @@ func (hs *hostnameStatus) verifyIPv6() bool {
|
|||
} else {
|
||||
working = false
|
||||
log.Log(INFO, "DNS AAAA is not in OS", aaaa)
|
||||
addToFixWindow("DELETE", aaaa)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -366,6 +357,7 @@ func (hs *hostnameStatus) verifyIPv6() bool {
|
|||
} else {
|
||||
working = false
|
||||
log.Log(INFO, "OS AAAA is not in DNS", aaaa)
|
||||
addToFixWindow("CREATE", aaaa)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
Show your IPv6 addresses
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
"go.wit.com/gui/gadgets"
|
||||
)
|
||||
|
||||
type ipv6box struct {
|
||||
name string // the problem name
|
||||
|
||||
parent *gui.Node
|
||||
group *gui.Node
|
||||
grid *gui.Node
|
||||
|
||||
l *gui.Node
|
||||
b *gui.Node
|
||||
|
||||
fixes map[string]*anError
|
||||
|
||||
something *gadgets.OneLiner
|
||||
}
|
||||
|
||||
type anIPv6 struct {
|
||||
kind string // what kind of error is it?
|
||||
aaaa string
|
||||
status string
|
||||
|
||||
kindLabel *gui.Node
|
||||
ipLabel *gui.Node
|
||||
statusLabel *gui.Node
|
||||
button *gui.Node
|
||||
}
|
||||
|
||||
func NewIpv6box(p *gui.Node, name string, ip string) *ipv6box {
|
||||
var ib *ipv6box
|
||||
ib = new(ipv6box)
|
||||
ib.parent = p
|
||||
ib.group = p.NewGroup(name)
|
||||
ib.grid = ib.group.NewGrid("stuff", 4, 1)
|
||||
|
||||
ib.grid.NewLabel("Type")
|
||||
ib.grid.NewLabel("IP")
|
||||
ib.grid.NewLabel("Status")
|
||||
ib.grid.NewLabel("")
|
||||
|
||||
ib.fixes = make(map[string]*anError)
|
||||
return ib
|
||||
}
|
||||
|
||||
|
||||
func (ib *ipv6box) add(kind string, ip string) bool {
|
||||
tmp := kind + " " + ip
|
||||
if ib.fixes[tmp] != nil {
|
||||
log.Log(WARN, "Error is already here", kind, ip)
|
||||
return false
|
||||
}
|
||||
|
||||
anErr := new(anError)
|
||||
anErr.kind = kind
|
||||
anErr.aaaa = ip
|
||||
|
||||
anErr.kindLabel = ib.grid.NewLabel(kind)
|
||||
anErr.ipLabel = ib.grid.NewLabel(ip)
|
||||
anErr.statusLabel = ib.grid.NewLabel("")
|
||||
anErr.button = ib.grid.NewButton(kind, func() {
|
||||
log.Log(WARN, "got", kind, "here. IP =", ip)
|
||||
ib.fix(tmp)
|
||||
})
|
||||
ib.fixes[tmp] = anErr
|
||||
return false
|
||||
}
|
||||
|
||||
func (ib *ipv6box) fix(key string) bool {
|
||||
if ib.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 := ib.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
|
||||
}
|
||||
|
||||
func (ib *ipv6box) update() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ib *ipv6box) toggle() {
|
||||
}
|
15
main.go
15
main.go
|
@ -128,23 +128,28 @@ func main() {
|
|||
|
||||
// check the four known things to see if they are all WORKING
|
||||
myTicker(10 * time.Second, "MAIN LOOP", func() {
|
||||
var working bool = true
|
||||
if me.hostnameStatus.GetText() != "WORKING" {
|
||||
log.Log(CHANGE, "The hostname is not WORKING yet", me.hostnameStatus.GetText())
|
||||
return
|
||||
working = false
|
||||
}
|
||||
if me.statusIPv6.Get() != "WORKING" {
|
||||
log.Log(CHANGE, "IPv6 DNS lookup has not been confirmed yet", me.statusIPv6.Get())
|
||||
return
|
||||
working = false
|
||||
}
|
||||
if me.DnsStatus.GetText() != "WORKING" {
|
||||
log.Log(CHANGE, "Your IPv6 DNS settings have not been confirmed yet", me.DnsStatus.GetText())
|
||||
return
|
||||
working = false
|
||||
}
|
||||
if me.DnsAPIstatus.GetText() != "WORKING" {
|
||||
log.Log(CHANGE, "The DNS API provider is not yet working", me.DnsAPIstatus.GetText())
|
||||
return
|
||||
working = false
|
||||
}
|
||||
if working {
|
||||
log.Log(CHANGE, "EVERYTHING IS WORKING. YOU HAVE IPv6 BLISS. TODO: don't check so often now")
|
||||
} else {
|
||||
log.Log(CHANGE, "EVERYTHING IS NOT WORKING. Probably run fix() here?")
|
||||
}
|
||||
log.Log(CHANGE, "EVERYTHING IS WORKING. YOU HAVE IPv6 BLISS. TODO: don't check so often now")
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,9 @@ type Host struct {
|
|||
witcom *gadgets.BasicWindow
|
||||
fixButton *gui.Node
|
||||
fixWindow *smartwindow.SmartWindow
|
||||
|
||||
errorGroup *gui.Node // Hide() and Show() this node if there are no errors
|
||||
problems *errorBox
|
||||
}
|
||||
|
||||
type IPtype struct {
|
||||
|
|
Loading…
Reference in New Issue