Compare commits
No commits in common. "guimaster" and "v0.13.0" have entirely different histories.
|
@ -1,10 +1,7 @@
|
||||||
*.swp
|
|
||||||
go.sum
|
|
||||||
go.mod
|
|
||||||
|
|
||||||
control-panel-dns
|
control-panel-dns
|
||||||
/files/*
|
/files/*
|
||||||
/*.deb
|
/*.deb
|
||||||
|
*.swp
|
||||||
/plugins/*
|
/plugins/*
|
||||||
|
|
||||||
control-panel-dns
|
control-panel-dns
|
||||||
|
|
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
|
|
||||||
|
|
56
common.go
56
common.go
|
@ -2,6 +2,7 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,6 +19,30 @@ func (ls *LinuxStatus) Changed() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ls *LinuxStatus) Make() {
|
||||||
|
if !ls.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Log(CHANGE, "Make() window ready =", ls.ready)
|
||||||
|
ls.window.Make()
|
||||||
|
ls.ready = true
|
||||||
|
}
|
||||||
|
func (ls *LinuxStatus) Draw() {
|
||||||
|
if !ls.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Log(CHANGE, "Draw() window ready =", ls.ready)
|
||||||
|
ls.window.Draw()
|
||||||
|
ls.ready = true
|
||||||
|
}
|
||||||
|
func (ls *LinuxStatus) Draw2() {
|
||||||
|
if !ls.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Log(CHANGE, "draw(ls) ready =", ls.ready)
|
||||||
|
draw(ls)
|
||||||
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) Show() {
|
func (ls *LinuxStatus) Show() {
|
||||||
if !ls.Ready() {
|
if !ls.Ready() {
|
||||||
return
|
return
|
||||||
|
@ -61,3 +86,34 @@ func (ls *LinuxStatus) Ready() bool {
|
||||||
}
|
}
|
||||||
return me.ready
|
return me.ready
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ls *LinuxStatus) Initialized() bool {
|
||||||
|
log.Log(CHANGE, "checking Initialized()")
|
||||||
|
if me == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if ls == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if ls.parent == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *LinuxStatus) SetParent(p *gui.Node) {
|
||||||
|
log.Log(CHANGE, "Attempting SetParent")
|
||||||
|
if me == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ls == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ls.parent == nil {
|
||||||
|
log.Log(CHANGE, "SetParent =", p)
|
||||||
|
ls.parent = p
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
log.Log(CHANGE, "SetParent was already set to =", ls.parent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
5
draw.go
5
draw.go
|
@ -8,6 +8,9 @@ import (
|
||||||
// creates the actual widgets.
|
// creates the actual widgets.
|
||||||
// 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
|
||||||
|
}
|
||||||
ls.group = ls.window.Box().NewGroup("What Linux Knows It Is")
|
ls.group = ls.window.Box().NewGroup("What Linux Knows It Is")
|
||||||
|
|
||||||
ls.grid = ls.group.NewGrid("gridnuts", 2, 2)
|
ls.grid = ls.group.NewGrid("gridnuts", 2, 2)
|
||||||
|
@ -17,7 +20,7 @@ func draw(ls *LinuxStatus) {
|
||||||
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.resolver = gadgets.NewOneLiner(ls.grid, "nameservers =")
|
ls.resolver = gadgets.NewOneLiner(ls.grid, "nameservers =")
|
||||||
ls.resolver.SetText("TODO")
|
ls.resolver.SetValue("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 =")
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
module go.wit.com/lib/gui/linuxstatus
|
||||||
|
|
||||||
|
go 1.21.4
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/Showmax/go-fqdn v1.0.0
|
||||||
|
github.com/creack/pty v1.1.21
|
||||||
|
github.com/jsimonetti/rtnetlink v1.4.0
|
||||||
|
go.wit.com/gui v0.13.11
|
||||||
|
go.wit.com/lib/gadgets v0.13.0
|
||||||
|
go.wit.com/log v0.5.6
|
||||||
|
go.wit.com/shell v0.2.3
|
||||||
|
golang.org/x/term v0.16.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
|
||||||
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
|
github.com/josharian/native v1.1.0 // indirect
|
||||||
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||||
|
github.com/mdlayher/netlink v1.7.2 // indirect
|
||||||
|
github.com/mdlayher/socket v0.4.1 // indirect
|
||||||
|
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||||
|
github.com/svent/go-nbreader v0.0.0-20150201200112-7cef48da76dc // indirect
|
||||||
|
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef // indirect
|
||||||
|
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117 // indirect
|
||||||
|
go.wit.com/dev/alexflint/arg v1.4.5 // indirect
|
||||||
|
go.wit.com/dev/alexflint/scalar v1.2.1 // indirect
|
||||||
|
go.wit.com/dev/davecgh/spew v1.1.4 // indirect
|
||||||
|
go.wit.com/widget v1.1.6 // indirect
|
||||||
|
golang.org/x/crypto v0.17.0 // indirect
|
||||||
|
golang.org/x/net v0.17.0 // indirect
|
||||||
|
golang.org/x/sync v0.1.0 // indirect
|
||||||
|
golang.org/x/sys v0.16.0 // indirect
|
||||||
|
)
|
|
@ -0,0 +1,68 @@
|
||||||
|
github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM=
|
||||||
|
github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko=
|
||||||
|
github.com/cilium/ebpf v0.12.3 h1:8ht6F9MquybnY97at+VDZb3eQQr8ev79RueWeVaEcG4=
|
||||||
|
github.com/cilium/ebpf v0.12.3/go.mod h1:TctK1ivibvI3znr66ljgi4hqOT8EYQjz1KWBfb1UVgM=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
|
||||||
|
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
||||||
|
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||||
|
github.com/jsimonetti/rtnetlink v1.4.0 h1:Z1BF0fRgcETPEa0Kt0MRk3yV5+kF1FWTni6KUFKrq2I=
|
||||||
|
github.com/jsimonetti/rtnetlink v1.4.0/go.mod h1:5W1jDvWdnthFJ7fxYX1GMK07BUpI4oskfOqvPteYS6E=
|
||||||
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||||
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||||
|
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
|
||||||
|
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
|
||||||
|
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
|
||||||
|
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/svent/go-nbreader v0.0.0-20150201200112-7cef48da76dc h1:usYkrH2/es/TT7ETdC/qLAagcJPW3EEYFKqvibSnFbA=
|
||||||
|
github.com/svent/go-nbreader v0.0.0-20150201200112-7cef48da76dc/go.mod h1:pPzZl0vMkUhyoxUF8PAGG5bDRGo7PY80oO/PMmpLkkc=
|
||||||
|
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef h1:7D6Nm4D6f0ci9yttWaKjM1TMAXrH5Su72dojqYGntFY=
|
||||||
|
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef/go.mod h1:WLFStEdnJXpjK8kd4qKLwQKX/1vrDzp5BcDyiZJBHJM=
|
||||||
|
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117 h1:67A5tweHp3C7osHjrYsy6pQZ00bYkTTttZ7kiOwwHeA=
|
||||||
|
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117/go.mod h1:XCsSkdKK4gwBMNrOCZWww0pX6AOt+2gYc5Z6jBRrNVg=
|
||||||
|
go.wit.com/dev/alexflint/arg v1.4.5 h1:asDx5f9IlfpknKjPBqqb2qndE91Pbo7ZDkWUgddfMhY=
|
||||||
|
go.wit.com/dev/alexflint/arg v1.4.5/go.mod h1:wnWc+c6z8kSdDKYriMf6RpM+FiXmo5RYp/t4FNi0MU0=
|
||||||
|
go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs=
|
||||||
|
go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
|
||||||
|
go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
|
||||||
|
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
|
||||||
|
go.wit.com/gui v0.13.11 h1:d74Ko/XFZYR25P/AZfCQaVO2CuGh1BSjdUp1wjktdDg=
|
||||||
|
go.wit.com/gui v0.13.11/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA=
|
||||||
|
go.wit.com/lib/gadgets v0.13.0 h1:jtsEnf4DHqAxBxuYsaDlHti73rgaxYf/ffAXNB1PJAk=
|
||||||
|
go.wit.com/lib/gadgets v0.13.0/go.mod h1:xidaHAL6Nk9+M9FkySVU1AG5i39v7T3PuFphUos6LxE=
|
||||||
|
go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4=
|
||||||
|
go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
|
||||||
|
go.wit.com/shell v0.2.3 h1:9EH4Sel9xw+9MJsBmYQPu4onDuOkh307VroSkpt9+6E=
|
||||||
|
go.wit.com/shell v0.2.3/go.mod h1:ig4rzOYoHKRRWjNAoDuddV7lIDg05qF1nj3f93j+FQo=
|
||||||
|
go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY=
|
||||||
|
go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ=
|
||||||
|
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||||
|
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||||
|
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI=
|
||||||
|
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||||
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
|
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||||
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||||
|
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
|
||||||
|
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
46
hostname.go
46
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
|
||||||
|
@ -29,7 +26,7 @@ func (ls *LinuxStatus) setDomainName() {
|
||||||
dn := run("domainname")
|
dn := run("domainname")
|
||||||
if me.domainname.String() != dn {
|
if me.domainname.String() != dn {
|
||||||
log.Log(CHANGE, "domainname has changed from", me.GetDomainName(), "to", dn)
|
log.Log(CHANGE, "domainname has changed from", me.GetDomainName(), "to", dn)
|
||||||
me.domainname.SetText(dn)
|
me.domainname.SetValue(dn)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +40,6 @@ func (ls *LinuxStatus) GetHostname() string {
|
||||||
|
|
||||||
func (ls *LinuxStatus) ValidHostname() bool {
|
func (ls *LinuxStatus) ValidHostname() bool {
|
||||||
if !me.Ready() {
|
if !me.Ready() {
|
||||||
log.Info("ValidHostname() not ready")
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if me.hostnameStatus.String() == "WORKING" {
|
if me.hostnameStatus.String() == "WORKING" {
|
||||||
|
@ -60,7 +56,7 @@ func (ls *LinuxStatus) setHostname(newname string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Log(CHANGE, "hostname has changed from", me.GetHostname(), "to", newname)
|
log.Log(CHANGE, "hostname has changed from", me.GetHostname(), "to", newname)
|
||||||
me.hostname.SetText(newname)
|
me.hostname.SetValue(newname)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,22 +74,11 @@ func (ls *LinuxStatus) setHostShort() {
|
||||||
hshort := run("hostname -s")
|
hshort := run("hostname -s")
|
||||||
if me.hostshort.String() != hshort {
|
if me.hostshort.String() != hshort {
|
||||||
log.Log(CHANGE, "hostname -s has changed from", me.hostshort.String(), "to", hshort)
|
log.Log(CHANGE, "hostname -s has changed from", me.hostshort.String(), "to", hshort)
|
||||||
me.hostshort.SetText(hshort)
|
me.hostshort.SetValue(hshort)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 +106,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
|
||||||
|
@ -154,12 +118,12 @@ func lookupHostname() {
|
||||||
if me.hostnameStatus.String() != "BROKEN" {
|
if me.hostnameStatus.String() != "BROKEN" {
|
||||||
log.Log(CHANGE, "hostname", hostname, "does not equal", test)
|
log.Log(CHANGE, "hostname", hostname, "does not equal", test)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
me.hostnameStatus.SetText("BROKEN")
|
me.hostnameStatus.SetValue("BROKEN")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if me.hostnameStatus.String() != "WORKING" {
|
if me.hostnameStatus.String() != "WORKING" {
|
||||||
log.Log(CHANGE, "hostname", hostname, "is valid")
|
log.Log(CHANGE, "hostname", hostname, "is valid")
|
||||||
me.hostnameStatus.SetText("WORKING")
|
me.hostnameStatus.SetValue("WORKING")
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
linuxloop.go
10
linuxloop.go
|
@ -44,9 +44,9 @@ 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.SetValue(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
|
||||||
|
@ -56,7 +56,7 @@ func linuxLoop() {
|
||||||
if tmp != me.workingIPv6.String() {
|
if tmp != me.workingIPv6.String() {
|
||||||
log.Log(CHANGE, "realAAAA() your real IPv6 addresses changed")
|
log.Log(CHANGE, "realAAAA() your real IPv6 addresses changed")
|
||||||
me.changed = true
|
me.changed = true
|
||||||
me.workingIPv6.SetText(tmp)
|
me.workingIPv6.SetValue(tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, _ := user.Current()
|
user, _ := user.Current()
|
||||||
|
@ -64,7 +64,7 @@ func linuxLoop() {
|
||||||
if tmp != me.uid.String() {
|
if tmp != me.uid.String() {
|
||||||
log.Log(CHANGE, "os.Getuid =", user.Username, os.Getuid())
|
log.Log(CHANGE, "os.Getuid =", user.Username, os.Getuid())
|
||||||
me.changed = true
|
me.changed = true
|
||||||
me.uid.SetText(tmp)
|
me.uid.SetValue(tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
content, _ := ioutil.ReadFile("/etc/resolv.conf")
|
content, _ := ioutil.ReadFile("/etc/resolv.conf")
|
||||||
|
@ -82,7 +82,7 @@ func linuxLoop() {
|
||||||
if newNS != me.resolver.String() {
|
if newNS != me.resolver.String() {
|
||||||
log.Log(CHANGE, "resolver changed in /etc/resolv.conf to", ns)
|
log.Log(CHANGE, "resolver changed in /etc/resolv.conf to", ns)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
me.resolver.SetText(newNS)
|
me.resolver.SetValue(newNS)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
10
net.go
10
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
|
||||||
|
|
||||||
|
@ -154,13 +154,13 @@ func checkIP(ip *net.IPNet, i net.Interface) bool {
|
||||||
me.ipmap[realip].ipv4 = false
|
me.ipmap[realip].ipv4 = false
|
||||||
t = "IPv6"
|
t = "IPv6"
|
||||||
if me.IPv6 != nil {
|
if me.IPv6 != nil {
|
||||||
me.IPv6.SetText(realip)
|
me.IPv6.SetValue(realip)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
me.ipmap[realip].ipv6 = false
|
me.ipmap[realip].ipv6 = false
|
||||||
me.ipmap[realip].ipv4 = true
|
me.ipmap[realip].ipv4 = true
|
||||||
if me.IPv4 != nil {
|
if me.IPv4 != nil {
|
||||||
me.IPv4.SetText(realip)
|
me.IPv4.SetValue(realip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if IsReal(&ip.IP) {
|
if IsReal(&ip.IP) {
|
||||||
|
@ -234,12 +234,12 @@ func updateRealAAAA() {
|
||||||
|
|
||||||
if me.IPv4.String() != s4 {
|
if me.IPv4.String() != s4 {
|
||||||
log.Log(CHANGE, "IPv4 addresses have changed", s4)
|
log.Log(CHANGE, "IPv4 addresses have changed", s4)
|
||||||
me.IPv4.SetText(s4)
|
me.IPv4.SetValue(s4)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
if me.IPv6.String() != s6 {
|
if me.IPv6.String() != s6 {
|
||||||
log.Log(CHANGE, "IPv6 addresses have changed", s6)
|
log.Log(CHANGE, "IPv6 addresses have changed", s6)
|
||||||
me.IPv6.SetText(s6)
|
me.IPv6.SetValue(s6)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
24
new.go
24
new.go
|
@ -7,7 +7,7 @@ import (
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitLinuxStatus() *LinuxStatus {
|
func New() *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
|
||||||
|
@ -19,11 +19,21 @@ func InitLinuxStatus() *LinuxStatus {
|
||||||
me.ifmap = make(map[int]*IFtype)
|
me.ifmap = make(map[int]*IFtype)
|
||||||
me.ipmap = make(map[string]*IPtype)
|
me.ipmap = make(map[string]*IPtype)
|
||||||
|
|
||||||
log.Log(WARN, "Creating the Window")
|
|
||||||
me.window = gadgets.RawBasicWindow("OS Hostname Details")
|
|
||||||
me.window.Make()
|
|
||||||
draw(me)
|
|
||||||
|
|
||||||
me.ready = true
|
|
||||||
return me
|
return me
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ls *LinuxStatus) InitWindow() {
|
||||||
|
if !ls.Initialized() {
|
||||||
|
log.Log(WARN, "not initalized yet (no parent for the window?)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ls.window != nil {
|
||||||
|
log.Log(WARN, "You already have a window")
|
||||||
|
ls.ready = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Log(WARN, "Creating the Window")
|
||||||
|
ls.window = gadgets.NewBasicWindow(ls.parent, "Linux OS Details")
|
||||||
|
ls.ready = true
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/creack/pty"
|
||||||
|
"golang.org/x/term"
|
||||||
|
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func test() error {
|
||||||
|
// Create arbitrary command.
|
||||||
|
c := exec.Command("bash")
|
||||||
|
|
||||||
|
// Start the command with a pty.
|
||||||
|
ptmx, err := pty.Start(c)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Make sure to close the pty at the end.
|
||||||
|
defer func() { _ = ptmx.Close() }() // Best effort.
|
||||||
|
|
||||||
|
// Handle pty size.
|
||||||
|
ch := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(ch, syscall.SIGWINCH)
|
||||||
|
go func() {
|
||||||
|
for range ch {
|
||||||
|
if err := pty.InheritSize(os.Stdin, ptmx); err != nil {
|
||||||
|
log.Println("error resizing pty: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
ch <- syscall.SIGWINCH // Initial resize.
|
||||||
|
defer func() { signal.Stop(ch); close(ch) }() // Cleanup signals when done.
|
||||||
|
|
||||||
|
// Set stdin in raw mode.
|
||||||
|
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer func() { _ = term.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort.
|
||||||
|
|
||||||
|
// Copy stdin to the pty and the pty to stdout.
|
||||||
|
// NOTE: The goroutine will keep reading until the next keystroke before returning.
|
||||||
|
go func() { _, _ = io.Copy(ptmx, os.Stdin) }()
|
||||||
|
_, _ = io.Copy(os.Stdout, ptmx)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func mainBash() {
|
||||||
|
if err := test(); err != nil {
|
||||||
|
log.Error(err, "exit in mainBash()")
|
||||||
|
log.Exit(err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
https://pkg.go.dev/github.com/miekg/dns#section-readme
|
||||||
|
|
||||||
|
DYNAMIC UPDATES
|
||||||
|
|
||||||
|
Dynamic updates reuses the DNS message format, but renames three of the sections. Question is Zone, Answer is Prerequisite, Authority is Update, only the Additional is not renamed. See RFC 2136 for the gory details.
|
||||||
|
|
||||||
|
You can set a rather complex set of rules for the existence of absence of certain resource records or names in a zone to specify if resource records should be added or removed. The table from RFC 2136 supplemented with the Go DNS function shows which functions exist to specify the prerequisites.
|
||||||
|
|
||||||
|
3.2.4 - Table Of Metavalues Used In Prerequisite Section
|
||||||
|
|
||||||
|
CLASS TYPE RDATA Meaning Function
|
||||||
|
--------------------------------------------------------------
|
||||||
|
ANY ANY empty Name is in use dns.NameUsed
|
||||||
|
ANY rrset empty RRset exists (value indep) dns.RRsetUsed
|
||||||
|
NONE ANY empty Name is not in use dns.NameNotUsed
|
||||||
|
NONE rrset empty RRset does not exist dns.RRsetNotUsed
|
||||||
|
zone rrset rr RRset exists (value dep) dns.Used
|
||||||
|
|
||||||
|
The prerequisite section can also be left empty. If you have decided on the prerequisites you can tell what RRs should be added or deleted. The next table shows the options you have and what functions to call.
|
||||||
|
|
||||||
|
3.4.2.6 - Table Of Metavalues Used In Update Section
|
||||||
|
|
||||||
|
CLASS TYPE RDATA Meaning Function
|
||||||
|
---------------------------------------------------------------
|
||||||
|
ANY ANY empty Delete all RRsets from name dns.RemoveName
|
||||||
|
ANY rrset empty Delete an RRset dns.RemoveRRset
|
||||||
|
NONE rrset rr Delete an RR from RRset dns.Remove
|
||||||
|
zone rrset rr Add to an RRset dns.Insert
|
||||||
|
*/
|
|
@ -0,0 +1,81 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
// Watches for changes to a directory. Works cross-platform
|
||||||
|
|
||||||
|
/*
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
"github.com/fsnotify/fsnotify"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This would be a really dumb way to watch for new network interfaces
|
||||||
|
// since it then watches a linux only directory /sys/class/net for changes
|
||||||
|
|
||||||
|
func watchSysClassNet() {
|
||||||
|
// Create new watcher.
|
||||||
|
watcher, err := fsnotify.NewWatcher()
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err, "watchSysClassNet() failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer watcher.Close()
|
||||||
|
|
||||||
|
// Start listening for events.
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case event, ok := <-watcher.Events:
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Println("event:", event)
|
||||||
|
if event.Has(fsnotify.Write) {
|
||||||
|
log.Println("modified file:", event.Name)
|
||||||
|
}
|
||||||
|
case err, ok := <-watcher.Errors:
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Println("error:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Add a path.
|
||||||
|
err = watcher.Add("/tmp")
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err, "watchSysClassNet() watcher.Add() failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Block main goroutine forever.
|
||||||
|
<-make(chan struct{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func fsnotifyNetworkInterfaceChanges() error {
|
||||||
|
watcher, err := fsnotify.NewWatcher()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer watcher.Close()
|
||||||
|
|
||||||
|
// Watch for network interface changes
|
||||||
|
err = watcher.Add("/sys/class/net")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case event := <-watcher.Events:
|
||||||
|
log.Println("fsnotifyNetworkInterfaceChanges() event =", event)
|
||||||
|
if event.Op&fsnotify.Create == fsnotify.Create {
|
||||||
|
// Do something on network interface creation
|
||||||
|
}
|
||||||
|
case err := <-watcher.Errors:
|
||||||
|
log.Println("fsnotifyNetworkInterfaceChanges() event err =", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
|
@ -0,0 +1,34 @@
|
||||||
|
// inspired from:
|
||||||
|
// https://github.com/mactsouk/opensource.com.git
|
||||||
|
// and
|
||||||
|
// https://coderwall.com/p/wohavg/creating-a-simple-tcp-server-in-go
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
)
|
||||||
|
|
||||||
|
// ./go-nsupdate \
|
||||||
|
// --tsig-algorithm=hmac-sha512 \
|
||||||
|
// --tsig-secret="OWh5/ZHIyaz7B8J9m9ZDqZ8448Pke0PTpkYbZmFcOf5a6rEzgmcwrG91u1BHi1/4us+mKKEobDPLw1x6sD+ZJw==" \
|
||||||
|
// -i eno2 farm001.lab.wit.com
|
||||||
|
|
||||||
|
/*
|
||||||
|
func nsupdate() {
|
||||||
|
var tsigSecret string
|
||||||
|
log.Log(NET, "nsupdate() START")
|
||||||
|
cmd := "go-nsupdate --tsig-algorithm=hmac-sha512"
|
||||||
|
tsigSecret = os.Getenv("TIG_SECRET")
|
||||||
|
cmd += " --tig-secret=\"" + tsigSecret + "\""
|
||||||
|
cmd += " -i wlo1 " + me.statusOS.GetHostname()
|
||||||
|
log.Log(NET, "nsupdate() RUN:", cmd)
|
||||||
|
|
||||||
|
for s, t := range me.ipmap {
|
||||||
|
if (t.IsReal()) {
|
||||||
|
if (t.ipv6) {
|
||||||
|
log.Log(NET, "nsupdate() found real AAAA =", s, "on iface", t.iface.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
|
@ -0,0 +1,26 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jsimonetti/rtnetlink"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// List all interfaces
|
||||||
|
func Example_listLink() {
|
||||||
|
// Dial a connection to the rtnetlink socket
|
||||||
|
conn, err := rtnetlink.Dial(nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err, "Example_listLink() failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
// Request a list of interfaces
|
||||||
|
msg, err := conn.Link.List()
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println("%#v", msg)
|
||||||
|
log.Println(SPEW, msg)
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
// Various Linux/Unix'y things
|
||||||
|
|
||||||
|
// https://wiki.archlinux.org/title/Dynamic_DNS
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"net"
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/shell"
|
||||||
|
)
|
||||||
|
|
||||||
|
func CheckSuperuser() bool {
|
||||||
|
return os.Getuid() == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func Escalate() {
|
||||||
|
if os.Getuid() != 0 {
|
||||||
|
cmd := exec.Command("sudo", "./control-panel-dns") // TODO: get the actual path
|
||||||
|
cmd.Stdin = os.Stdin
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err, "exit in Escalate()")
|
||||||
|
log.Exit(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// You need permission to do a zone transfer. Otherwise:
|
||||||
|
// dig +noall +answer +multiline lab.wit.com any
|
||||||
|
// dig +all +multiline fire.lab.wit.com # gives the zonefile header (ttl vals)
|
||||||
|
func DumpPublicDNSZone(zone string) {
|
||||||
|
entries, err := net.LookupHost(zone)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
for _, entry := range entries {
|
||||||
|
log.Println(entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func dumpIPs(host string) {
|
||||||
|
ips, err := net.LookupIP(host)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err, "dumpIPs() failed")
|
||||||
|
}
|
||||||
|
for _, ip := range ips {
|
||||||
|
log.Println(host, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
check if ddclient is installed, working, and/or configured
|
||||||
|
https://github.com/ddclient/ddclient
|
||||||
|
*/
|
||||||
|
func ddclient() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
check if ddupdate is installed, working, and/or configured
|
||||||
|
*/
|
||||||
|
func ddupdate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func run(s string) string {
|
||||||
|
cmdArgs := strings.Fields(s)
|
||||||
|
// Define the command you want to run
|
||||||
|
// cmd := exec.Command(cmdArgs)
|
||||||
|
cmd := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
|
||||||
|
|
||||||
|
// Create a buffer to capture the output
|
||||||
|
var out bytes.Buffer
|
||||||
|
|
||||||
|
// Set the output of the command to the buffer
|
||||||
|
cmd.Stdout = &out
|
||||||
|
|
||||||
|
// Run the command
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error running command:", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp := shell.Chomp(out.String())
|
||||||
|
// Output the results
|
||||||
|
log.Info("Command Output:", tmp)
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
}
|
2
timer.go
2
timer.go
|
@ -34,5 +34,5 @@ func (ls *LinuxStatus) SetSpeedActual(s string) {
|
||||||
if !ls.Ready() {
|
if !ls.Ready() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ls.speedActual.SetText(s)
|
ls.speedActual.SetValue(s)
|
||||||
}
|
}
|
||||||
|
|
2
unix.go
2
unix.go
|
@ -91,7 +91,7 @@ func run(s string) string {
|
||||||
// Trim leading and trailing whitespace from each line
|
// Trim leading and trailing whitespace from each line
|
||||||
tmp := strings.TrimSpace(out.String())
|
tmp := strings.TrimSpace(out.String())
|
||||||
// Output the results
|
// Output the results
|
||||||
log.Verbose("Command Output:", tmp)
|
log.Info("Command Output:", tmp)
|
||||||
|
|
||||||
return tmp
|
return tmp
|
||||||
}
|
}
|
||||||
|
|
11
update.go
11
update.go
|
@ -9,9 +9,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ls *LinuxStatus) Update() {
|
func (ls *LinuxStatus) Update() {
|
||||||
if ls == nil {
|
|
||||||
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"))
|
||||||
|
@ -31,13 +28,13 @@ func (ls *LinuxStatus) setSpeed(duration time.Duration) {
|
||||||
log.Log(WARN, "can't actually warn")
|
log.Log(WARN, "can't actually warn")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ls.speedActual.SetText(s)
|
ls.speedActual.SetValue(s)
|
||||||
|
|
||||||
if duration > 500*time.Millisecond {
|
if duration > 500*time.Millisecond {
|
||||||
ls.speed.SetText("SLOW")
|
ls.speed.SetValue("SLOW")
|
||||||
} else if duration > 100*time.Millisecond {
|
} else if duration > 100*time.Millisecond {
|
||||||
ls.speed.SetText("OK")
|
ls.speed.SetValue("OK")
|
||||||
} else {
|
} else {
|
||||||
ls.speed.SetText("FAST")
|
ls.speed.SetValue("FAST")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue