start automatically fixing the problems
This commit is contained in:
parent
46de348eb2
commit
42ca387a49
|
@ -204,7 +204,7 @@ func (ds *digStatus) set(a any, s string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *digStatus) updateDnsStatus() {
|
func (ds *digStatus) updateDnsStatus() {
|
||||||
var cmd, out string
|
// var cmd, out string
|
||||||
var ipv4, ipv6 bool
|
var ipv4, ipv6 bool
|
||||||
|
|
||||||
log.Info("updateDnsStatus() START")
|
log.Info("updateDnsStatus() START")
|
||||||
|
@ -252,15 +252,13 @@ func (ds *digStatus) updateDnsStatus() {
|
||||||
ds.setIPv6status("Need VPN")
|
ds.setIPv6status("Need VPN")
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = "dig +noall +answer www.wit.com A"
|
r := shell.Output("", []string{"dig", "+noall", "+answer", "www.wit.com", "A"})
|
||||||
out = shell.RunCapture(cmd)
|
log.Log(DNS, "makeDnsStatusGrid() dig", r.Stdout())
|
||||||
log.Log(DNS, "makeDnsStatusGrid() dig", out)
|
me.digStatus.set(ds.DnsDigUDP, r.Stdout())
|
||||||
me.digStatus.set(ds.DnsDigUDP, out)
|
|
||||||
|
|
||||||
cmd = "dig +noall +answer www.wit.com AAAA"
|
r = shell.Output("", []string{"dig", "+noall", "+answer", "www.wit.com", "AAAA"})
|
||||||
out = shell.RunCapture(cmd)
|
log.Log(DNS, "makeDnsStatusGrid() dig", r.Stdout())
|
||||||
log.Log(DNS, "makeDnsStatusGrid() dig", out)
|
me.digStatus.set(ds.DnsDigTCP, r.Stdout())
|
||||||
me.digStatus.set(ds.DnsDigTCP, out)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
g2.NewButton("dig +trace", func () {
|
g2.NewButton("dig +trace", func () {
|
||||||
|
@ -283,23 +281,14 @@ func (ds *digStatus) makeHttpStatusGrid() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *digStatus) makeDnsStatusGrid() {
|
func (ds *digStatus) makeDnsStatusGrid() {
|
||||||
var cmd, out string
|
|
||||||
group := ds.details.NewGroup("dig results")
|
group := ds.details.NewGroup("dig results")
|
||||||
grid := group.NewGrid("LookupStatus", 2, 2)
|
grid := group.NewGrid("LookupStatus", 2, 2)
|
||||||
|
|
||||||
cmd = "dig +noall +answer go.wit.com A"
|
grid.NewLabel("dig +noall +answer go.wit.com A")
|
||||||
grid.NewLabel(cmd)
|
|
||||||
ds.DnsDigUDP = grid.NewLabel("?")
|
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("dig +noall +answer go.wit.com AAAA")
|
||||||
grid.NewLabel(cmd)
|
|
||||||
ds.DnsDigTCP = grid.NewLabel("?")
|
ds.DnsDigTCP = grid.NewLabel("?")
|
||||||
out = shell.RunCapture(cmd)
|
|
||||||
log.Log(DNS, "makeDnsStatusGrid() dig", out)
|
|
||||||
me.digStatus.set(ds.DnsDigTCP, out)
|
|
||||||
|
|
||||||
group.Pad()
|
group.Pad()
|
||||||
grid.Pad()
|
grid.Pad()
|
||||||
|
|
51
errorBox.go
51
errorBox.go
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -131,21 +132,20 @@ func (eb *errorBox) addIPerror(kind ProblemType, action ActionType, ip string) b
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all your problems!
|
func (e *anError) Age() string {
|
||||||
func (eb *errorBox) Scan() []anError {
|
// Get the current time
|
||||||
for s, thing := range eb.fixes {
|
currentTime := time.Now()
|
||||||
log.Log(CHANGE, "Scan()", s, thing.actionLabel.String(), thing.ipLabel.String())
|
|
||||||
}
|
// Calculate the duration between t current time
|
||||||
return nil
|
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 {
|
func (myErr *anError) Fix() 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]
|
|
||||||
log.Log(WARN, "should try to fix", myErr.problem.kind, "here. IP =", myErr.problem.aaaa)
|
log.Log(WARN, "should try to fix", myErr.problem.kind, "here. IP =", myErr.problem.aaaa)
|
||||||
if os.Getenv("DNS_AUTOCORRECT") != "true" {
|
if os.Getenv("DNS_AUTOCORRECT") != "true" {
|
||||||
log.Log(WARN, "not autofixing. $DNS_AUTOCORRECT != true")
|
log.Log(WARN, "not autofixing. $DNS_AUTOCORRECT != true")
|
||||||
|
@ -201,6 +201,31 @@ func (eb *errorBox) fix(key string) bool {
|
||||||
return false
|
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 {
|
func (eb *errorBox) update() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue