all engines running and stable
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
983517732d
commit
15d9f97693
|
@ -207,8 +207,8 @@ func (ds *digStatus) updateDnsStatus() {
|
|||
ipv4, ipv6 = ds.dsCloudflare.update()
|
||||
ipv4, ipv6 = ds.dsGoogle.update()
|
||||
|
||||
if me.status.ValidHostname() {
|
||||
if ds.checkLookupDoH(me.status.GetHostname()) {
|
||||
if me.statusOS.ValidHostname() {
|
||||
if ds.checkLookupDoH(me.statusOS.GetHostname()) {
|
||||
log.Log(DNS, "updateDnsStatus() HTTP DNS lookups working")
|
||||
me.digStatus.set(ds.statusHTTP, "WORKING")
|
||||
} else {
|
||||
|
|
30
dns-https.go
30
dns-https.go
|
@ -2,10 +2,13 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"go.wit.com/log"
|
||||
"strings"
|
||||
"io/ioutil"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"go.wit.com/log"
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// dnsLookupDoH performs a DNS lookup for AAAA records over HTTPS.
|
||||
|
@ -54,3 +57,28 @@ func lookupDoH(hostname string, rrType string) []string {
|
|||
|
||||
return values
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
6
fix.go
6
fix.go
|
@ -11,10 +11,10 @@ func fix() bool {
|
|||
log.Warn("The IPv6 Control Panel is not Ready() yet")
|
||||
return false
|
||||
}
|
||||
if me.status.ValidHostname() {
|
||||
log.Warn("Your hostname is VALID:", me.status.GetHostname())
|
||||
if me.statusOS.ValidHostname() {
|
||||
log.Warn("Your hostname is VALID:", me.statusOS.GetHostname())
|
||||
} else {
|
||||
log.Warn("You must first fix your hostname:", me.status.GetHostname())
|
||||
log.Warn("You must first fix your hostname:", me.statusOS.GetHostname())
|
||||
return false
|
||||
}
|
||||
if me.digStatus.IPv4() {
|
||||
|
|
12
gui.go
12
gui.go
|
@ -38,10 +38,6 @@ func debugTab(title string) {
|
|||
debugger.DebugWindow(me.myGui)
|
||||
})
|
||||
|
||||
g2.NewButton("getHostname() looks at the OS settings", func () {
|
||||
getHostname()
|
||||
})
|
||||
|
||||
g2.NewButton("dig A & AAAA DNS records", func () {
|
||||
log.Println("updateDNS()")
|
||||
updateDNS()
|
||||
|
@ -146,9 +142,7 @@ func mainWindow(title string) {
|
|||
|
||||
grid.SetNext(1,1)
|
||||
|
||||
grid.NewLabel("hostname =")
|
||||
me.fqdn = grid.NewLabel("?")
|
||||
|
||||
me.hostname = gadgets.NewOneLiner(grid, "hostname =").Set("unknown")
|
||||
me.DnsAAAA = gadgets.NewOneLiner(grid, "DNS AAAA =").Set("unknown")
|
||||
|
||||
grid.NewLabel("DNS A =")
|
||||
|
@ -253,9 +247,9 @@ func updateDNS() {
|
|||
|
||||
// log.Println("digAAAA()")
|
||||
|
||||
if me.status.ValidHostname() {
|
||||
if me.statusOS.ValidHostname() {
|
||||
var aaaa []string
|
||||
h := me.status.GetHostname()
|
||||
h := me.statusOS.GetHostname()
|
||||
aaaa = digAAAA(h)
|
||||
log.Log(NOW, "digAAAA() for", h, "=", aaaa)
|
||||
|
||||
|
|
92
hostname.go
92
hostname.go
|
@ -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
|
||||
}
|
|
@ -120,24 +120,11 @@ func NewHostnameStatusWindow(p *gui.Node) *hostnameStatus {
|
|||
return hs
|
||||
}
|
||||
|
||||
/*
|
||||
func (hs *hostnameStatus) ValidHostname() bool {
|
||||
return goodHostname()
|
||||
}
|
||||
|
||||
func (hs *hostnameStatus) GetHostname() string {
|
||||
return hs.lastname
|
||||
}
|
||||
|
||||
func (hs *hostnameStatus) SetHostname(hostname string) {
|
||||
if hostname == hs.lastname {return}
|
||||
log.Log(CHANGE, "the hostname is changing from", hs.lastname, "to", hostname)
|
||||
hs.lastname = hostname
|
||||
me.changed = true
|
||||
|
||||
if (me.fqdn != nil) {
|
||||
me.fqdn.SetText(hostname)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func (hs *hostnameStatus) Domain() string {
|
||||
if ! hs.Ready() {return ""}
|
||||
|
@ -301,10 +288,10 @@ func (hs *hostnameStatus) updateStatus() {
|
|||
hs.hostShort.Set(me.statusOS.GetHostShort())
|
||||
hs.domainname.Set(me.statusOS.GetDomainName())
|
||||
|
||||
if hs.ValidHostname() {
|
||||
vals = lookupDoH(hs.GetHostname(), "AAAA")
|
||||
if me.statusOS.ValidHostname() {
|
||||
vals = lookupDoH(me.statusOS.GetHostname(), "AAAA")
|
||||
|
||||
log.Log(STATUS, "DNS IPv6 Addresses for ", hs.GetHostname(), "=", vals)
|
||||
log.Log(STATUS, "DNS IPv6 Addresses for ", me.statusOS.GetHostname(), "=", vals)
|
||||
if len(vals) == 0 {
|
||||
s = "(none)"
|
||||
} else {
|
||||
|
@ -324,8 +311,8 @@ func (hs *hostnameStatus) updateStatus() {
|
|||
}
|
||||
hs.set(hs.dnsAAAA, s)
|
||||
|
||||
vals = lookupDoH(hs.GetHostname(), "A")
|
||||
log.Log(STATUS, "IPv4 Addresses for ", hs.GetHostname(), "=", vals)
|
||||
vals = lookupDoH(me.statusOS.GetHostname(), "A")
|
||||
log.Log(STATUS, "IPv4 Addresses for ", me.statusOS.GetHostname(), "=", vals)
|
||||
s = strings.Join(vals, "\n")
|
||||
if (s == "") {
|
||||
s = "(none)"
|
||||
|
@ -333,7 +320,7 @@ func (hs *hostnameStatus) updateStatus() {
|
|||
}
|
||||
hs.set(hs.dnsA, s)
|
||||
|
||||
vals = lookupDoH(hs.GetHostname(), "CNAME")
|
||||
vals = lookupDoH(me.statusOS.GetHostname(), "CNAME")
|
||||
s = strings.Join(vals, "\n")
|
||||
if (s != "") {
|
||||
hs.set(hs.dnsA, "CNAME " + s)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
92
net.go
92
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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
15
structs.go
15
structs.go
|
@ -19,9 +19,7 @@ type Host struct {
|
|||
statusOS *linuxstatus.LinuxStatus // what the Linux OS sees
|
||||
|
||||
hostnameStatus *gui.Node // a summary for the user of where things are
|
||||
|
||||
// domainname *gui.Node // kernel.org
|
||||
hostshort *gui.Node // hostname -s
|
||||
hostname *gadgets.OneLiner // the hostname grabbed from gadget.linuxStatus
|
||||
|
||||
artificialSleep float64 `default:"0.7"` // artificial sleep on startup
|
||||
artificialS string `default:"abc"` // artificial sleep on startup
|
||||
|
@ -50,18 +48,13 @@ type Host struct {
|
|||
notes *gui.Node // using this to put notes here
|
||||
|
||||
// local OS settings, network interfaces, etc
|
||||
// uid *gui.Node // user
|
||||
fqdn *gui.Node // display the full hostname
|
||||
// IPv4 *gui.Node // show valid IPv4 addresses
|
||||
// IPv6 *gui.Node // show valid IPv6 addresses
|
||||
Interfaces *gui.Node // Interfaces
|
||||
LocalSpeedActual *gui.Node // the time it takes to check each network interface
|
||||
// fqdn *gui.Node // display the full hostname
|
||||
// Interfaces *gui.Node // Interfaces
|
||||
// LocalSpeedActual *gui.Node // the time it takes to check each network interface
|
||||
|
||||
// DNS stuff
|
||||
// NSrr *gui.Node // NS resource records for the domain name
|
||||
DnsAPI *gui.Node // what DNS API to use?
|
||||
DnsAAAA *gadgets.OneLiner // the actual DNS AAAA results
|
||||
// workingIPv6 *gui.Node // currently working AAAA
|
||||
DnsA *gui.Node // the actual DNS A results (ignore for status since mostly never happens?)
|
||||
DnsStatus *gui.Node // the current state of DNS
|
||||
DnsSpeed *gui.Node // 'FAST', 'OK', 'SLOW', etc
|
||||
|
|
Loading…
Reference in New Issue