From 9b4d2d9a08819c28ee01be36ebd9c7acdb015d1c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 7 Jan 2024 08:40:46 -0600 Subject: [PATCH] more status cleanups Signed-off-by: Jeff Carr --- gui.go | 76 +++--------------------------------------------------- main.go | 8 ++++++ structs.go | 2 +- 3 files changed, 13 insertions(+), 73 deletions(-) diff --git a/gui.go b/gui.go index 3505608..4746f20 100644 --- a/gui.go +++ b/gui.go @@ -58,44 +58,6 @@ func debugTab(title string) { me.debug.Hide() } -/* -// doesn't actually do any network traffic -// it just updates the GUI -func displayDNS() string { - var aaaa []string - aaaa = append(aaaa, "blah", "more") - // h := me.hostname - var all string - var broken string = "unknown" - for _, s := range aaaa { - log.Log(STATUS, "host", "fixme", "DNS AAAA =", s, "ipmap[s] =", me.ipmap[s]) - all += s + "\n" - if ( me.ipmap[s] == nil) { - log.Warn("THIS IS THE WRONG AAAA DNS ENTRY: host", "fixme", "DNS AAAA =", s) - broken = "wrong AAAA entry" - } else { - if (broken == "unknown") { - broken = "needs update" - } - } - } - - var a []string - a = append(a, "fixme") - sort.Strings(a) - all = strings.Join(a, "\n") - if (all == "") { - log.Log(NOW, "THERE IS NOT a real A DNS ENTRY") - all = "CNAME ipv6.wit.com" - } - if (me.DnsA.S != all) { - log.Log(NOW, "DnsA.SetText() to:", all) - me.DnsA.SetText(all) - } - return broken -} -*/ - func myDefaultExit(n *gui.Node) { log.Println("You can Do exit() things here") os.Exit(0) @@ -105,11 +67,6 @@ func mainWindow(title string) { me.window = gadgets.NewBasicWindow(me.myGui, title) gr := me.window.Box().NewGroup("dns update") - grid := gr.NewGrid("gridnuts", 2, 2) - - grid.SetNext(1,1) - - me.hostname = gadgets.NewOneLiner(grid, "hostname =").Set("unknown") // This is where you figure out what to do next to fix the problems me.fixButton = gr.NewButton("fix", func () { @@ -119,16 +76,13 @@ func mainWindow(title string) { } log.Log(CHANGE, "IPv6 WORKED") // update everything here visually for the user - hostname := me.statusOS.GetHostname() - me.hostname.Set(hostname) + // hostname := me.statusOS.GetHostname() + // me.hostname.Set(hostname) me.hostnameStatus.Set("WORKING") me.DnsStatus.Set("WORKING") // me.fixButton.Disable() }) - grid.Margin() - grid.Pad() - statusGrid(me.window.Box()) gr = me.window.Box().NewGroup("debugging") @@ -203,6 +157,7 @@ func updateDNS() { // log.Println("digAAAA()") + /* if me.statusOS.ValidHostname() { var aaaa []string h := me.statusOS.GetHostname() @@ -221,32 +176,9 @@ func updateDNS() { cloudflare.CFdialog.NameNode.SetText(h) } - /* - d := deleteAAA() - if (d != "") { - if (cloudflare.CFdialog.ValueNode != nil) { - cloudflare.CFdialog.ValueNode.SetText(d) - } - } - */ -// m := missingAAAA() -// if (m != "") { -// if (cloudflare.CFdialog.ValueNode != nil) { -// cloudflare.CFdialog.ValueNode.SetText(m) -// } -// /* -// rr := &cloudflare.RRT{ -// Type: "AAAA", -// Name: me.hostname, -// Ttl: "Auto", -// Proxied: false, -// Content: m, -// } -// cloudflare.Update(rr) -// */ -// } } } + */ // status := displayDNS() // update the GUI based on dig results // me.DnsStatus.SetText(status) diff --git a/main.go b/main.go index 5988392..e57b4ef 100644 --- a/main.go +++ b/main.go @@ -157,9 +157,17 @@ func dnsTTL() { } // run update on the LinuxStatus() window +// also update a few things on the main window func linuxLoop() { me.statusOS.Update() + if me.statusOS.ValidHostname() { + if me.hostnameStatus.GetText() != "VALID" { + me.hostnameStatus.Set("VALID") + me.changed = true + } + } + if (me.statusOS.Changed()) { stamp := time.Now().Format("2006/01/02 15:04:05") log.Log(CHANGE, "Network things changed on", stamp) diff --git a/structs.go b/structs.go index 061eb09..2408dbb 100644 --- a/structs.go +++ b/structs.go @@ -27,7 +27,7 @@ type Host struct { digStatus *digStatus // window of the results of DNS lookups hostnameStatus *gui.Node // a summary for the user of where things are - hostname *gadgets.OneLiner // the hostname grabbed from gadget.linuxStatus + // hostname *gadgets.OneLiner // the hostname grabbed from gadget.linuxStatus artificialSleep float64 `default:"0.7"` // artificial sleep on startup artificialS string `default:"abc"` // artificial sleep on startup