Compare commits
No commits in common. "guimaster" and "v0.21.0" have entirely different histories.
12
Makefile
12
Makefile
|
@ -1,7 +1,8 @@
|
||||||
all: goimports vet
|
all:
|
||||||
|
@echo
|
||||||
vet:
|
@echo Run: make redomod
|
||||||
GO111MODULE=off go vet
|
@echo
|
||||||
|
@# ./myrepos >/tmp/myrepos.stderr 2>&1
|
||||||
|
|
||||||
goimports:
|
goimports:
|
||||||
goimports -w *.go
|
goimports -w *.go
|
||||||
|
@ -12,6 +13,3 @@ redomod:
|
||||||
GO111MODULE= go mod init
|
GO111MODULE= go mod init
|
||||||
GO111MODULE= go mod tidy
|
GO111MODULE= go mod tidy
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -f go.*
|
|
||||||
-go-mod-clean --purge
|
|
||||||
|
|
35
hostname.go
35
hostname.go
|
@ -3,11 +3,8 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
// will try to get this hosts FQDN
|
// will try to get this hosts FQDN
|
||||||
|
@ -83,17 +80,6 @@ func (ls *LinuxStatus) setHostShort() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getDomainName extracts the domain name from a given hostname
|
|
||||||
func getDomainName(hostname string) (string, error) {
|
|
||||||
parts := strings.Split(hostname, ".")
|
|
||||||
if len(parts) < 3 {
|
|
||||||
return "", fmt.Errorf("hostname '%s' is too short to extract a domain name", hostname)
|
|
||||||
}
|
|
||||||
// Join all parts except the first one, which is assumed to be a subdomain
|
|
||||||
domain := strings.Join(parts[1:], ".")
|
|
||||||
return domain, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func lookupHostname() {
|
func lookupHostname() {
|
||||||
if !me.Ready() {
|
if !me.Ready() {
|
||||||
return
|
return
|
||||||
|
@ -121,27 +107,6 @@ func lookupHostname() {
|
||||||
if hostfqdn != hostname {
|
if hostfqdn != hostname {
|
||||||
log.Log(WARN, "hostname", hostname, "does not equal fqdn.FqdnHostname()", hostfqdn)
|
log.Log(WARN, "hostname", hostname, "does not equal fqdn.FqdnHostname()", hostfqdn)
|
||||||
// TODO: figure out what is wrong
|
// TODO: figure out what is wrong
|
||||||
if dn == "(none)" {
|
|
||||||
realdn, err := getDomainName(hostfqdn)
|
|
||||||
if err == nil {
|
|
||||||
log.Log(WARN, "need to run: 'domainname", realdn, "' here")
|
|
||||||
me.changed = true
|
|
||||||
me.hostnameStatus.SetText("FIXING")
|
|
||||||
shell.Run([]string{"domainname", realdn})
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
log.Log(WARN, "getDomainName() err =", err)
|
|
||||||
log.Log(WARN, "/etc/hostname is too short. let the user set the name here.")
|
|
||||||
// me.changed = true
|
|
||||||
me.hostnameStatus.SetText("INVALID DOMAIN NAME")
|
|
||||||
// return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.Log(WARN, "don't know what to do here with domainname")
|
|
||||||
log.Log(WARN, "check that /etc/hostname is valid?")
|
|
||||||
// me.changed = true
|
|
||||||
me.hostnameStatus.SetText("UNKNOWN")
|
|
||||||
// return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var test string
|
var test string
|
||||||
|
|
|
@ -44,7 +44,7 @@ func linuxLoop() {
|
||||||
sort.Strings(a)
|
sort.Strings(a)
|
||||||
tmp := strings.Join(a, "\n")
|
tmp := strings.Join(a, "\n")
|
||||||
if tmp != me.workingIPv4.String() {
|
if tmp != me.workingIPv4.String() {
|
||||||
log.Log(CHANGE, "realA() your real IPv6 addresses changed")
|
log.Log(CHANGE, "realAAAA() your real IPv6 addresses changed")
|
||||||
me.changed = true
|
me.changed = true
|
||||||
me.workingIPv4.SetText(tmp)
|
me.workingIPv4.SetText(tmp)
|
||||||
}
|
}
|
||||||
|
|
2
net.go
2
net.go
|
@ -101,7 +101,7 @@ func realA() []string {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkDNSOld() (map[string]*IPtype, map[string]*IPtype) {
|
func checkDNS() (map[string]*IPtype, map[string]*IPtype) {
|
||||||
var ipv4s map[string]*IPtype
|
var ipv4s map[string]*IPtype
|
||||||
var ipv6s map[string]*IPtype
|
var ipv6s map[string]*IPtype
|
||||||
|
|
||||||
|
|
6
new.go
6
new.go
|
@ -2,12 +2,13 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitLinuxStatus() *LinuxStatus {
|
func NewLinuxStatus(parent *gui.Node) *LinuxStatus {
|
||||||
if me != nil {
|
if me != nil {
|
||||||
log.Log(WARN, "You have done New() twice. You can only do this once")
|
log.Log(WARN, "You have done New() twice. You can only do this once")
|
||||||
return me
|
return me
|
||||||
|
@ -20,9 +21,10 @@ func InitLinuxStatus() *LinuxStatus {
|
||||||
me.ipmap = make(map[string]*IPtype)
|
me.ipmap = make(map[string]*IPtype)
|
||||||
|
|
||||||
log.Log(WARN, "Creating the Window")
|
log.Log(WARN, "Creating the Window")
|
||||||
me.window = gadgets.RawBasicWindow("OS Hostname Details")
|
me.window = gadgets.NewBasicWindow(parent, "OS Hostname Details")
|
||||||
me.window.Make()
|
me.window.Make()
|
||||||
draw(me)
|
draw(me)
|
||||||
|
me.window.Draw()
|
||||||
|
|
||||||
me.ready = true
|
me.ready = true
|
||||||
return me
|
return me
|
||||||
|
|
|
@ -9,9 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ls *LinuxStatus) Update() {
|
func (ls *LinuxStatus) Update() {
|
||||||
if ls == nil {
|
if ls == nil { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
if !ls.Ready() {
|
if !ls.Ready() {
|
||||||
log.Log(WARN, "can't update yet. ready is false")
|
log.Log(WARN, "can't update yet. ready is false")
|
||||||
log.Error(errors.New("Update() is not ready yet"))
|
log.Error(errors.New("Update() is not ready yet"))
|
||||||
|
|
Loading…
Reference in New Issue