summaryrefslogtreecommitdiff
path: root/hostnameStatusWindow.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-03-02 11:51:16 -0600
committerJeff Carr <[email protected]>2024-03-02 11:51:16 -0600
commit46de348eb26cae3558ca943b46472a8cdc3e3a96 (patch)
treed56cffcd93445910ddb1abe0d5243467126615ce /hostnameStatusWindow.go
parent7b4eb41de7e1c65c07dfc8f04f1263b3f258b268 (diff)
start rewrite after some years of nothingv0.22.0v0.21.2
Diffstat (limited to 'hostnameStatusWindow.go')
-rw-r--r--hostnameStatusWindow.go29
1 files changed, 20 insertions, 9 deletions
diff --git a/hostnameStatusWindow.go b/hostnameStatusWindow.go
index 5ce8ae9..c37f430 100644
--- a/hostnameStatusWindow.go
+++ b/hostnameStatusWindow.go
@@ -64,7 +64,7 @@ func InitHostnameStatus() *hostnameStatus {
hs.hidden = true
// hs.hostname = me.hostname
- hs.window = gadgets.RawBasicWindow("fix hostname here"+" Status")
+ hs.window = gadgets.RawBasicWindow("fix hostname here" + " Status")
hs.window.Make()
// hs.window.Draw()
// hs.window.Hide()
@@ -118,7 +118,7 @@ func (hs *hostnameStatus) API() string {
}
func (hs *hostnameStatus) Update() {
- log.Info("hostnameStatus() Update() START")
+ // log.Info("hostnameStatus() Update() START")
if hs == nil {
log.Error(errors.New("hostnameStatus() Update() hs == nil"))
return
@@ -136,7 +136,7 @@ func (hs *hostnameStatus) Update() {
} else {
hs.set(hs.speed, "FAST")
}
- log.Info("hostnameStatus() Update() END")
+ // log.Info("hostnameStatus() Update() END")
}
// Returns true if the status is valid
@@ -227,7 +227,11 @@ func (hs *hostnameStatus) GetIPv6() []string {
if !hs.Ready() {
return nil
}
- return strings.Split(hs.dnsAAAA.String(), "\n")
+ // clean out any blank lines
+ // todo: fix this whole hacky thing
+ tmp := hs.dnsAAAA.String()
+ tmp = strings.TrimSpace(tmp)
+ return strings.Split(tmp, "\n")
}
func (hs *hostnameStatus) updateStatus() {
@@ -305,7 +309,7 @@ func (hs *hostnameStatus) updateStatus() {
}
last := hs.statusIPv6.String()
- if hs.verifyIPv6() {
+ if ok, err := hs.verifyIPv6(); ok {
if last != "WORKING" {
log.Log(CHANGE, "Your DNS IPv6 has started working.", me.statusOS.GetHostname(), "should now work")
hs.changed = true
@@ -314,7 +318,7 @@ func (hs *hostnameStatus) updateStatus() {
}
} else {
if last != "BROKEN" {
- log.Log(CHANGE, "Your DNS entries for IPv6 have BROKEN")
+ log.Log(CHANGE, "Your DNS entries for IPv6 have BROKEN", ok, err)
hs.changed = true
hs.statusIPv6.SetText("BROKEN")
me.DnsStatus.SetText("BROKEN")
@@ -322,8 +326,13 @@ func (hs *hostnameStatus) updateStatus() {
}
}
-func (hs *hostnameStatus) verifyIPv6() bool {
+var ErrorNoIPv6 error = errors.New("OS has no IPv6")
+var ErrorDeleteIPv6 error = errors.New("IPv6 Delete")
+var ErrorCreateIPv6 error = errors.New("IPv6 Create")
+
+func (hs *hostnameStatus) verifyIPv6() (bool, error) {
var working bool = true
+ var err error = nil
osAAAA := make(map[string]string)
dnsAAAA := make(map[string]string)
@@ -331,7 +340,7 @@ func (hs *hostnameStatus) verifyIPv6() bool {
tmp := me.statusOS.GetIPv6()
if len(tmp) == 0 {
// you don't have any IPv6 addresses in your OS right now
- return false
+ return false, ErrorNoIPv6
}
for _, aaaa := range me.statusOS.GetIPv6() {
log.Log(INFO, "FOUND OS AAAA ip", aaaa)
@@ -351,6 +360,7 @@ func (hs *hostnameStatus) verifyIPv6() bool {
working = false
log.Log(INFO, "DNS AAAA is not in OS", aaaa)
addToFixWindow("DELETE", aaaa)
+ err = ErrorDeleteIPv6
}
}
@@ -361,10 +371,11 @@ func (hs *hostnameStatus) verifyIPv6() bool {
working = false
log.Log(INFO, "OS AAAA is not in DNS", aaaa)
addToFixWindow("CREATE", aaaa)
+ err = ErrorCreateIPv6
}
}
- return working
+ return working, err
}
func (hs *hostnameStatus) Show() {