summaryrefslogtreecommitdiff
path: root/errorBox.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-04-15 05:06:14 -0500
committerJeff Carr <[email protected]>2024-04-15 05:06:14 -0500
commit42ca387a49857c6a179650c4296384ce74c1e3d1 (patch)
tree2084a707cfcbdb2b34a870a7e8a5474b5b737c53 /errorBox.go
parent46de348eb26cae3558ca943b46472a8cdc3e3a96 (diff)
start automatically fixing the problems
Diffstat (limited to 'errorBox.go')
-rw-r--r--errorBox.go51
1 files changed, 38 insertions, 13 deletions
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
}