works within 30 seconds

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-01 08:49:16 -06:00
parent 78927ede5d
commit a26018c86d
5 changed files with 78 additions and 89 deletions

View File

@ -336,3 +336,22 @@ func (ds *digStatus) Hide() {
}
me.digStatus.hidden = true
}
func digLoop() {
me.digStatus.Update()
if me.digStatus.Ready() {
current := me.statusIPv6.String()
if me.digStatus.IPv6() {
if current != "WORKING" {
log.Log(CHANGE, "IPv6 resolution is WORKING")
me.statusIPv6.SetText("WORKING")
}
} else {
if current != "Need VPN" {
log.Log(CHANGE, "IPv6 resolution seems to have broken")
me.statusIPv6.SetText("Need VPN")
}
}
}
}

118
gui.go
View File

@ -15,63 +15,65 @@ import (
)
// This setups up the dns control panel window
func setupControlPanelWindow() {
func setupControlPanelWindow(title string) {
log.Info("artificial sleep of:", me.artificialSleep)
log.Sleep(me.artificialSleep)
// setup the main tab
mainWindow("DNS and IPv6 Control Panel")
debugTab("Debug")
me.window.Show()
me.window = gadgets.NewBasicWindow(me.myGui, title)
me.window.Vertical()
me.window.Make()
makeMainWindow()
// These are your problems
me.problems = NewErrorBox(me.window.Box(), "Errors", "has problems?")
me.problems.addIPerror(RR, USER, "1:1:1:1")
me.window.Draw()
}
func debugTab(title string) {
var g2 *gui.Node
// var g2 *gui.Node
me.debug = gadgets.NewBasicWindow(me.myGui, title)
me.debug.Make()
// me.debug.Draw()
g2 = me.debug.Box().NewGroup("Real Stuff")
group := me.debug.Box().NewGroup("Real Stuff")
g2.NewButton("GO GUI Debug Window", func() {
group.NewButton("GO GUI Debug Window", func() {
debugger.DebugWindow()
})
g2.NewButton("dig A & AAAA DNS records (updateDNS())", func() {
group.NewButton("dig A & AAAA DNS records (updateDNS())", func() {
log.Log(CHANGE, "updateDNS() going to run:")
})
g2 = me.debug.Box().NewGroup("debugging options")
gridP := g2.NewGrid("nuts", 2, 1)
group = me.debug.Box().NewGroup("debugging options")
grid := group.NewGrid("nuts", 2, 1)
// makes a slider widget
me.ttl = gadgets.NewDurationSlider(gridP, "Loop Timeout", 10*time.Millisecond, 5*time.Second)
me.ttl = gadgets.NewDurationSlider(grid, "Loop Timeout", 10*time.Millisecond, 5*time.Second)
me.ttl.Set(300 * time.Millisecond)
// makes a slider widget
me.dnsTtl = gadgets.NewDurationSlider(gridP, "DNS Timeout", 800*time.Millisecond, 300*time.Second)
me.dnsTtl = gadgets.NewDurationSlider(grid, "DNS Timeout", 800*time.Millisecond, 300*time.Second)
me.dnsTtl.Set(60 * time.Second)
gridP.NewLabel("dns resolution")
me.DnsSpeed = gridP.NewLabel("unknown")
grid.NewLabel("dns resolution")
me.DnsSpeed = grid.NewLabel("unknown")
gridP.NewLabel("dns resolution speed")
me.DnsSpeedActual = gridP.NewLabel("unknown")
grid.NewLabel("dns resolution speed")
me.DnsSpeedActual = grid.NewLabel("unknown")
gridP.NewLabel("Test speed")
newGrid := gridP.NewGrid("nuts", 2, 1).Pad()
g2.Margin()
g2.Pad()
grid.NewLabel("Test speed")
newGrid := grid.NewGrid("nuts", 2, 1).Pad()
newGrid.NewLabel("ping.wit.com =")
newGrid.NewLabel("unknown")
newGrid.NewLabel("ping6.wit.com =")
newGrid.NewLabel("unknown")
me.debug.Hide()
}
func myDefaultExit(n *gui.Node) {
@ -79,85 +81,71 @@ func myDefaultExit(n *gui.Node) {
os.Exit(0)
}
func mainWindow(title string) {
me.window = gadgets.NewBasicWindow(me.myGui, title)
me.window.Vertical()
me.window.Make()
me.window.Draw()
func makeMainWindow() {
if me.window == nil {
return
}
hbox := me.window.Box().NewBox("bw hbox", true)
statusGrid(hbox)
// some artificial padding to make the last row of buttons look less wierd
gr := hbox.NewGroup("Development and Debugging Windows")
gr = gr.NewBox("vbox", false)
group := hbox.NewGroup("Development and Debugging Windows")
gr.NewButton("Debug", func() {
group.NewButton("Debug", func() {
me.debug.Toggle()
})
gr.NewButton("Logging Settings", func() {
group.NewButton("Logging Settings", func() {
logsettings.LogWindow()
})
gr.NewButton("test smartwindow()", func() {
if me.fixWindow == nil {
me.fixWindow = gadgets.NewBasicWindow(me.myGui, "smart window test")
me.fixWindow.Make()
me.fixWindow.Draw()
return
me.showErrorsB = group.NewCheckbox("Show Errors").SetChecked(true)
me.showErrorsB.Custom = func() {
if me.showErrorsB.Checked() {
me.problems.Show()
} else {
me.problems.Hide()
}
me.fixWindow.Toggle()
})
}
gr.NewButton("Show Errors", func() {
me.problems.Toggle()
})
me.autofix = gr.NewCheckbox("Auto-correct Errors")
me.autofix = group.NewCheckbox("Auto-correct Errors")
me.autofix.SetChecked(false)
// These are your problems
me.problems = NewErrorBox(me.window.Box(), "Errors", "has problems?")
me.problems.addIPerror(RR, USER, "1:1:1:1")
}
func statusGrid(n *gui.Node) {
problems := n.NewGroup("status")
problems.Margin()
problems.Pad()
gridP := problems.NewGrid("nuts", 3, 1)
gridP.Margin()
gridP.Pad()
grid := problems.NewGrid("nuts", 3, 1)
gridP.NewLabel("hostname =")
me.hostnameStatus = gridP.NewLabel("invalid")
gridP.NewButton("Linux Status", func() {
grid.NewLabel("hostname =")
me.hostnameStatus = grid.NewLabel("invalid")
grid.NewButton("Linux Status", func() {
me.statusOS.Toggle()
})
me.statusIPv6 = gadgets.NewOneLiner(gridP, "DNS Lookup")
me.statusIPv6 = gadgets.NewOneLiner(grid, "DNS Lookup")
me.statusIPv6.SetText("known")
gridP.NewButton("resolver status", func() {
grid.NewButton("resolver status", func() {
if !me.digStatus.Ready() {
return
}
me.digStatus.window.Toggle()
})
gridP.NewLabel("DNS Status")
me.DnsStatus = gridP.NewLabel("unknown")
me.statusDNSbutton = gridP.NewButton("hostname status", func() {
grid.NewLabel("DNS Status")
me.DnsStatus = grid.NewLabel("unknown")
me.statusDNSbutton = grid.NewButton("hostname status", func() {
if !me.statusDNS.Ready() {
return
}
me.statusDNS.window.Toggle()
})
gridP.NewLabel("DNS API")
me.DnsAPIstatus = gridP.NewLabel("unknown")
me.apiButton = gridP.NewButton("unknown wit.com", func() {
grid.NewLabel("DNS API")
me.DnsAPIstatus = grid.NewLabel("unknown")
me.apiButton = grid.NewButton("unknown wit.com", func() {
log.Log(CHANGE, "WHAT API ARE YOU USING?")
provider := me.statusDNS.GetDNSapi()
if provider == "cloudflare" {

24
main.go
View File

@ -47,9 +47,10 @@ func main() {
// log.Sleep(me.artificialSleep)
// setupControlPanelWindow()
// setup the main tab
mainWindow("DNS and IPv6 Control Panel")
setupControlPanelWindow("DNS and IPv6 Control Panel")
debugTab("Debug")
me.window.Show()
// TODO: track this bug down
log.Sleep(1)
me.window.Toggle()
log.Sleep(1)
@ -67,26 +68,11 @@ func main() {
}()
}
log.Sleep(me.artificialSleep)
digLoop()
// TCP & UDP port 53 lookups + DNS over HTTP lookups + os.Exec(dig)
go myTicker(60*time.Second, "DNSloop", func() {
me.digStatus.Update()
if me.digStatus.Ready() {
current := me.statusIPv6.String()
if me.digStatus.IPv6() {
if current != "WORKING" {
log.Log(CHANGE, "IPv6 resolution is WORKING")
me.statusIPv6.SetText("WORKING")
}
} else {
if current != "Need VPN" {
log.Log(CHANGE, "IPv6 resolution seems to have broken")
me.statusIPv6.SetText("Need VPN")
}
}
}
digLoop()
})
// checks if your DNS records are still broken

View File

@ -95,11 +95,6 @@ func NewResolverStatus(p *gui.Node, title string, server string, hostname string
rs.aaaaSuccess = rs.grid.NewLabel("?")
rs.aaaaFail = rs.grid.NewLabel("?")
rs.group.Margin()
rs.grid.Margin()
rs.group.Pad()
rs.grid.Pad()
return rs
}

View File

@ -63,6 +63,7 @@ type Host struct {
witcom *gadgets.BasicWindow
fixButton *gui.Node
fixWindow *gadgets.BasicWindow
showErrorsB *gui.Node
problems *errorBox
autofix *gui.Node