diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 70 |
1 files changed, 36 insertions, 34 deletions
@@ -4,22 +4,22 @@ package main -import ( +import ( "fmt" // "runtime" - "time" "embed" + "time" + "go.wit.com/lib/debugger" + "go.wit.com/gui" "go.wit.com/log" - "go.wit.com/gui/gui" - "go.wit.com/gui/debugger" - "go.wit.com/gui/lib/linuxstatus" + "go.wit.com/lib/gui/linuxstatus" "github.com/miekg/dns" ) -//go:embed plugins/* +//go:embed resources/* var resToolkit embed.FS func main() { @@ -41,6 +41,9 @@ func main() { } me.myGui = gui.New() + me.myGui.LoadToolkit("andlabs") + log.Sleep(1) + panic("test") me.myGui.InitEmbed(resToolkit) me.myGui.Default() @@ -60,27 +63,27 @@ func main() { if debugger.ArgDebug() { go func() { log.Sleep(2) - debugger.DebugWindow(me.myGui) + debugger.DebugWindow() }() } log.Sleep(me.artificialSleep) // TCP & UDP port 53 lookups + DNS over HTTP lookups + os.Exec(dig) - go myTicker(60 * time.Second, "DNSloop", func() { + go myTicker(60*time.Second, "DNSloop", func() { me.digStatus.Update() if me.digStatus.Ready() { - current := me.statusIPv6.Get() + current := me.statusIPv6.String() if me.digStatus.IPv6() { if current != "WORKING" { log.Log(CHANGE, "IPv6 resolution is WORKING") - me.statusIPv6.Set("WORKING") + me.statusIPv6.SetValue("WORKING") } } else { if current != "Need VPN" { log.Log(CHANGE, "IPv6 resolution seems to have broken") - me.statusIPv6.Set("Need VPN") + me.statusIPv6.SetValue("Need VPN") } } } @@ -91,7 +94,7 @@ func main() { // things until the timeout happens lastProvider := "unknown" - go myTicker(10 * time.Second, "DNSloop", func() { + go myTicker(10*time.Second, "DNSloop", func() { log.Log(INFO, "me.statusDNS.Update() START") me.statusDNS.Update() @@ -102,24 +105,24 @@ func main() { me.apiButton.SetText(provider + " wit.com") } if provider == "cloudflare" { - me.DnsAPIstatus.Set("WORKING") + me.DnsAPIstatus.SetValue("WORKING") } }) // probes the OS network settings - go myTicker(500 * time.Millisecond, "me.statusOS,Update()", func() { - duration := timeFunction( func() { + go myTicker(500*time.Millisecond, "me.statusOS,Update()", func() { + duration := timeFunction(func() { me.statusOS.Update() if me.statusOS.ValidHostname() { - if me.hostnameStatus.GetText() != "WORKING" { - me.hostnameStatus.Set("WORKING") + if me.hostnameStatus.String() != "WORKING" { + me.hostnameStatus.SetValue("WORKING") me.changed = true } } // re-check DNS API provider - if (me.statusOS.Changed()) { + if me.statusOS.Changed() { // lookup the NS records for your domain // if your host is test.wit.com, find the NS resource records for wit.com lookupNS(me.statusOS.GetDomainName()) @@ -135,22 +138,22 @@ func main() { }) // check the four known things to see if they are all WORKING - myTicker(10 * time.Second, "MAIN LOOP", func() { + 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()) + if me.hostnameStatus.String() != "WORKING" { + log.Log(CHANGE, "The hostname is not WORKING yet", me.hostnameStatus.String()) working = false } - if me.statusIPv6.Get() != "WORKING" { - log.Log(CHANGE, "IPv6 DNS lookup has not been confirmed yet", me.statusIPv6.Get()) + if me.statusIPv6.String() != "WORKING" { + log.Log(CHANGE, "IPv6 DNS lookup has not been confirmed yet", me.statusIPv6.String()) working = false } - if me.DnsStatus.GetText() != "WORKING" { - log.Log(CHANGE, "Your IPv6 DNS settings have not been confirmed yet", me.DnsStatus.GetText()) + if me.DnsStatus.String() != "WORKING" { + log.Log(CHANGE, "Your IPv6 DNS settings have not been confirmed yet", me.DnsStatus.String()) working = false } - if me.DnsAPIstatus.GetText() != "WORKING" { - log.Log(CHANGE, "The DNS API provider is not yet working", me.DnsAPIstatus.GetText()) + if me.DnsAPIstatus.String() != "WORKING" { + log.Log(CHANGE, "The DNS API provider is not yet working", me.DnsAPIstatus.String()) working = false } if working { @@ -170,8 +173,8 @@ func main() { // timeFunction takes a function as an argument and returns the execution time. func timeFunction(f func()) time.Duration { - startTime := time.Now() // Record the start time - f() // Execute the function + startTime := time.Now() // Record the start time + f() // Execute the function return time.Since(startTime) // Calculate the elapsed time } @@ -181,16 +184,15 @@ func timeStamp() string { return stamp } - func myTicker(t time.Duration, name string, f func()) { ticker := time.NewTicker(t) defer ticker.Stop() done := make(chan bool) /* - go func() { - time.Sleep(10 * time.Second) - done <- true - }() + go func() { + time.Sleep(10 * time.Second) + done <- true + }() */ for { select { |
