all engines running and stable

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-06 16:59:33 -06:00
parent bd3e75e687
commit a385734bc9
5 changed files with 10 additions and 186 deletions

View File

@ -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
}

View File

@ -9,7 +9,7 @@ import (
// it's assumed you are always passing in a box // it's assumed you are always passing in a box
func draw(ls *LinuxStatus) { func draw(ls *LinuxStatus) {
if ! ls.Ready() {return} 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) ls.grid = ls.group.NewGrid("gridnuts", 2, 2)

View File

@ -31,6 +31,14 @@ func (ls *LinuxStatus) GetHostname() string {
return me.hostname.Get() 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) { func (ls *LinuxStatus) setHostname(newname string) {
if ! me.Ready() {return} if ! me.Ready() {return}
if newname == me.hostname.Get() { if newname == me.hostname.Get() {

92
net.go
View File

@ -9,35 +9,6 @@ import (
"go.wit.com/log" "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 { func IsIPv6(address string) bool {
return strings.Count(address, ":") >= 2 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 These are the real IP address you have been
given from DHCP given from DHCP
@ -155,29 +89,3 @@ func checkDNS() (map[string]*IPtype, map[string]*IPtype) {
} }
return ipv6s, ipv4s 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
}

View File

@ -22,7 +22,7 @@ func nsupdate() {
cmd := "go-nsupdate --tsig-algorithm=hmac-sha512" cmd := "go-nsupdate --tsig-algorithm=hmac-sha512"
tsigSecret = os.Getenv("TIG_SECRET") tsigSecret = os.Getenv("TIG_SECRET")
cmd += " --tig-secret=\"" + tsigSecret + "\"" cmd += " --tig-secret=\"" + tsigSecret + "\""
cmd += " -i wlo1 " + me.status.GetHostname() cmd += " -i wlo1 " + me.statusOS.GetHostname()
log.Log(NET, "nsupdate() RUN:", cmd) log.Log(NET, "nsupdate() RUN:", cmd)
for s, t := range me.ipmap { for s, t := range me.ipmap {