From 1decb6925bbde8c6c9015ec603b8ca0b9cdd587b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 7 Jan 2024 14:43:17 -0600 Subject: [PATCH] watches for finished setup Signed-off-by: Jeff Carr --- gui.go | 10 +++------- main.go | 24 +++++++++++++++++++++++- structs.go | 1 + 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/gui.go b/gui.go index 46c42ce..253e948 100644 --- a/gui.go +++ b/gui.go @@ -177,19 +177,15 @@ func statusGrid(n *gui.Node) { gridP.NewLabel("DNS API") me.DnsAPIstatus = gridP.NewLabel("unknown") - var apiButton *gui.Node - apiButton = gridP.NewButton("unknown wit.com", func () { + me.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() + } else { + me.witcom = cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06") } - me.witcom = cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06") } }) diff --git a/main.go b/main.go index 8dfa852..c21ae6f 100644 --- a/main.go +++ b/main.go @@ -95,6 +95,7 @@ func main() { if provider != lastProvider { log.Log(CHANGE, "Your DNS API provider appears to have changed to", provider) lastProvider = provider + me.apiButton.SetText(provider + " wit.com") } if provider == "cloudflare" { me.DnsAPIstatus.Set("WORKING") @@ -102,7 +103,7 @@ func main() { }) // probes the OS network settings - myTicker(500 * time.Millisecond, "me.statusOS,Update()", func() { + go myTicker(500 * time.Millisecond, "me.statusOS,Update()", func() { duration := timeFunction( func() { me.statusOS.Update() @@ -124,6 +125,27 @@ func main() { s := fmt.Sprint(duration) me.statusOS.SetSpeedActual(s) }) + + // check the four known things to see if they are all WORKING + myTicker(3 * time.Second, "MAIN LOOP", func() { + if me.hostnameStatus.GetText() != "WORKING" { + log.Log(CHANGE, "The hostname is not WORKING yet", me.hostnameStatus.GetText()) + return + } + if me.statusIPv6.Get() != "WORKING" { + log.Log(CHANGE, "IPv6 DNS lookup has not been confirmed yet", me.statusIPv6.Get()) + return + } + if me.DnsStatus.GetText() != "WORKING" { + log.Log(CHANGE, "Your IPv6 DNS settings have not been confirmed yet", me.DnsStatus.GetText()) + return + } + if me.DnsAPIstatus.GetText() != "WORKING" { + log.Log(CHANGE, "The DNS API provider is not yet working", me.DnsAPIstatus.GetText()) + return + } + log.Log(CHANGE, "EVERYTHING IS WORKING. YOU HAVE IPv6 BLISS") + }) } /* diff --git a/structs.go b/structs.go index e840a37..8130881 100644 --- a/structs.go +++ b/structs.go @@ -30,6 +30,7 @@ type Host struct { hostnameStatus *gui.Node // a summary for the user of where things are DnsAPIstatus *gui.Node // does your DNS API work? APIprovider string + apiButton *gui.Node // the button you click for the API config page artificialSleep float64 `default:"0.7"` // artificial sleep on startup artificialS string `default:"abc"` // artificial sleep on startup