164 lines
3.7 KiB
Go
164 lines
3.7 KiB
Go
// This creates a simple hello world window
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"go.wit.com/log"
|
|
|
|
"go.wit.com/gui"
|
|
"go.wit.com/lib/debugger"
|
|
"go.wit.com/lib/gadgets"
|
|
"go.wit.com/lib/gui/cloudflare"
|
|
"go.wit.com/lib/gui/logsettings"
|
|
)
|
|
|
|
// This setups up the dns control panel window
|
|
func setupControlPanelWindow(title string) {
|
|
log.Info("artificial sleep of:", me.artificialSleep)
|
|
log.Sleep(me.artificialSleep)
|
|
|
|
// setup the main tab
|
|
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) *gadgets.BasicWindow {
|
|
if me.debug != nil {
|
|
return me.debug
|
|
}
|
|
|
|
win := gadgets.NewBasicWindow(me.myGui, title)
|
|
win.Make()
|
|
|
|
group := win.Box().NewGroup("Real Stuff")
|
|
|
|
group.NewButton("GO GUI Debug Window", func() {
|
|
debugger.DebugWindow()
|
|
})
|
|
|
|
group.NewButton("Logging Settings", func() {
|
|
logsettings.LogWindow()
|
|
})
|
|
|
|
group.NewButton("dig A & AAAA DNS records (updateDNS())", func() {
|
|
log.Log(CHANGE, "updateDNS() going to run:")
|
|
})
|
|
|
|
group = win.Box().NewGroup("debugging options")
|
|
grid := group.NewGrid("nuts", 2, 1)
|
|
|
|
// makes a slider widget
|
|
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(grid, "DNS Timeout", 800*time.Millisecond, 300*time.Second)
|
|
me.dnsTtl.Set(60 * time.Second)
|
|
|
|
grid.NewLabel("dns resolution")
|
|
me.DnsSpeed = grid.NewLabel("unknown")
|
|
|
|
grid.NewLabel("dns resolution speed")
|
|
me.DnsSpeedActual = grid.NewLabel("unknown")
|
|
|
|
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")
|
|
|
|
return win
|
|
}
|
|
|
|
func myDefaultExit(n *gui.Node) {
|
|
log.Println("You can Do exit() things here")
|
|
os.Exit(0)
|
|
}
|
|
|
|
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
|
|
group := hbox.NewGroup("Under Development")
|
|
|
|
group.NewButton("Debug", func() {
|
|
me.debug.Toggle()
|
|
})
|
|
|
|
me.showErrorsB = group.NewCheckbox("Show Errors").SetChecked(true)
|
|
me.showErrorsB.Custom = func() {
|
|
if me.showErrorsB.Checked() {
|
|
me.problems.Show()
|
|
} else {
|
|
me.problems.Hide()
|
|
}
|
|
}
|
|
|
|
me.autofix = group.NewCheckbox("Auto-correct Errors")
|
|
me.autofix.SetChecked(false)
|
|
}
|
|
|
|
func statusGrid(n *gui.Node) {
|
|
problems := n.NewGroup("status")
|
|
|
|
grid := problems.NewGrid("nuts", 3, 1)
|
|
|
|
grid.NewLabel("hostname =")
|
|
me.hostnameStatus = grid.NewLabel("invalid")
|
|
grid.NewButton("Linux Status", func() {
|
|
me.statusOS.Toggle()
|
|
})
|
|
|
|
me.statusIPv6 = gadgets.NewOneLiner(grid, "DNS Lookup")
|
|
me.statusIPv6.SetText("known")
|
|
grid.NewButton("resolver status", func() {
|
|
if !me.digStatus.Ready() {
|
|
return
|
|
}
|
|
me.digStatus.window.Toggle()
|
|
})
|
|
|
|
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()
|
|
})
|
|
|
|
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" {
|
|
if me.witcom != nil {
|
|
me.witcom.Toggle()
|
|
} else {
|
|
me.witcom = cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
|
|
}
|
|
}
|
|
})
|
|
}
|