diff --git a/digStatusWindow.go b/digStatusWindow.go index e62be77..5fc375a 100644 --- a/digStatusWindow.go +++ b/digStatusWindow.go @@ -204,7 +204,7 @@ func (ds *digStatus) set(a any, s string) { } func (ds *digStatus) updateDnsStatus() { - var cmd, out string + // var cmd, out string var ipv4, ipv6 bool log.Info("updateDnsStatus() START") @@ -252,15 +252,13 @@ func (ds *digStatus) updateDnsStatus() { ds.setIPv6status("Need VPN") } - cmd = "dig +noall +answer www.wit.com A" - out = shell.RunCapture(cmd) - log.Log(DNS, "makeDnsStatusGrid() dig", out) - me.digStatus.set(ds.DnsDigUDP, out) + r := shell.Output("", []string{"dig", "+noall", "+answer", "www.wit.com", "A"}) + log.Log(DNS, "makeDnsStatusGrid() dig", r.Stdout()) + me.digStatus.set(ds.DnsDigUDP, r.Stdout()) - cmd = "dig +noall +answer www.wit.com AAAA" - out = shell.RunCapture(cmd) - log.Log(DNS, "makeDnsStatusGrid() dig", out) - me.digStatus.set(ds.DnsDigTCP, out) + r = shell.Output("", []string{"dig", "+noall", "+answer", "www.wit.com", "AAAA"}) + log.Log(DNS, "makeDnsStatusGrid() dig", r.Stdout()) + me.digStatus.set(ds.DnsDigTCP, r.Stdout()) /* g2.NewButton("dig +trace", func () { @@ -283,23 +281,14 @@ func (ds *digStatus) makeHttpStatusGrid() { } func (ds *digStatus) makeDnsStatusGrid() { - var cmd, out string group := ds.details.NewGroup("dig results") grid := group.NewGrid("LookupStatus", 2, 2) - cmd = "dig +noall +answer go.wit.com A" - grid.NewLabel(cmd) + grid.NewLabel("dig +noall +answer go.wit.com A") ds.DnsDigUDP = grid.NewLabel("?") - out = shell.RunCapture(cmd) - log.Log(DNS, "makeDnsStatusGrid() dig", out) - me.digStatus.set(ds.DnsDigUDP, out) - cmd = "dig +noall +answer go.wit.com AAAA" - grid.NewLabel(cmd) + grid.NewLabel("dig +noall +answer go.wit.com AAAA") ds.DnsDigTCP = grid.NewLabel("?") - out = shell.RunCapture(cmd) - log.Log(DNS, "makeDnsStatusGrid() dig", out) - me.digStatus.set(ds.DnsDigTCP, out) group.Pad() grid.Pad() diff --git a/errorBox.go b/errorBox.go index 6991683..427b86e 100644 --- a/errorBox.go +++ b/errorBox.go @@ -10,6 +10,7 @@ import ( "go.wit.com/gui" "go.wit.com/lib/gadgets" + "go.wit.com/lib/gui/shell" "go.wit.com/log" ) @@ -131,21 +132,20 @@ func (eb *errorBox) addIPerror(kind ProblemType, action ActionType, ip string) b return false } -// get all your problems! -func (eb *errorBox) Scan() []anError { - for s, thing := range eb.fixes { - log.Log(CHANGE, "Scan()", s, thing.actionLabel.String(), thing.ipLabel.String()) - } - return nil +func (e *anError) Age() string { + // Get the current time + currentTime := time.Now() + + // Calculate the duration between t current time + duration := currentTime.Sub(e.problem.born) + + age := shell.FormatDuration(duration) + log.Log(WARN, "Error Age() =", age) + + return age } -func (eb *errorBox) fix(key string) bool { - if eb.fixes[key] == nil { - log.Log(WARN, "Unknown error. could not find key =", key) - log.Log(WARN, "TODO: probably remove this error. key =", key) - return true - } - myErr := eb.fixes[key] +func (myErr *anError) Fix() bool { log.Log(WARN, "should try to fix", myErr.problem.kind, "here. IP =", myErr.problem.aaaa) if os.Getenv("DNS_AUTOCORRECT") != "true" { log.Log(WARN, "not autofixing. $DNS_AUTOCORRECT != true") @@ -201,6 +201,31 @@ func (eb *errorBox) fix(key string) bool { return false } +// get all your problems! +func (eb *errorBox) Scan() []anError { + for s, thing := range eb.fixes { + log.Log(WARN, "Scan()", s, thing.actionLabel.String(), thing.ipLabel.String(), thing.Age()) + if thing.problem.begun { + log.Log(WARN, "Scan()", "attempted to fix has happened") + } else { + log.Log(WARN, "Scan()", "attempted to fix not yet happened") + thing.Fix() + } + + } + return nil +} + +func (eb *errorBox) fix(key string) bool { + if eb.fixes[key] == nil { + log.Log(WARN, "Unknown error. could not find key =", key) + log.Log(WARN, "TODO: probably remove this error. key =", key) + return true + } + myErr := eb.fixes[key] + return myErr.Fix() +} + func (eb *errorBox) update() bool { return false }