window titles update to correct values
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
930bdc941b
commit
807b3be94f
|
@ -245,6 +245,14 @@ func (ds *digStatus) updateDnsStatus() {
|
||||||
out = shell.Run(cmd)
|
out = shell.Run(cmd)
|
||||||
log.Log(DNS, "makeDnsStatusGrid() dig", out)
|
log.Log(DNS, "makeDnsStatusGrid() dig", out)
|
||||||
me.digStatus.set(ds.DnsDigTCP, out)
|
me.digStatus.set(ds.DnsDigTCP, out)
|
||||||
|
|
||||||
|
/*
|
||||||
|
g2.NewButton("dig +trace", func () {
|
||||||
|
log.Log(NOW, "TODO: redo this")
|
||||||
|
// o := shell.Run("dig +trace +noadditional DS " + me.hostname + " @8.8.8.8")
|
||||||
|
// log.Println(o)
|
||||||
|
})
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ds *digStatus) makeHttpStatusGrid() {
|
func (ds *digStatus) makeHttpStatusGrid() {
|
||||||
|
|
19
gui.go
19
gui.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ import (
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/gui/gadgets"
|
||||||
"go.wit.com/gui/cloudflare"
|
"go.wit.com/gui/cloudflare"
|
||||||
"go.wit.com/gui/debugger"
|
"go.wit.com/gui/debugger"
|
||||||
"go.wit.com/control-panels/dns/linuxstatus"
|
// "go.wit.com/control-panels/dns/linuxstatus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This setups up the dns control panel window
|
// This setups up the dns control panel window
|
||||||
|
@ -43,17 +44,6 @@ func debugTab(title string) {
|
||||||
updateDNS()
|
updateDNS()
|
||||||
})
|
})
|
||||||
|
|
||||||
g2.NewButton("dig +trace", func () {
|
|
||||||
log.Log(NOW, "TODO: redo this")
|
|
||||||
// o := shell.Run("dig +trace +noadditional DS " + me.hostname + " @8.8.8.8")
|
|
||||||
// log.Println(o)
|
|
||||||
})
|
|
||||||
|
|
||||||
g2.NewButton("getProcessNameByPort()", func () {
|
|
||||||
processName := linuxstatus.GetProcessNameByPort(53)
|
|
||||||
log.Info("Process with port 53:", processName)
|
|
||||||
})
|
|
||||||
|
|
||||||
g2 = me.debug.Box().NewGroup("debugging options")
|
g2 = me.debug.Box().NewGroup("debugging options")
|
||||||
|
|
||||||
// makes a slider widget
|
// makes a slider widget
|
||||||
|
@ -93,7 +83,8 @@ func displayDNS() string {
|
||||||
|
|
||||||
var a []string
|
var a []string
|
||||||
a = append(a, "fixme")
|
a = append(a, "fixme")
|
||||||
all = sortLines(strings.Join(a, "\n"))
|
sort.Strings(a)
|
||||||
|
all = strings.Join(a, "\n")
|
||||||
if (all == "") {
|
if (all == "") {
|
||||||
log.Log(NOW, "THERE IS NOT a real A DNS ENTRY")
|
log.Log(NOW, "THERE IS NOT a real A DNS ENTRY")
|
||||||
all = "CNAME ipv6.wit.com"
|
all = "CNAME ipv6.wit.com"
|
||||||
|
@ -145,7 +136,7 @@ func mainWindow(title string) {
|
||||||
statusGrid(me.window.Box())
|
statusGrid(me.window.Box())
|
||||||
|
|
||||||
gr = me.window.Box().NewGroup("debugging")
|
gr = me.window.Box().NewGroup("debugging")
|
||||||
gr.NewButton("hostname status", func () {
|
me.statusDNSbutton = gr.NewButton("hostname status", func () {
|
||||||
if ! me.statusDNS.Ready() {return}
|
if ! me.statusDNS.Ready() {return}
|
||||||
me.statusDNS.window.Toggle()
|
me.statusDNS.window.Toggle()
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sort"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -22,7 +23,6 @@ type hostnameStatus struct {
|
||||||
ready bool
|
ready bool
|
||||||
hidden bool
|
hidden bool
|
||||||
|
|
||||||
// hostname string // my hostname. Example: "test.wit.com"
|
|
||||||
lastname string // used to watch for changes in the hostname
|
lastname string // used to watch for changes in the hostname
|
||||||
|
|
||||||
window *gadgets.BasicWindow
|
window *gadgets.BasicWindow
|
||||||
|
@ -33,14 +33,12 @@ type hostnameStatus struct {
|
||||||
statusIPv4 *gadgets.OneLiner
|
statusIPv4 *gadgets.OneLiner
|
||||||
statusIPv6 *gadgets.OneLiner
|
statusIPv6 *gadgets.OneLiner
|
||||||
|
|
||||||
// Details Group
|
hostname *gadgets.OneLiner
|
||||||
hostShort *gadgets.OneLiner
|
|
||||||
domainname *gadgets.OneLiner
|
domainname *gadgets.OneLiner
|
||||||
|
|
||||||
// what the current IP address your network has given you
|
// what the current IP addresses your network has given you
|
||||||
currentIPv4 *gadgets.OneLiner
|
currentIPv4 *gadgets.OneLiner
|
||||||
currentIPv6 *gadgets.OneLiner
|
currentIPv6 *gadgets.OneLiner
|
||||||
currentAAAA string
|
|
||||||
|
|
||||||
// what the DNS servers have
|
// what the DNS servers have
|
||||||
NSrr *gadgets.OneLiner
|
NSrr *gadgets.OneLiner
|
||||||
|
@ -81,7 +79,7 @@ func NewHostnameStatusWindow(p *gui.Node) *hostnameStatus {
|
||||||
group = hs.window.Box().NewGroup("Details")
|
group = hs.window.Box().NewGroup("Details")
|
||||||
grid = group.NewGrid("LookupDetails", 2, 2)
|
grid = group.NewGrid("LookupDetails", 2, 2)
|
||||||
|
|
||||||
hs.hostShort = gadgets.NewOneLiner(grid, "hostname -s")
|
hs.hostname = gadgets.NewOneLiner(grid, "hostname")
|
||||||
hs.domainname = gadgets.NewOneLiner(grid, "domain name")
|
hs.domainname = gadgets.NewOneLiner(grid, "domain name")
|
||||||
hs.currentIPv4 = gadgets.NewOneLiner(grid, "Current IPv4")
|
hs.currentIPv4 = gadgets.NewOneLiner(grid, "Current IPv4")
|
||||||
hs.currentIPv6 = gadgets.NewOneLiner(grid, "Current IPv6")
|
hs.currentIPv6 = gadgets.NewOneLiner(grid, "Current IPv6")
|
||||||
|
@ -121,12 +119,6 @@ func NewHostnameStatusWindow(p *gui.Node) *hostnameStatus {
|
||||||
return hs
|
return hs
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func (hs *hostnameStatus) ValidHostname() bool {
|
|
||||||
return goodHostname()
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (hs *hostnameStatus) Domain() string {
|
func (hs *hostnameStatus) Domain() string {
|
||||||
if ! hs.Ready() {return ""}
|
if ! hs.Ready() {return ""}
|
||||||
return hs.domainname.Get()
|
return hs.domainname.Get()
|
||||||
|
@ -137,34 +129,6 @@ func (hs *hostnameStatus) API() string {
|
||||||
return hs.dnsAPI.Get()
|
return hs.dnsAPI.Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func (hs *hostnameStatus) deleteDNSrecord(value string) bool {
|
|
||||||
log.Info("deleteDNSrecord() START for", value)
|
|
||||||
log.Info("deleteDNSrecord() hostname =", me.status.GetHostname())
|
|
||||||
log.Info("deleteDNSrecord() domain =", hs.Domain())
|
|
||||||
log.Info("deleteDNSrecord() DNS API Provider =", hs.API())
|
|
||||||
|
|
||||||
if (hs.API() == "cloudflare") {
|
|
||||||
log.Info("deleteDNSrecord() Try to delete via cloudflare")
|
|
||||||
return cloudflare.Delete(hs.Domain(), me.status.GetHostname(), value)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (hs *hostnameStatus) createDNSrecord(value string) bool {
|
|
||||||
log.Info("createDNSrecord() START for", value)
|
|
||||||
log.Info("createDNSrecord() hostname =", me.status.GetHostname())
|
|
||||||
log.Info("createDNSrecord() domain =", hs.Domain())
|
|
||||||
log.Info("createDNSrecord() DNS API Provider =", hs.API())
|
|
||||||
|
|
||||||
if (hs.API() == "cloudflare") {
|
|
||||||
log.Warn("createDNSrecord() Try to create via cloudflare:", me.status.GetHostname(), value)
|
|
||||||
return cloudflare.Create(hs.Domain(), me.status.GetHostname(), value)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (hs *hostnameStatus) Update() {
|
func (hs *hostnameStatus) Update() {
|
||||||
log.Info("hostnameStatus() Update() START")
|
log.Info("hostnameStatus() Update() START")
|
||||||
if hs == nil {
|
if hs == nil {
|
||||||
|
@ -282,7 +246,7 @@ func (hs *hostnameStatus) missingAAAA() bool {
|
||||||
|
|
||||||
func (hs *hostnameStatus) GetIPv6() []string {
|
func (hs *hostnameStatus) GetIPv6() []string {
|
||||||
if ! hs.Ready() { return nil}
|
if ! hs.Ready() { return nil}
|
||||||
return strings.Split(hs.currentAAAA, "\n")
|
return strings.Split(hs.dnsAAAA.Get(), "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *hostnameStatus) updateStatus() {
|
func (hs *hostnameStatus) updateStatus() {
|
||||||
|
@ -291,9 +255,27 @@ func (hs *hostnameStatus) updateStatus() {
|
||||||
var vals []string
|
var vals []string
|
||||||
log.Log(STATUS, "updateStatus() START")
|
log.Log(STATUS, "updateStatus() START")
|
||||||
|
|
||||||
hs.hostShort.Set(me.statusOS.GetHostShort())
|
// copy the OS status over
|
||||||
|
lasthostname := hs.hostname.Get()
|
||||||
|
hostname := me.statusOS.GetHostname()
|
||||||
|
|
||||||
|
// hostname changed or was setup for the first time. Set the window title, etc
|
||||||
|
if lasthostname != hostname {
|
||||||
|
me.changed = true
|
||||||
|
hs.hostname.Set(hostname)
|
||||||
|
hs.window.Title(hostname + " Status")
|
||||||
|
me.statusDNSbutton.Set(hostname + " status")
|
||||||
|
}
|
||||||
hs.domainname.Set(me.statusOS.GetDomainName())
|
hs.domainname.Set(me.statusOS.GetDomainName())
|
||||||
|
|
||||||
|
tmp := me.statusOS.GetIPv4()
|
||||||
|
sort.Strings(tmp)
|
||||||
|
hs.currentIPv4.Set(strings.Join(tmp, "\n"))
|
||||||
|
|
||||||
|
tmp = me.statusOS.GetIPv6()
|
||||||
|
sort.Strings(tmp)
|
||||||
|
hs.currentIPv6.Set(strings.Join(tmp, "\n"))
|
||||||
|
|
||||||
if me.statusOS.ValidHostname() {
|
if me.statusOS.ValidHostname() {
|
||||||
vals = lookupDoH(me.statusOS.GetHostname(), "AAAA")
|
vals = lookupDoH(me.statusOS.GetHostname(), "AAAA")
|
||||||
|
|
||||||
|
@ -315,7 +297,8 @@ func (hs *hostnameStatus) updateStatus() {
|
||||||
// hs.dnsAction.SetText("DELETE")
|
// hs.dnsAction.SetText("DELETE")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hs.currentAAAA = strings.Join(vals, "\n")
|
sort.Strings(vals)
|
||||||
|
hs.dnsAAAA.Set(strings.Join(vals, "\n"))
|
||||||
|
|
||||||
vals = lookupDoH(me.statusOS.GetHostname(), "A")
|
vals = lookupDoH(me.statusOS.GetHostname(), "A")
|
||||||
log.Log(STATUS, "IPv4 Addresses for ", me.statusOS.GetHostname(), "=", vals)
|
log.Log(STATUS, "IPv4 Addresses for ", me.statusOS.GetHostname(), "=", vals)
|
||||||
|
@ -334,11 +317,6 @@ func (hs *hostnameStatus) updateStatus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hs.currentIPv4.Set(me.IPv4.S)
|
|
||||||
// hs.currentIPv6.Set(me.IPv6.S)
|
|
||||||
hs.currentIPv4.Set("get this from linuxStatus")
|
|
||||||
hs.currentIPv6.Set("get this from linuxStatus")
|
|
||||||
|
|
||||||
if hs.IPv4() && hs.IPv6() {
|
if hs.IPv4() && hs.IPv6() {
|
||||||
hs.status.Set("GOOD")
|
hs.status.Set("GOOD")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,6 +24,7 @@ func draw(ls *LinuxStatus) {
|
||||||
ls.uid = gadgets.NewOneLiner(ls.grid, "UID =")
|
ls.uid = gadgets.NewOneLiner(ls.grid, "UID =")
|
||||||
ls.IPv4 = gadgets.NewOneLiner(ls.grid, "Current IPv4 =")
|
ls.IPv4 = gadgets.NewOneLiner(ls.grid, "Current IPv4 =")
|
||||||
ls.IPv6 = gadgets.NewOneLiner(ls.grid, "Current IPv6 =")
|
ls.IPv6 = gadgets.NewOneLiner(ls.grid, "Current IPv6 =")
|
||||||
|
ls.workingIPv4 = gadgets.NewOneLiner(ls.grid, "Real IPv4 =")
|
||||||
ls.workingIPv6 = gadgets.NewOneLiner(ls.grid, "Real IPv6 =")
|
ls.workingIPv6 = gadgets.NewOneLiner(ls.grid, "Real IPv6 =")
|
||||||
// ls.nics = gadgets.NewOneLiner(ls.grid, "network intefaces =")
|
// ls.nics = gadgets.NewOneLiner(ls.grid, "network intefaces =")
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"io/ioutil"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/shell"
|
|
||||||
|
|
||||||
// will try to get this hosts FQDN
|
// will try to get this hosts FQDN
|
||||||
"github.com/Showmax/go-fqdn"
|
"github.com/Showmax/go-fqdn"
|
||||||
|
@ -124,7 +124,14 @@ func lookupHostname() {
|
||||||
// On Linux, /etc/hosts, /etc/hostname
|
// On Linux, /etc/hosts, /etc/hostname
|
||||||
// and domainname and hostname
|
// and domainname and hostname
|
||||||
func goodHostname() bool {
|
func goodHostname() bool {
|
||||||
hostname := shell.Chomp(shell.Cat("/etc/hostname"))
|
content, err := ioutil.ReadFile("/etc/hostname")
|
||||||
|
if err != nil {
|
||||||
|
// this needs to be a fixWindow() error
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
hostname := string(content)
|
||||||
|
|
||||||
log.Log(NOW, "hostname =", hostname)
|
log.Log(NOW, "hostname =", hostname)
|
||||||
|
|
||||||
hs := run("hostname -s")
|
hs := run("hostname -s")
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
// GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
|
// GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
|
||||||
// Copyright (c) 2023 WIT.COM, Inc.
|
// Copyright (c) 2023 WIT.COM, Inc.
|
||||||
|
|
||||||
// This is a control panel for DNS
|
// This is a control panel for DNS
|
||||||
|
|
||||||
|
// This is the main Linux kernel / OS code
|
||||||
|
// to check your network settings are correct
|
||||||
|
// This does (and should do) no network or external checking
|
||||||
|
// This is just the state of your OS
|
||||||
|
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -9,30 +15,55 @@ import (
|
||||||
"os/user"
|
"os/user"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func linuxLoop() {
|
func linuxLoop() {
|
||||||
me.changed = false
|
me.changed = false
|
||||||
duration := timeFunction(lookupHostname)
|
|
||||||
log.Log(INFO, "getHostname() execution Time: ", duration, "me.changed =", me.changed)
|
|
||||||
|
|
||||||
duration = timeFunction(scanInterfaces)
|
// checks for a VALID hostname
|
||||||
log.Log(NET, "scanInterfaces() execution Time: ", duration)
|
lookupHostname()
|
||||||
|
if me.changed {
|
||||||
|
log.Log(CHANGE, "lookupHostname() detected a change")
|
||||||
|
}
|
||||||
|
|
||||||
|
// scans the linux network intefaces for your available IPv4 & IPv6 addresses
|
||||||
|
scanInterfaces()
|
||||||
|
if me.changed {
|
||||||
|
log.Log(CHANGE, "scanInterfaces() detected a change")
|
||||||
|
}
|
||||||
for i, t := range me.ifmap {
|
for i, t := range me.ifmap {
|
||||||
log.Log(NET, strconv.Itoa(i) + " iface = " + t.iface.Name)
|
log.Log(NET, strconv.Itoa(i) + " iface = " + t.iface.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get all the real A records from all the network interfaces linux can see
|
||||||
|
a := realA()
|
||||||
|
sort.Strings(a)
|
||||||
|
tmp := strings.Join(a, "\n")
|
||||||
|
if tmp != me.workingIPv4.Get() {
|
||||||
|
log.Log(CHANGE, "realAAAA() your real IPv6 addresses changed")
|
||||||
|
me.changed = true
|
||||||
|
me.workingIPv4.Set(tmp)
|
||||||
|
}
|
||||||
|
|
||||||
// get all the real AAAA records from all the network interfaces linux can see
|
// get all the real AAAA records from all the network interfaces linux can see
|
||||||
tmp := strings.Join(realAAAA(), "\n")
|
aaaa := realAAAA()
|
||||||
tmp = sortLines(tmp)
|
sort.Strings(aaaa)
|
||||||
me.workingIPv6.Set(tmp)
|
tmp = strings.Join(aaaa, "\n")
|
||||||
|
if tmp != me.workingIPv6.Get() {
|
||||||
|
log.Log(CHANGE, "realAAAA() your real IPv6 addresses changed")
|
||||||
|
me.changed = true
|
||||||
|
me.workingIPv6.Set(tmp)
|
||||||
|
}
|
||||||
|
|
||||||
user, _ := user.Current()
|
user, _ := user.Current()
|
||||||
log.Log(INFO, "os.Getuid =", user.Username, os.Getuid())
|
tmp = user.Username + " (" + strconv.Itoa(os.Getuid()) + ")"
|
||||||
if (me.uid != nil) {
|
if tmp != me.uid.Get() {
|
||||||
me.uid.Set(user.Username + " (" + strconv.Itoa(os.Getuid()) + ")")
|
log.Log(CHANGE, "os.Getuid =", user.Username, os.Getuid())
|
||||||
|
me.changed = true
|
||||||
|
me.uid.Set(tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -269,3 +269,10 @@ func deleteChanges() bool {
|
||||||
|
|
||||||
return changed
|
return changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ls *LinuxStatus) GetIPv4() []string {
|
||||||
|
if ! me.Ready() {return nil}
|
||||||
|
tmp := "(none) fixme"
|
||||||
|
return strings.Split(tmp, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ type LinuxStatus struct {
|
||||||
uid *gadgets.OneLiner
|
uid *gadgets.OneLiner
|
||||||
IPv4 *gadgets.OneLiner
|
IPv4 *gadgets.OneLiner
|
||||||
IPv6 *gadgets.OneLiner
|
IPv6 *gadgets.OneLiner
|
||||||
|
workingIPv4 *gadgets.OneLiner
|
||||||
workingIPv6 *gadgets.OneLiner
|
workingIPv6 *gadgets.OneLiner
|
||||||
Interfaces *gui.Node
|
Interfaces *gui.Node
|
||||||
speed *gadgets.OneLiner
|
speed *gadgets.OneLiner
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/shell"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func CheckSuperuser() bool {
|
func CheckSuperuser() bool {
|
||||||
|
@ -89,7 +88,8 @@ func run(s string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp := shell.Chomp(out.String())
|
// Trim leading and trailing whitespace from each line
|
||||||
|
tmp := strings.TrimSpace(out.String())
|
||||||
// Output the results
|
// Output the results
|
||||||
log.Info("Command Output:", tmp)
|
log.Info("Command Output:", tmp)
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ type Host struct {
|
||||||
|
|
||||||
statusIPv6 *gadgets.OneLiner
|
statusIPv6 *gadgets.OneLiner
|
||||||
digStatusButton *gui.Node
|
digStatusButton *gui.Node
|
||||||
|
statusDNSbutton *gui.Node
|
||||||
witcom *gadgets.BasicWindow
|
witcom *gadgets.BasicWindow
|
||||||
fixButton *gui.Node
|
fixButton *gui.Node
|
||||||
fixWindow *smartwindow.SmartWindow
|
fixWindow *smartwindow.SmartWindow
|
||||||
|
|
Loading…
Reference in New Issue