old window is nearly deprecated
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
ba3d5a3cb2
commit
5dee2af784
4
dns.go
4
dns.go
|
@ -111,10 +111,10 @@ func lookupNS(domain string) {
|
||||||
}
|
}
|
||||||
tmp = shell.Chomp(tmp)
|
tmp = shell.Chomp(tmp)
|
||||||
|
|
||||||
if (tmp != me.NSrr.S) {
|
if (tmp != me.status.NSrr.Get()) {
|
||||||
me.changed = true
|
me.changed = true
|
||||||
log.Log(CHANGE, "lookupNS() setting me.NSrr =", tmp)
|
log.Log(CHANGE, "lookupNS() setting me.NSrr =", tmp)
|
||||||
me.NSrr.SetText(tmp)
|
me.status.NSrr.Set(tmp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
gui.go
15
gui.go
|
@ -47,19 +47,19 @@ func detailsTab(title string) {
|
||||||
grid.NewLabel("DEPRECATED")
|
grid.NewLabel("DEPRECATED")
|
||||||
|
|
||||||
grid.NewLabel("NS records =")
|
grid.NewLabel("NS records =")
|
||||||
me.NSrr = grid.NewLabel("NS RR's")
|
grid.NewLabel("DEPRECATED")
|
||||||
|
|
||||||
grid.NewLabel("UID =")
|
grid.NewLabel("UID =")
|
||||||
grid.NewLabel("DEPRECATED")
|
grid.NewLabel("DEPRECATED")
|
||||||
|
|
||||||
grid.NewLabel("Current IPv4 =")
|
grid.NewLabel("Current IPv4 =")
|
||||||
me.IPv4 = grid.NewLabel("?")
|
grid.NewLabel("DEPRECATED")
|
||||||
|
|
||||||
grid.NewLabel("Current IPv6 =")
|
grid.NewLabel("Current IPv6 =")
|
||||||
me.IPv6 = grid.NewLabel("?")
|
grid.NewLabel("DEPRECATED")
|
||||||
|
|
||||||
grid.NewLabel("Working Real IPv6 =")
|
grid.NewLabel("Working Real IPv6 =")
|
||||||
me.workingIPv6 = grid.NewLabel("?")
|
grid.NewLabel("?")
|
||||||
|
|
||||||
grid.NewLabel("interfaces =")
|
grid.NewLabel("interfaces =")
|
||||||
me.Interfaces = grid.NewCombobox("Interfaces")
|
me.Interfaces = grid.NewCombobox("Interfaces")
|
||||||
|
@ -150,7 +150,7 @@ func missingAAAA() string {
|
||||||
// it just updates the GUI
|
// it just updates the GUI
|
||||||
func displayDNS() string {
|
func displayDNS() string {
|
||||||
var aaaa []string
|
var aaaa []string
|
||||||
aaaa = dhcpAAAA() // your AAAA records right now
|
aaaa = append(aaaa, "blah", "more")
|
||||||
// h := me.hostname
|
// h := me.hostname
|
||||||
var all string
|
var all string
|
||||||
var broken string = "unknown"
|
var broken string = "unknown"
|
||||||
|
@ -166,11 +166,6 @@ func displayDNS() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
all = sortLines(all)
|
|
||||||
if (me.workingIPv6.S != all) {
|
|
||||||
log.Log(NOW, "workingIPv6.SetText() to:", all)
|
|
||||||
me.workingIPv6.SetText(all)
|
|
||||||
}
|
|
||||||
|
|
||||||
var a []string
|
var a []string
|
||||||
a = realA()
|
a = realA()
|
||||||
|
|
|
@ -42,6 +42,7 @@ type hostnameStatus struct {
|
||||||
currentIPv6 *gadgets.OneLiner
|
currentIPv6 *gadgets.OneLiner
|
||||||
|
|
||||||
// what the DNS servers have
|
// what the DNS servers have
|
||||||
|
NSrr *gadgets.OneLiner
|
||||||
dnsA *gadgets.OneLiner
|
dnsA *gadgets.OneLiner
|
||||||
dnsAAAA *gadgets.OneLiner
|
dnsAAAA *gadgets.OneLiner
|
||||||
dnsAPI *gadgets.OneLiner
|
dnsAPI *gadgets.OneLiner
|
||||||
|
@ -84,6 +85,7 @@ func NewHostnameStatusWindow(p *gui.Node) *hostnameStatus {
|
||||||
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")
|
||||||
|
|
||||||
|
hs.NSrr = gadgets.NewOneLiner(grid, "dns NS records").Set("unknown")
|
||||||
hs.dnsAPI = gadgets.NewOneLiner(grid, "dns API provider").Set("unknown")
|
hs.dnsAPI = gadgets.NewOneLiner(grid, "dns API provider").Set("unknown")
|
||||||
hs.dnsA = gadgets.NewOneLiner(grid, "dns IPv4 resource records").Set("unknown")
|
hs.dnsA = gadgets.NewOneLiner(grid, "dns IPv4 resource records").Set("unknown")
|
||||||
hs.dnsAAAA = gadgets.NewOneLiner(grid, "dns IPv6 resource records").Set("unknown")
|
hs.dnsAAAA = gadgets.NewOneLiner(grid, "dns IPv6 resource records").Set("unknown")
|
||||||
|
@ -339,8 +341,10 @@ func (hs *hostnameStatus) updateStatus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hs.currentIPv4.Set(me.IPv4.S)
|
// hs.currentIPv4.Set(me.IPv4.S)
|
||||||
hs.currentIPv6.Set(me.IPv6.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")
|
||||||
|
|
|
@ -9,15 +9,17 @@ 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("Real Stuff")
|
ls.group = ls.window.Box().NewGroup("What Linux Says It Is")
|
||||||
|
|
||||||
ls.grid = ls.group.NewGrid("gridnuts", 2, 2)
|
ls.grid = ls.group.NewGrid("gridnuts", 2, 2)
|
||||||
|
|
||||||
ls.grid.SetNext(1,1)
|
ls.grid.SetNext(1,1)
|
||||||
|
|
||||||
|
ls.fqdn = gadgets.NewOneLiner(ls.grid, "hostname -f")
|
||||||
ls.hostshort = gadgets.NewOneLiner(ls.grid, "hostname -s")
|
ls.hostshort = gadgets.NewOneLiner(ls.grid, "hostname -s")
|
||||||
ls.domainname = gadgets.NewOneLiner(ls.grid, "domain name")
|
ls.domainname = gadgets.NewOneLiner(ls.grid, "domain name")
|
||||||
ls.NSrr = gadgets.NewOneLiner(ls.grid, "NS records =")
|
ls.resolver = gadgets.NewOneLiner(ls.grid, "nameservers =")
|
||||||
|
ls.resolver.Set("TODO")
|
||||||
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 =")
|
||||||
|
|
|
@ -50,7 +50,7 @@ func (ls *LinuxStatus) GetHostShort() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) setHostShort() {
|
func (ls *LinuxStatus) setHostShort() {
|
||||||
if ! me.Ready() {return ""}
|
if ! me.Ready() {return}
|
||||||
hshort := run("hostname -s")
|
hshort := run("hostname -s")
|
||||||
if (me.hostshort.Get() != hshort) {
|
if (me.hostshort.Get() != hshort) {
|
||||||
log.Log(CHANGE, "hostname -s has changed from", me.hostshort.Get(), "to", hshort)
|
log.Log(CHANGE, "hostname -s has changed from", me.hostshort.Get(), "to", hshort)
|
||||||
|
@ -71,7 +71,7 @@ func lookupHostname() {
|
||||||
log.Error(errors.New("full hostname should be: " + s))
|
log.Error(errors.New("full hostname should be: " + s))
|
||||||
|
|
||||||
me.setDomainName()
|
me.setDomainName()
|
||||||
|
me.setHostShort()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var test string
|
var test string
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -23,14 +24,10 @@ func linuxLoop() {
|
||||||
log.Log(NET, strconv.Itoa(i) + " iface = " + t.iface.Name)
|
log.Log(NET, strconv.Itoa(i) + " iface = " + t.iface.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
var aaaa []string
|
// get all the real AAAA records from all the network interfaces linux can see
|
||||||
aaaa = dhcpAAAA()
|
tmp := strings.Join(realAAAA(), "\n")
|
||||||
var all string
|
tmp = sortLines(tmp)
|
||||||
for _, s := range aaaa {
|
me.workingIPv6.Set(tmp)
|
||||||
log.Log(NET, "my actual AAAA = ",s)
|
|
||||||
all += s + "\n"
|
|
||||||
}
|
|
||||||
// me.IPv6.SetText(all)
|
|
||||||
|
|
||||||
user, _ := user.Current()
|
user, _ := user.Current()
|
||||||
log.Log(INFO, "os.Getuid =", user.Username, os.Getuid())
|
log.Log(INFO, "os.Getuid =", user.Username, os.Getuid())
|
||||||
|
|
|
@ -103,7 +103,7 @@ func checkInterface(i net.Interface) {
|
||||||
These are the real IP address you have been
|
These are the real IP address you have been
|
||||||
given from DHCP
|
given from DHCP
|
||||||
*/
|
*/
|
||||||
func dhcpAAAA() []string {
|
func realAAAA() []string {
|
||||||
var aaaa []string
|
var aaaa []string
|
||||||
|
|
||||||
for s, t := range me.ipmap {
|
for s, t := range me.ipmap {
|
||||||
|
|
|
@ -30,7 +30,7 @@ type LinuxStatus struct {
|
||||||
hostshort *gadgets.OneLiner
|
hostshort *gadgets.OneLiner
|
||||||
domainname *gadgets.OneLiner
|
domainname *gadgets.OneLiner
|
||||||
fqdn *gadgets.OneLiner
|
fqdn *gadgets.OneLiner
|
||||||
NSrr *gadgets.OneLiner
|
resolver *gadgets.OneLiner
|
||||||
uid *gadgets.OneLiner
|
uid *gadgets.OneLiner
|
||||||
IPv4 *gadgets.OneLiner
|
IPv4 *gadgets.OneLiner
|
||||||
IPv6 *gadgets.OneLiner
|
IPv6 *gadgets.OneLiner
|
||||||
|
|
7
main.go
7
main.go
|
@ -8,7 +8,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
"embed"
|
"embed"
|
||||||
|
@ -160,12 +159,6 @@ func linuxLoop() {
|
||||||
duration := timeFunction(getHostname)
|
duration := timeFunction(getHostname)
|
||||||
log.Info("getHostname() execution Time: ", duration, "me.changed =", me.changed)
|
log.Info("getHostname() execution Time: ", duration, "me.changed =", me.changed)
|
||||||
|
|
||||||
duration = timeFunction(scanInterfaces)
|
|
||||||
log.Log(NET, "scanInterfaces() execution Time: ", duration)
|
|
||||||
for i, t := range me.ifmap {
|
|
||||||
log.Log(NET, strconv.Itoa(i) + " iface = " + t.iface.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
var aaaa []string
|
var aaaa []string
|
||||||
aaaa = dhcpAAAA()
|
aaaa = dhcpAAAA()
|
||||||
var all string
|
var all string
|
||||||
|
|
111
net.go
111
net.go
|
@ -156,117 +156,8 @@ func checkDNS() (map[string]*IPtype, map[string]*IPtype) {
|
||||||
return ipv6s, ipv4s
|
return ipv6s, ipv4s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will figure out if an IP address is new
|
|
||||||
func checkIP(ip *net.IPNet, i net.Interface) bool {
|
|
||||||
log.Log(NET, "\t\taddr.(type) = *net.IPNet")
|
|
||||||
log.Log(NET, "\t\taddr.(type) =", ip)
|
|
||||||
var realip string
|
|
||||||
realip = ip.IP.String()
|
|
||||||
|
|
||||||
val, ok := me.ipmap[realip]
|
|
||||||
if ok {
|
|
||||||
log.Log(NET, val.ipnet.IP.String(), "is already a defined IP address")
|
|
||||||
me.ipmap[realip].gone = false
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
me.ipmap[realip] = new(IPtype)
|
|
||||||
me.ipmap[realip].gone = false
|
|
||||||
me.ipmap[realip].ipv4 = true
|
|
||||||
me.ipmap[realip].ipnet = ip
|
|
||||||
me.ipmap[realip].ip = ip.IP
|
|
||||||
me.ipmap[realip].iface = &i
|
|
||||||
t := "IPv4"
|
|
||||||
if (IsIPv6(ip.String())) {
|
|
||||||
me.ipmap[realip].ipv6 = true
|
|
||||||
me.ipmap[realip].ipv4 = false
|
|
||||||
t = "IPv6"
|
|
||||||
if (me.IPv6 != nil) {
|
|
||||||
me.IPv6.SetText(realip)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
me.ipmap[realip].ipv6 = false
|
|
||||||
me.ipmap[realip].ipv4 = true
|
|
||||||
if (me.IPv4 != nil) {
|
|
||||||
me.IPv4.SetText(realip)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (IsReal(&ip.IP)) {
|
|
||||||
log.Info("\tIP is Real ", t, i.Index, i.Name, realip)
|
|
||||||
} else {
|
|
||||||
log.Info("\tIP is not Real", t, i.Index, i.Name, realip)
|
|
||||||
}
|
|
||||||
log.Log(NET, "\t\tIP is IsPrivate() =", ip.IP.IsPrivate())
|
|
||||||
log.Log(NET, "\t\tIP is IsLoopback() =", ip.IP.IsLoopback())
|
|
||||||
log.Log(NET, "\t\tIP is IsLinkLocalUnicast() =", ip.IP.IsLinkLocalUnicast())
|
|
||||||
// log.Info("HERE HERE", "realip =", realip, "me.ip[realip]=", me.ipmap[realip])
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func scanInterfaces() {
|
|
||||||
log.Log(NET, "scanInterfaces() START")
|
|
||||||
ifaces, _ := net.Interfaces()
|
|
||||||
// me.ifnew = ifaces
|
|
||||||
log.Log(NET, SPEW, ifaces)
|
|
||||||
for _, i := range ifaces {
|
|
||||||
addrs, _ := i.Addrs()
|
|
||||||
// log.Info("range ifaces = ", i)
|
|
||||||
checkInterface(i)
|
|
||||||
log.Log(NET, "*net.Interface.Name = ", i.Name, i.Index)
|
|
||||||
log.Log(NET, SPEW, i)
|
|
||||||
log.Log(NET, SPEW, addrs)
|
|
||||||
for _, addr := range addrs {
|
|
||||||
log.Log(NET, "\taddr =", addr)
|
|
||||||
log.Log(NET, SPEW, addrs)
|
|
||||||
ips, _ := net.LookupIP(addr.String())
|
|
||||||
log.Log(NET, "\tLookupIP(addr) =", ips)
|
|
||||||
switch v := addr.(type) {
|
|
||||||
case *net.IPNet:
|
|
||||||
if checkIP(v, i) {
|
|
||||||
log.Log(true, "scanInterfaces() IP is new () i =", v.IP.String())
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
log.Log(NET, "\t\taddr.(type) = NO IDEA WHAT TO DO HERE v =", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if deleteChanges() {
|
|
||||||
me.changed = true
|
|
||||||
log.Log(NET, "deleteChanges() detected network changes")
|
|
||||||
}
|
|
||||||
updateRealAAAA()
|
|
||||||
log.Log(NET, "scanInterfaces() END")
|
|
||||||
}
|
|
||||||
|
|
||||||
// displays the IP address found on your network interfaces
|
|
||||||
func updateRealAAAA() {
|
|
||||||
var all4 string
|
|
||||||
var all6 string
|
|
||||||
for s, t := range me.ipmap {
|
|
||||||
if (t.ipv4) {
|
|
||||||
all4 += s + "\n"
|
|
||||||
log.Log(NET, "IPv4 =", s)
|
|
||||||
} else if (t.ipv6) {
|
|
||||||
all6 += s + "\n"
|
|
||||||
log.Log(NET, "IPv6 =", s)
|
|
||||||
} else {
|
|
||||||
log.Log(NET, "???? =", s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
all4 = sortLines(all4)
|
|
||||||
all6 = sortLines(all6)
|
|
||||||
if (me.IPv4.S != all4) {
|
|
||||||
log.Log(NET, "IPv4 addresses have changed", all4)
|
|
||||||
me.IPv4.SetText(all4)
|
|
||||||
}
|
|
||||||
if (me.IPv6.S != all6) {
|
|
||||||
log.Log(NET, "IPv6 addresses have changed", all6)
|
|
||||||
me.IPv6.SetText(all6)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete network interfaces and ip addresses from the gui
|
// delete network interfaces and ip addresses from the gui
|
||||||
func deleteChanges() bool {
|
func deleteChanges2() bool {
|
||||||
var changed bool = false
|
var changed bool = false
|
||||||
for i, t := range me.ifmap {
|
for i, t := range me.ifmap {
|
||||||
if (t.gone) {
|
if (t.gone) {
|
||||||
|
|
|
@ -53,16 +53,16 @@ type Host struct {
|
||||||
// local OS settings, network interfaces, etc
|
// local OS settings, network interfaces, etc
|
||||||
// uid *gui.Node // user
|
// uid *gui.Node // user
|
||||||
fqdn *gui.Node // display the full hostname
|
fqdn *gui.Node // display the full hostname
|
||||||
IPv4 *gui.Node // show valid IPv4 addresses
|
// IPv4 *gui.Node // show valid IPv4 addresses
|
||||||
IPv6 *gui.Node // show valid IPv6 addresses
|
// IPv6 *gui.Node // show valid IPv6 addresses
|
||||||
Interfaces *gui.Node // Interfaces
|
Interfaces *gui.Node // Interfaces
|
||||||
LocalSpeedActual *gui.Node // the time it takes to check each network interface
|
LocalSpeedActual *gui.Node // the time it takes to check each network interface
|
||||||
|
|
||||||
// DNS stuff
|
// DNS stuff
|
||||||
NSrr *gui.Node // NS resource records for the domain name
|
// NSrr *gui.Node // NS resource records for the domain name
|
||||||
DnsAPI *gui.Node // what DNS API to use?
|
DnsAPI *gui.Node // what DNS API to use?
|
||||||
DnsAAAA *gadgets.OneLiner // the actual DNS AAAA results
|
DnsAAAA *gadgets.OneLiner // the actual DNS AAAA results
|
||||||
workingIPv6 *gui.Node // currently working AAAA
|
// workingIPv6 *gui.Node // currently working AAAA
|
||||||
DnsA *gui.Node // the actual DNS A results (ignore for status since mostly never happens?)
|
DnsA *gui.Node // the actual DNS A results (ignore for status since mostly never happens?)
|
||||||
DnsStatus *gui.Node // the current state of DNS
|
DnsStatus *gui.Node // the current state of DNS
|
||||||
DnsSpeed *gui.Node // 'FAST', 'OK', 'SLOW', etc
|
DnsSpeed *gui.Node // 'FAST', 'OK', 'SLOW', etc
|
||||||
|
|
Loading…
Reference in New Issue