summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-06 16:59:33 -0600
committerJeff Carr <[email protected]>2024-01-06 16:59:33 -0600
commita385734bc948b6cae6c5dd9a5fc48abaca4a040f (patch)
tree00eac4714c36543d68eb32ce5d41f570af7e5501
parentbd3e75e68779b36186fb85a61b726b71a178e96f (diff)
all engines running and stable
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--hostname.go92
-rw-r--r--linuxstatus/draw.go2
-rw-r--r--linuxstatus/hostname.go8
-rw-r--r--net.go92
-rw-r--r--nsupdate.go2
5 files changed, 10 insertions, 186 deletions
diff --git a/hostname.go b/hostname.go
deleted file mode 100644
index 9ca821f..0000000
--- a/hostname.go
+++ /dev/null
@@ -1,92 +0,0 @@
-// figures out if your hostname is valid
-// then checks if your DNS is setup correctly
-package main
-
-import (
- "strings"
-
- "go.wit.com/log"
- "go.wit.com/shell"
-// "go.wit.com/gui/cloudflare"
-
- "github.com/miekg/dns"
- // will try to get this hosts FQDN
- "github.com/Showmax/go-fqdn"
-)
-
-func getHostname() {
- var err error
- var s string = "gui.Label == nil"
- s, err = fqdn.FqdnHostname()
- if (err != nil) {
- log.Error(err, "FQDN hostname error")
- return
- }
- me.status.SetHostname(s)
-
- dn := run("domainname")
- hshort := run("hostname -s")
-
- var test string
- test = hshort + "." + dn
- if (me.status.GetHostname() != test) {
- log.Log(CHANGE, "me.hostname", me.status.GetHostname(), "does not equal", test)
- if (me.hostnameStatus.S != "BROKEN") {
- log.Log(CHANGE, "me.hostname", me.status.GetHostname(), "does not equal", test)
- me.changed = true
- me.hostnameStatus.SetText("BROKEN")
- }
- } else {
- if (me.hostnameStatus.S != "VALID") {
- log.Log(CHANGE, "me.hostname", me.status.GetHostname(), "is valid")
- me.hostnameStatus.SetText("VALID")
- me.changed = true
- }
- }
-}
-
-// returns true if the hostname is good
-// check that all the OS settings are correct here
-// On Linux, /etc/hosts, /etc/hostname
-// and domainname and hostname
-func goodHostname() bool {
- hostname := shell.Chomp(shell.Cat("/etc/hostname"))
- log.Log(NOW, "hostname =", hostname)
-
- hs := run("hostname -s")
- dn := run("domainname")
- log.Log(NOW, "hostname short =", hs, "domainname =", dn)
-
- tmp := hs + "." + dn
- if (hostname == tmp) {
- log.Log(NOW, "hostname seems to be good", hostname)
- return true
- }
-
- return false
-}
-
-func digAAAA(hostname string) []string {
- var blah, ipv6Addresses []string
- // domain := hostname
- recordType := dns.TypeAAAA // dns.TypeTXT
-
- // Cloudflare's DNS server
- blah, _ = dnsUdpLookup("1.1.1.1:53", hostname, recordType)
- log.Println("digAAAA() has BLAH =", blah)
-
- if (len(blah) == 0) {
- log.Println("digAAAA() RUNNING dnsAAAAlookupDoH(domain)")
- ipv6Addresses = lookupDoH(hostname, "AAAA")
- log.Println("digAAAA() has ipv6Addresses =", strings.Join(ipv6Addresses, " "))
- for _, addr := range ipv6Addresses {
- log.Println(addr)
- }
- return ipv6Addresses
- }
-
- // TODO: check digDoH vs blah, if so, then port 53 TCP and/or UDP is broken or blocked
- log.Println("digAAAA() has BLAH =", blah)
-
- return blah
-}
diff --git a/linuxstatus/draw.go b/linuxstatus/draw.go
index 91e0a6a..5b76b49 100644
--- a/linuxstatus/draw.go
+++ b/linuxstatus/draw.go
@@ -9,7 +9,7 @@ import (
// it's assumed you are always passing in a box
func draw(ls *LinuxStatus) {
if ! ls.Ready() {return}
- ls.group = ls.window.Box().NewGroup("What Linux Says It Is")
+ ls.group = ls.window.Box().NewGroup("What Linux Knows It Is")
ls.grid = ls.group.NewGrid("gridnuts", 2, 2)
diff --git a/linuxstatus/hostname.go b/linuxstatus/hostname.go
index 58f84b2..e9ac5f4 100644
--- a/linuxstatus/hostname.go
+++ b/linuxstatus/hostname.go
@@ -31,6 +31,14 @@ func (ls *LinuxStatus) GetHostname() string {
return me.hostname.Get()
}
+func (ls *LinuxStatus) ValidHostname() bool {
+ if ! me.Ready() {return false}
+ if me.hostnameStatus.Get() == "VALID" {
+ return true
+ }
+ return false
+}
+
func (ls *LinuxStatus) setHostname(newname string) {
if ! me.Ready() {return}
if newname == me.hostname.Get() {
diff --git a/net.go b/net.go
index cd988d1..a3ebefd 100644
--- a/net.go
+++ b/net.go
@@ -9,35 +9,6 @@ import (
"go.wit.com/log"
)
-// this doesn't work
-/*
-func watchNetworkInterfaces() {
- // Get list of network interfaces
- interfaces, _ := net.Interfaces()
-
- // Set up a notification channel
- notification := make(chan net.Interface)
-
- log.Log(NET, "watchNet()")
- // Start goroutine to watch for changes
- go func() {
- log.Log(NET, "watchNet() func")
- for {
- log.Log(NET, "forever loop start")
- // Check for changes in each interface
- for _, i := range interfaces {
- log.Log(NET, "something on i =", i)
- if status := i.Flags & net.FlagUp; status != 0 {
- notification <- i
- log.Log(NET, "something on i =", i)
- }
- }
- log.Log(NET, "forever loop end")
- }
- }()
-}
-*/
-
func IsIPv6(address string) bool {
return strings.Count(address, ":") >= 2
}
@@ -62,43 +33,6 @@ func IsReal(ip *net.IP) bool {
}
}
-func renameInterface(i *net.Interface) {
- /*
- /sbin/ip link set eth1 down
- /sbin/ip link set eth1 name eth123
- /sbin/ip link set eth123 up
- */
-}
-
-// Will figure out if an interface was just added
-func checkInterface(i net.Interface) {
- val, ok := me.ifmap[i.Index]
- if ! ok {
- log.Info(i.Name, "is a new network interface. The linux kernel index =", i.Index)
- me.ifmap[i.Index] = new(IFtype)
- me.ifmap[i.Index].gone = false
- me.ifmap[i.Index].iface = &i
- me.changed = true
- if (me.Interfaces != nil) {
- me.Interfaces.AddText(i.Name)
- me.Interfaces.SetText(i.Name)
- }
- return
- }
- me.ifmap[i.Index].gone = false
- log.Log(NET, "me.ifmap[i] does exist. Need to compare everything.", i.Index, i.Name, val.iface.Index, val.iface.Name)
- if (val.iface.Name != i.Name) {
- log.Info(val.iface.Name, "has changed to it's name to", i.Name)
- me.ifmap[i.Index].iface = &i
- me.changed = true
- if (me.Interfaces != nil) {
- me.Interfaces.AddText(i.Name)
- me.Interfaces.SetText(i.Name)
- }
- return
- }
-}
-
/*
These are the real IP address you have been
given from DHCP
@@ -155,29 +89,3 @@ func checkDNS() (map[string]*IPtype, map[string]*IPtype) {
}
return ipv6s, ipv4s
}
-
-// delete network interfaces and ip addresses from the gui
-func deleteChanges2() bool {
- var changed bool = false
- for i, t := range me.ifmap {
- if (t.gone) {
- log.Log(CHANGE, "DELETE int =", i, "name =", t.name, t.iface)
- delete(me.ifmap, i)
- changed = true
- }
- t.gone = true
- }
- for s, t := range me.ipmap {
- if (t.gone) {
- log.Log(CHANGE, "DELETE name =", s, "IPv4 =", t.ipv4)
- log.Log(CHANGE, "DELETE name =", s, "IPv6 =", t.ipv6)
- log.Log(CHANGE, "DELETE name =", s, "iface =", t.iface)
- log.Log(CHANGE, "DELETE name =", s, "ip =", t.ip)
- delete(me.ipmap, s)
- changed = true
- }
- t.gone = true
- }
-
- return changed
-}
diff --git a/nsupdate.go b/nsupdate.go
index 2757b75..add2c94 100644
--- a/nsupdate.go
+++ b/nsupdate.go
@@ -22,7 +22,7 @@ func nsupdate() {
cmd := "go-nsupdate --tsig-algorithm=hmac-sha512"
tsigSecret = os.Getenv("TIG_SECRET")
cmd += " --tig-secret=\"" + tsigSecret + "\""
- cmd += " -i wlo1 " + me.status.GetHostname()
+ cmd += " -i wlo1 " + me.statusOS.GetHostname()
log.Log(NET, "nsupdate() RUN:", cmd)
for s, t := range me.ipmap {