main window is pretty clean
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
6916a6428d
commit
34569cbcee
46
dns.go
46
dns.go
|
@ -40,42 +40,16 @@ func (h *Host) setIPv4(ipv4s map[string]*IPtype) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func (h *Host) checkDNS() {
|
||||
var ip4 bool = false
|
||||
var ip6 bool = false
|
||||
|
||||
for s, t := range h.ipmap {
|
||||
i := t.iface
|
||||
ipt := "IPv4"
|
||||
if (t.ipv6) {
|
||||
ipt = "IPv6"
|
||||
}
|
||||
if (! t.IsReal()) {
|
||||
log.Println(args.VerboseDNS, "\tIP is not Real", ipt, i.Index, i.Name, s)
|
||||
continue
|
||||
}
|
||||
|
||||
log.Println(args.VerboseDNS, "\tIP is Real ", ipt, i.Index, i.Name, s)
|
||||
if (t.ipv6) {
|
||||
ip6 = true
|
||||
} else {
|
||||
ip4 = true
|
||||
func lookupNSprovider(domain string) string {
|
||||
for s, d := range me.nsmap {
|
||||
log.Log(CHANGE, "lookupNS() domain =", d, "server =", s)
|
||||
if (domain == d) {
|
||||
// figure out the provider (google, cloudflare, etc)
|
||||
return s + " blah"
|
||||
}
|
||||
}
|
||||
|
||||
if (ip4 == true) {
|
||||
log.Println(args.VerboseDNS, "IPv4 should work. Wow. You actually have a real IPv4 address")
|
||||
} else {
|
||||
log.Println(args.VerboseDNS, "IPv4 is broken. (be nice and setup ipv4-only.wit.com)")
|
||||
return "blah"
|
||||
}
|
||||
if (ip6 == true) {
|
||||
log.Println(args.VerboseDNS, "IPv6 should be working. Need to test it here.")
|
||||
} else {
|
||||
log.Println(args.VerboseDNS, "IPv6 is broken. Need to fix it here.")
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// nsLookup performs an NS lookup on the given domain name.
|
||||
func lookupNS(domain string) {
|
||||
|
@ -127,9 +101,15 @@ func setProvider(hostname string) {
|
|||
if len(parts) >= 2 {
|
||||
provider = parts[len(parts)-2]
|
||||
}
|
||||
if me.APIprovider != provider {
|
||||
log.Log(CHANGE, "setProvider() changed to =", provider)
|
||||
}
|
||||
me.APIprovider = provider
|
||||
/*
|
||||
if (me.DnsAPI.S != provider) {
|
||||
me.changed = true
|
||||
log.Log(CHANGE, "setProvider() changed to =", provider)
|
||||
me.DnsAPI.SetText(provider)
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
84
gui.go
84
gui.go
|
@ -44,18 +44,34 @@ func debugTab(title string) {
|
|||
})
|
||||
|
||||
g2 = me.debug.Box().NewGroup("debugging options")
|
||||
gridP := g2.NewGrid("nuts", 2, 1)
|
||||
|
||||
// makes a slider widget
|
||||
me.ttl = gadgets.NewDurationSlider(g2, "Loop Timeout", 10 * time.Millisecond, 5 * time.Second)
|
||||
me.ttl = gadgets.NewDurationSlider(gridP, "Loop Timeout", 10 * time.Millisecond, 5 * time.Second)
|
||||
me.ttl.Set(300 * time.Millisecond)
|
||||
|
||||
// makes a slider widget
|
||||
me.dnsTtl = gadgets.NewDurationSlider(g2, "DNS Timeout", 800 * time.Millisecond, 300 * time.Second)
|
||||
me.dnsTtl = gadgets.NewDurationSlider(gridP, "DNS Timeout", 800 * time.Millisecond, 300 * time.Second)
|
||||
me.dnsTtl.Set(60 * time.Second)
|
||||
|
||||
gridP.NewLabel("dns resolution")
|
||||
me.DnsSpeed = gridP.NewLabel("unknown")
|
||||
|
||||
gridP.NewLabel("dns resolution speed")
|
||||
me.DnsSpeedActual = gridP.NewLabel("unknown")
|
||||
|
||||
gridP.NewLabel("Test speed")
|
||||
newGrid := gridP.NewGrid("nuts", 2, 1).Pad()
|
||||
|
||||
g2.Margin()
|
||||
g2.Pad()
|
||||
|
||||
newGrid.NewLabel("ping.wit.com =")
|
||||
newGrid.NewLabel("unknown")
|
||||
|
||||
newGrid.NewLabel("ping6.wit.com =")
|
||||
newGrid.NewLabel("unknown")
|
||||
|
||||
me.debug.Hide()
|
||||
}
|
||||
|
||||
|
@ -87,7 +103,7 @@ func mainWindow(title string) {
|
|||
|
||||
statusGrid(me.window.Box())
|
||||
|
||||
gr = me.window.Box().NewGroup("debugging")
|
||||
gr = me.window.Box().NewGroup("")
|
||||
/*
|
||||
me.statusDNSbutton = gr.NewButton("hostname status", func () {
|
||||
if ! me.statusDNS.Ready() {return}
|
||||
|
@ -133,8 +149,12 @@ func mainWindow(title string) {
|
|||
|
||||
func statusGrid(n *gui.Node) {
|
||||
problems := n.NewGroup("status")
|
||||
problems.Margin()
|
||||
problems.Pad()
|
||||
|
||||
gridP := problems.NewGrid("nuts", 3, 1)
|
||||
gridP.Margin()
|
||||
gridP.Pad()
|
||||
|
||||
gridP.NewLabel("hostname =")
|
||||
me.hostnameStatus = gridP.NewLabel("invalid")
|
||||
|
@ -142,54 +162,40 @@ func statusGrid(n *gui.Node) {
|
|||
me.statusOS.Toggle()
|
||||
})
|
||||
|
||||
gridP.NewLabel("DNS Status =")
|
||||
me.DnsStatus = gridP.NewLabel("unknown")
|
||||
me.statusDNSbutton = gridP.NewButton("hostname status", func () {
|
||||
if ! me.statusDNS.Ready() {return}
|
||||
me.statusDNS.window.Toggle()
|
||||
})
|
||||
|
||||
me.statusIPv6 = gadgets.NewOneLiner(gridP, "IPv6 working")
|
||||
me.statusIPv6 = gadgets.NewOneLiner(gridP, "DNS Lookup")
|
||||
me.statusIPv6.Set("known")
|
||||
gridP.NewButton("resolver status", func () {
|
||||
if ! me.digStatus.Ready() {return}
|
||||
me.digStatus.window.Toggle()
|
||||
})
|
||||
|
||||
gridP.NewLabel("dns API provider =")
|
||||
me.DnsAPI = gridP.NewLabel("unknown")
|
||||
gridP.NewButton("cloudflare wit.com", func () {
|
||||
gridP.NewLabel("DNS Status")
|
||||
me.DnsStatus = gridP.NewLabel("unknown")
|
||||
me.statusDNSbutton = gridP.NewButton("hostname status", func () {
|
||||
if ! me.statusDNS.Ready() {return}
|
||||
me.statusDNS.window.Toggle()
|
||||
})
|
||||
|
||||
gridP.NewLabel("DNS API")
|
||||
me.DnsAPIstatus = gridP.NewLabel("unknown")
|
||||
var apiButton *gui.Node
|
||||
apiButton = gridP.NewButton("unknown wit.com", func () {
|
||||
log.Log(CHANGE, "WHAT API ARE YOU USING?")
|
||||
provider := me.statusDNS.GetDNSapi()
|
||||
apiButton.SetText(provider + " wit.com")
|
||||
if provider == "cloudflare" {
|
||||
me.DnsAPIstatus.Set("WORKING")
|
||||
return
|
||||
|
||||
if me.witcom != nil {
|
||||
me.witcom.Toggle()
|
||||
}
|
||||
me.witcom = cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
|
||||
}
|
||||
})
|
||||
|
||||
gridP.NewLabel("dns resolution")
|
||||
me.DnsSpeed = gridP.NewLabel("unknown")
|
||||
gridP.NewLabel("")
|
||||
n.NewGroup("NOTES")
|
||||
|
||||
gridP.NewLabel("dns resolution speed")
|
||||
me.DnsSpeedActual = gridP.NewLabel("unknown")
|
||||
gridP.NewLabel("")
|
||||
|
||||
gridP.Margin()
|
||||
gridP.Pad()
|
||||
|
||||
// TODO: these are notes for me things to figure out
|
||||
ng := n.NewGroup("TODO:")
|
||||
gridP = ng.NewGrid("nut2", 2, 2)
|
||||
|
||||
gridP.NewLabel("ping.wit.com =")
|
||||
gridP.NewLabel("unknown")
|
||||
|
||||
gridP.NewLabel("ping6.wit.com =")
|
||||
gridP.NewLabel("unknown")
|
||||
|
||||
problems.Margin()
|
||||
problems.Pad()
|
||||
gridP.Margin()
|
||||
gridP.Pad()
|
||||
}
|
||||
|
||||
// run everything because something has changed
|
||||
|
@ -199,7 +205,7 @@ func updateDNS() {
|
|||
|
||||
if me.digStatus.Ready() {
|
||||
if me.digStatus.IPv6() {
|
||||
me.statusIPv6.Set("IPv6 WORKING")
|
||||
me.statusIPv6.Set("WORKING")
|
||||
} else {
|
||||
me.statusIPv6.Set("Need VPN")
|
||||
}
|
||||
|
|
|
@ -323,7 +323,9 @@ func (hs *hostnameStatus) updateStatus() {
|
|||
hs.status.Set("BROKEN")
|
||||
}
|
||||
|
||||
hs.dnsAPI.Set(me.DnsAPI.S)
|
||||
// lookup the DNS provider
|
||||
// hs.dnsAPI.Set(me.DnsAPI.S)
|
||||
lookupNSprovider("wit.com")
|
||||
}
|
||||
|
||||
func (hs *hostnameStatus) Show() {
|
||||
|
@ -341,3 +343,7 @@ func (hs *hostnameStatus) Hide() {
|
|||
}
|
||||
hs.hidden = true
|
||||
}
|
||||
|
||||
func (hs *hostnameStatus) GetDNSapi() string {
|
||||
return me.APIprovider
|
||||
}
|
||||
|
|
|
@ -26,8 +26,10 @@ type Host struct {
|
|||
statusOS *linuxstatus.LinuxStatus // what the Linux OS sees
|
||||
digStatus *digStatus // window of the results of DNS lookups
|
||||
|
||||
// WHEN THESE ARE ALL "WORKING", then everything is good
|
||||
hostnameStatus *gui.Node // a summary for the user of where things are
|
||||
// hostname *gadgets.OneLiner // the hostname grabbed from gadget.linuxStatus
|
||||
DnsAPIstatus *gui.Node // does your DNS API work?
|
||||
APIprovider string
|
||||
|
||||
artificialSleep float64 `default:"0.7"` // artificial sleep on startup
|
||||
artificialS string `default:"abc"` // artificial sleep on startup
|
||||
|
@ -49,7 +51,6 @@ type Host struct {
|
|||
ipv6s map[string]dns.RR
|
||||
|
||||
// DNS stuff
|
||||
DnsAPI *gui.Node // what DNS API to use?
|
||||
DnsStatus *gui.Node // the current state of DNS
|
||||
DnsSpeed *gui.Node // 'FAST', 'OK', 'SLOW', etc
|
||||
DnsSpeedActual *gui.Node // the last actual duration
|
||||
|
|
Loading…
Reference in New Issue