From 35ae17e15cef079b0f94616ab3ce475fcadc03e2 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 26 Mar 2023 16:17:32 -0500 Subject: [PATCH] everything auto-updates on open Signed-off-by: Jeff Carr --- hostname.go | 8 +++++--- net.go | 24 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/hostname.go b/hostname.go index d385e4f..0690c2e 100644 --- a/hostname.go +++ b/hostname.go @@ -28,9 +28,11 @@ func getHostname() { if (me.fqdn != nil) { // s = me.fqdn.GetText() log("trying to update gui.Label") - // me.fqdn.AddText(s) - me.fqdn.SetText(s) - me.hostname = s + if (me.hostname != s) { + me.fqdn.SetText(s) + me.hostname = s + me.changed = true + } } log("FQDN =", s) } diff --git a/net.go b/net.go index 7731f77..0c80790 100644 --- a/net.go +++ b/net.go @@ -78,7 +78,7 @@ func checkInterface(i net.Interface) { me.ifmap[i.Index] = new(IFtype) me.ifmap[i.Index].gone = false me.ifmap[i.Index].iface = &i - me.ipchange = true + me.changed = true if (me.Interfaces != nil) { me.Interfaces.AddText(i.Name) me.Interfaces.SetText(i.Name) @@ -90,7 +90,7 @@ func checkInterface(i net.Interface) { if (val.iface.Name != i.Name) { log(val.iface.Name, "has changed to it's name to", i.Name) me.ifmap[i.Index].iface = &i - me.ipchange = true + me.changed = true if (me.Interfaces != nil) { me.Interfaces.AddText(i.Name) me.Interfaces.SetText(i.Name) @@ -165,14 +165,12 @@ func checkIP(ip *net.IPNet, i net.Interface) bool { me.ipmap[realip].ipv4 = false t = "IPv6" if (me.IPv6 != nil) { - me.IPv6.AddText(realip) me.IPv6.SetText(realip) } } else { me.ipmap[realip].ipv6 = false me.ipmap[realip].ipv4 = true if (me.IPv4 != nil) { - me.IPv4.AddText(realip) me.IPv4.SetText(realip) } } @@ -189,7 +187,7 @@ func checkIP(ip *net.IPNet, i net.Interface) bool { } func scanInterfaces() { - me.ipchange = false + me.changed = false ifaces, _ := net.Interfaces() // me.ifnew = ifaces log(DEBUGNET, SPEW, ifaces) @@ -215,6 +213,20 @@ func scanInterfaces() { } } deleteChanges() + var all4 string + var all6 string + for s, t := range me.ipmap { + log("HAVE name =", s, "IPv4 =", t.ipv4) + log("HAVE name =", s, "IPv6 =", t.ipv6) + if (t.ipv4) { + all4 += s + "\n" + } + if (t.ipv6) { + all6 += s + "\n" + } + } + me.IPv4.SetText(all4) + me.IPv6.SetText(all6) } // delete network interfaces and ip addresses from the gui @@ -223,6 +235,7 @@ func deleteChanges() { if (t.gone) { log("DELETE int =", i, "name =", t.name, t.iface) delete(me.ifmap, i) + me.changed = true } t.gone = true } @@ -233,6 +246,7 @@ func deleteChanges() { log("DELETE name =", s, "iface =", t.iface) log("DELETE name =", s, "ip =", t.ip) delete(me.ipmap, s) + me.changed = true } t.gone = true }