watches for finished setup

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-07 14:43:17 -06:00
parent c82e88d015
commit 1decb6925b
3 changed files with 27 additions and 8 deletions

10
gui.go
View File

@ -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")
}
})

24
main.go
View File

@ -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")
})
}
/*

View File

@ -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