window titles update to correct values
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b1c7bb8a31
commit
a811226c53
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue