fix name changes
new gadgets correct go mod updated paths Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
fdac7e7b89
commit
433d83e636
|
@ -0,0 +1,15 @@
|
||||||
|
all:
|
||||||
|
@echo
|
||||||
|
@echo Run: make redomod
|
||||||
|
@echo
|
||||||
|
@# ./myrepos >/tmp/myrepos.stderr 2>&1
|
||||||
|
|
||||||
|
goimports:
|
||||||
|
goimports -w *.go
|
||||||
|
|
||||||
|
redomod:
|
||||||
|
rm -f go.*
|
||||||
|
goimports -w *.go
|
||||||
|
GO111MODULE= go mod init
|
||||||
|
GO111MODULE= go mod tidy
|
||||||
|
|
6
args.go
6
args.go
|
@ -24,10 +24,10 @@ func init() {
|
||||||
full := "go.wit.com/control-panels/dns/linuxstatus"
|
full := "go.wit.com/control-panels/dns/linuxstatus"
|
||||||
short := "linux"
|
short := "linux"
|
||||||
|
|
||||||
NOW = log.NewFlag( "NOW", true, full, short, "temp debugging stuff")
|
NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")
|
||||||
INFO = log.NewFlag("INFO", false, full, short, "normal debugging stuff")
|
INFO = log.NewFlag("INFO", false, full, short, "normal debugging stuff")
|
||||||
NET = log.NewFlag( "NET", false, full, short, "Network logging")
|
NET = log.NewFlag("NET", false, full, short, "Network logging")
|
||||||
DNS = log.NewFlag( "DNS", false, full, short, "dnsStatus.update()")
|
DNS = log.NewFlag("DNS", false, full, short, "dnsStatus.update()")
|
||||||
|
|
||||||
PROC = log.NewFlag("PROC", false, full, short, "/proc loggging")
|
PROC = log.NewFlag("PROC", false, full, short, "/proc loggging")
|
||||||
WARN = log.NewFlag("WARN", true, full, short, "bad things")
|
WARN = log.NewFlag("WARN", true, full, short, "bad things")
|
||||||
|
|
62
common.go
62
common.go
|
@ -2,14 +2,16 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// reports externally if something has changed
|
// reports externally if something has changed
|
||||||
// since the last time it was asked about it
|
// since the last time it was asked about it
|
||||||
func (ls *LinuxStatus) Changed() bool {
|
func (ls *LinuxStatus) Changed() bool {
|
||||||
if ! ls.Ready() {return false}
|
if !ls.Ready() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if ls.changed {
|
if ls.changed {
|
||||||
ls.changed = false
|
ls.changed = false
|
||||||
return true
|
return true
|
||||||
|
@ -18,39 +20,51 @@ func (ls *LinuxStatus) Changed() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) Make() {
|
func (ls *LinuxStatus) Make() {
|
||||||
if ! ls.Ready() {return}
|
if !ls.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(CHANGE, "Make() window ready =", ls.ready)
|
log.Log(CHANGE, "Make() window ready =", ls.ready)
|
||||||
ls.window.Make()
|
ls.window.Make()
|
||||||
ls.ready = true
|
ls.ready = true
|
||||||
}
|
}
|
||||||
func (ls *LinuxStatus) Draw() {
|
func (ls *LinuxStatus) Draw() {
|
||||||
if ! ls.Ready() {return}
|
if !ls.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(CHANGE, "Draw() window ready =", ls.ready)
|
log.Log(CHANGE, "Draw() window ready =", ls.ready)
|
||||||
ls.window.Draw()
|
ls.window.Draw()
|
||||||
ls.ready = true
|
ls.ready = true
|
||||||
}
|
}
|
||||||
func (ls *LinuxStatus) Draw2() {
|
func (ls *LinuxStatus) Draw2() {
|
||||||
if ! ls.Ready() {return}
|
if !ls.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(CHANGE, "draw(ls) ready =", ls.ready)
|
log.Log(CHANGE, "draw(ls) ready =", ls.ready)
|
||||||
draw(ls)
|
draw(ls)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) Show() {
|
func (ls *LinuxStatus) Show() {
|
||||||
if ! ls.Ready() {return}
|
if !ls.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(CHANGE, "Show() window ready =", ls.ready)
|
log.Log(CHANGE, "Show() window ready =", ls.ready)
|
||||||
ls.window.Show()
|
ls.window.Show()
|
||||||
ls.hidden = false
|
ls.hidden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) Hide() {
|
func (ls *LinuxStatus) Hide() {
|
||||||
if ! ls.Ready() {return}
|
if !ls.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(CHANGE, "Hide() window ready =", ls.ready)
|
log.Log(CHANGE, "Hide() window ready =", ls.ready)
|
||||||
ls.window.Hide()
|
ls.window.Hide()
|
||||||
ls.hidden = true
|
ls.hidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) Toggle() {
|
func (ls *LinuxStatus) Toggle() {
|
||||||
if ! ls.Ready() {return}
|
if !ls.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(CHANGE, "Toggle() window ready =", ls.ready)
|
log.Log(CHANGE, "Toggle() window ready =", ls.ready)
|
||||||
if ls.hidden {
|
if ls.hidden {
|
||||||
ls.Show()
|
ls.Show()
|
||||||
|
@ -61,24 +75,40 @@ func (ls *LinuxStatus) Toggle() {
|
||||||
|
|
||||||
func (ls *LinuxStatus) Ready() bool {
|
func (ls *LinuxStatus) Ready() bool {
|
||||||
log.Log(SPEW, "Ready() maybe not ready? ls =", ls)
|
log.Log(SPEW, "Ready() maybe not ready? ls =", ls)
|
||||||
if me == nil {return false}
|
if me == nil {
|
||||||
if ls == nil {return false}
|
return false
|
||||||
if ls.window == nil {return false}
|
}
|
||||||
|
if ls == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if ls.window == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return me.ready
|
return me.ready
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) Initialized() bool {
|
func (ls *LinuxStatus) Initialized() bool {
|
||||||
log.Log(CHANGE, "checking Initialized()")
|
log.Log(CHANGE, "checking Initialized()")
|
||||||
if me == nil {return false}
|
if me == nil {
|
||||||
if ls == nil {return false}
|
return false
|
||||||
if ls.parent == nil {return false}
|
}
|
||||||
|
if ls == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if ls.parent == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) SetParent(p *gui.Node) {
|
func (ls *LinuxStatus) SetParent(p *gui.Node) {
|
||||||
log.Log(CHANGE, "Attempting SetParent")
|
log.Log(CHANGE, "Attempting SetParent")
|
||||||
if me == nil {return}
|
if me == nil {
|
||||||
if ls == nil {return}
|
return
|
||||||
|
}
|
||||||
|
if ls == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
if ls.parent == nil {
|
if ls.parent == nil {
|
||||||
log.Log(CHANGE, "SetParent =", p)
|
log.Log(CHANGE, "SetParent =", p)
|
||||||
ls.parent = p
|
ls.parent = p
|
||||||
|
|
10
draw.go
10
draw.go
|
@ -2,13 +2,15 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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}
|
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)
|
||||||
|
@ -18,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.Set("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 =")
|
||||||
|
@ -27,7 +29,7 @@ func draw(ls *LinuxStatus) {
|
||||||
// ls.nics = gadgets.NewOneLiner(ls.grid, "network intefaces =")
|
// ls.nics = gadgets.NewOneLiner(ls.grid, "network intefaces =")
|
||||||
|
|
||||||
ls.grid.NewLabel("interfaces =")
|
ls.grid.NewLabel("interfaces =")
|
||||||
ls.Interfaces = ls.grid.NewCombobox("Interfaces")
|
ls.Interfaces = ls.grid.NewCombobox()
|
||||||
|
|
||||||
ls.speed = gadgets.NewOneLiner(ls.grid, "refresh speed =")
|
ls.speed = gadgets.NewOneLiner(ls.grid, "refresh speed =")
|
||||||
ls.speedActual = gadgets.NewOneLiner(ls.grid, "refresh speed =")
|
ls.speedActual = gadgets.NewOneLiner(ls.grid, "refresh speed =")
|
||||||
|
|
|
@ -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.12.19
|
||||||
|
go.wit.com/lib/gadgets v0.12.15
|
||||||
|
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.12.19 h1:OEnsnZnec7Q2jZVjwl413V0wuVAAB4r2mGTY0IouBuw=
|
||||||
|
go.wit.com/gui v0.12.19/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA=
|
||||||
|
go.wit.com/lib/gadgets v0.12.15 h1:C9q6wc45Trh5SrizD8lOXOWoJLGq/ESWwzjCVylZrNY=
|
||||||
|
go.wit.com/lib/gadgets v0.12.15/go.mod h1:Fxc7F8hGskpkWVAsXKhs4ilqUlAnikVXj4yzumtTYa0=
|
||||||
|
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=
|
70
hostname.go
70
hostname.go
|
@ -4,6 +4,7 @@ package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
// will try to get this hosts FQDN
|
// will try to get this hosts FQDN
|
||||||
|
@ -11,65 +12,81 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ls *LinuxStatus) GetDomainName() string {
|
func (ls *LinuxStatus) GetDomainName() string {
|
||||||
if ! me.Ready() {return ""}
|
if !me.Ready() {
|
||||||
return me.domainname.Get()
|
return ""
|
||||||
|
}
|
||||||
|
return me.domainname.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) setDomainName() {
|
func (ls *LinuxStatus) setDomainName() {
|
||||||
if ! me.Ready() {return}
|
if !me.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
dn := run("domainname")
|
dn := run("domainname")
|
||||||
if (me.domainname.Get() != 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.Set(dn)
|
me.domainname.SetValue(dn)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) GetHostname() string {
|
func (ls *LinuxStatus) GetHostname() string {
|
||||||
if ! me.Ready() {return ""}
|
if !me.Ready() {
|
||||||
return me.hostname.Get()
|
return ""
|
||||||
|
}
|
||||||
|
return me.hostname.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) ValidHostname() bool {
|
func (ls *LinuxStatus) ValidHostname() bool {
|
||||||
if ! me.Ready() {return false}
|
if !me.Ready() {
|
||||||
if me.hostnameStatus.Get() == "WORKING" {
|
return false
|
||||||
|
}
|
||||||
|
if me.hostnameStatus.String() == "WORKING" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) setHostname(newname string) {
|
func (ls *LinuxStatus) setHostname(newname string) {
|
||||||
if ! me.Ready() {return}
|
if !me.Ready() {
|
||||||
if newname == me.hostname.Get() {
|
return
|
||||||
|
}
|
||||||
|
if newname == me.hostname.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.Set(newname)
|
me.hostname.SetValue(newname)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) GetHostShort() string {
|
func (ls *LinuxStatus) GetHostShort() string {
|
||||||
if ! me.Ready() {return ""}
|
if !me.Ready() {
|
||||||
return me.hostshort.Get()
|
return ""
|
||||||
|
}
|
||||||
|
return me.hostshort.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.String() != hshort {
|
||||||
log.Log(CHANGE, "hostname -s has changed from", me.hostshort.Get(), "to", hshort)
|
log.Log(CHANGE, "hostname -s has changed from", me.hostshort.String(), "to", hshort)
|
||||||
me.hostshort.Set(hshort)
|
me.hostshort.SetValue(hshort)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func lookupHostname() {
|
func lookupHostname() {
|
||||||
if ! me.Ready() {return}
|
if !me.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
var hostfqdn string = "broken"
|
var hostfqdn string = "broken"
|
||||||
hostfqdn, err = fqdn.FqdnHostname()
|
hostfqdn, err = fqdn.FqdnHostname()
|
||||||
if (err != nil) {
|
if err != nil {
|
||||||
log.Error(err, "FQDN hostname error")
|
log.Error(err, "FQDN hostname error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -96,17 +113,17 @@ func lookupHostname() {
|
||||||
|
|
||||||
me.setHostname(test)
|
me.setHostname(test)
|
||||||
|
|
||||||
if (hostname != test) {
|
if hostname != test {
|
||||||
log.Log(CHANGE, "hostname", hostname, "does not equal", test)
|
log.Log(CHANGE, "hostname", hostname, "does not equal", test)
|
||||||
if (me.hostnameStatus.Get() != "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.Set("BROKEN")
|
me.hostnameStatus.SetValue("BROKEN")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (me.hostnameStatus.Get() != "WORKING") {
|
if me.hostnameStatus.String() != "WORKING" {
|
||||||
log.Log(CHANGE, "hostname", hostname, "is valid")
|
log.Log(CHANGE, "hostname", hostname, "is valid")
|
||||||
me.hostnameStatus.Set("WORKING")
|
me.hostnameStatus.SetValue("WORKING")
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,6 +132,7 @@ func lookupHostname() {
|
||||||
// returns true if the hostname is good
|
// returns true if the hostname is good
|
||||||
// check that all the OS settings are correct here
|
// check that all the OS settings are correct here
|
||||||
// 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 {
|
||||||
content, err := ioutil.ReadFile("/etc/hostname")
|
content, err := ioutil.ReadFile("/etc/hostname")
|
||||||
|
@ -132,7 +150,7 @@ func goodHostname() bool {
|
||||||
log.Log(NOW, "hostname short =", hs, "domainname =", dn)
|
log.Log(NOW, "hostname short =", hs, "domainname =", dn)
|
||||||
|
|
||||||
tmp := hs + "." + dn
|
tmp := hs + "." + dn
|
||||||
if (hostname == tmp) {
|
if hostname == tmp {
|
||||||
log.Log(NOW, "hostname seems to be good", hostname)
|
log.Log(NOW, "hostname seems to be good", hostname)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
22
linuxloop.go
22
linuxloop.go
|
@ -11,12 +11,12 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"io/ioutil"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sort"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -36,35 +36,35 @@ func linuxLoop() {
|
||||||
log.Log(CHANGE, "scanInterfaces() detected a change")
|
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
|
// get all the real A records from all the network interfaces linux can see
|
||||||
a := realA()
|
a := realA()
|
||||||
sort.Strings(a)
|
sort.Strings(a)
|
||||||
tmp := strings.Join(a, "\n")
|
tmp := strings.Join(a, "\n")
|
||||||
if tmp != me.workingIPv4.Get() {
|
if tmp != me.workingIPv4.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.workingIPv4.Set(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
|
||||||
aaaa := realAAAA()
|
aaaa := realAAAA()
|
||||||
sort.Strings(aaaa)
|
sort.Strings(aaaa)
|
||||||
tmp = strings.Join(aaaa, "\n")
|
tmp = strings.Join(aaaa, "\n")
|
||||||
if tmp != me.workingIPv6.Get() {
|
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.Set(tmp)
|
me.workingIPv6.SetValue(tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, _ := user.Current()
|
user, _ := user.Current()
|
||||||
tmp = user.Username + " (" + strconv.Itoa(os.Getuid()) + ")"
|
tmp = user.Username + " (" + strconv.Itoa(os.Getuid()) + ")"
|
||||||
if tmp != me.uid.Get() {
|
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.Set(tmp)
|
me.uid.SetValue(tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
content, _ := ioutil.ReadFile("/etc/resolv.conf")
|
content, _ := ioutil.ReadFile("/etc/resolv.conf")
|
||||||
|
@ -79,10 +79,10 @@ func linuxLoop() {
|
||||||
}
|
}
|
||||||
sort.Strings(ns)
|
sort.Strings(ns)
|
||||||
newNS := strings.Join(ns, "\n")
|
newNS := strings.Join(ns, "\n")
|
||||||
if newNS != me.resolver.Get() {
|
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.Set(newNS)
|
me.resolver.SetValue(newNS)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
76
net.go
76
net.go
|
@ -15,7 +15,7 @@ func IsIPv6(address string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *IPtype) IsReal() bool {
|
func (t *IPtype) IsReal() bool {
|
||||||
if (t.ip.IsPrivate() || t.ip.IsLoopback() || t.ip.IsLinkLocalUnicast()) {
|
if t.ip.IsPrivate() || t.ip.IsLoopback() || t.ip.IsLinkLocalUnicast() {
|
||||||
log.Log(NET, "\t\tIP is Real = false")
|
log.Log(NET, "\t\tIP is Real = false")
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +25,7 @@ func (t *IPtype) IsReal() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsReal(ip *net.IP) bool {
|
func IsReal(ip *net.IP) bool {
|
||||||
if (ip.IsPrivate() || ip.IsLoopback() || ip.IsLinkLocalUnicast()) {
|
if ip.IsPrivate() || ip.IsLoopback() || ip.IsLinkLocalUnicast() {
|
||||||
log.Log(NET, "\t\tIP is Real = false")
|
log.Log(NET, "\t\tIP is Real = false")
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,13 +45,13 @@ func renameInterface(i *net.Interface) {
|
||||||
// Will figure out if an interface was just added
|
// Will figure out if an interface was just added
|
||||||
func checkInterface(i net.Interface) {
|
func checkInterface(i net.Interface) {
|
||||||
val, ok := me.ifmap[i.Index]
|
val, ok := me.ifmap[i.Index]
|
||||||
if ! ok {
|
if !ok {
|
||||||
log.Log(INFO, i.Name, "is a new network interface. The linux kernel index =", i.Index)
|
log.Log(INFO, i.Name, "is a new network interface. The linux kernel index =", i.Index)
|
||||||
me.ifmap[i.Index] = new(IFtype)
|
me.ifmap[i.Index] = new(IFtype)
|
||||||
me.ifmap[i.Index].gone = false
|
me.ifmap[i.Index].gone = false
|
||||||
me.ifmap[i.Index].iface = &i
|
me.ifmap[i.Index].iface = &i
|
||||||
me.changed = true
|
me.changed = true
|
||||||
if (me.Interfaces != nil) {
|
if me.Interfaces != nil {
|
||||||
me.Interfaces.AddText(i.Name)
|
me.Interfaces.AddText(i.Name)
|
||||||
me.Interfaces.SetText(i.Name)
|
me.Interfaces.SetText(i.Name)
|
||||||
}
|
}
|
||||||
|
@ -59,11 +59,11 @@ func checkInterface(i net.Interface) {
|
||||||
}
|
}
|
||||||
me.ifmap[i.Index].gone = false
|
me.ifmap[i.Index].gone = false
|
||||||
log.Log(NET, "me.ifmap[i] does exist. Need to compare everything.", i.Index, i.Name, val.iface.Index, val.iface.Name)
|
log.Log(NET, "me.ifmap[i] does exist. Need to compare everything.", i.Index, i.Name, val.iface.Index, val.iface.Name)
|
||||||
if (val.iface.Name != i.Name) {
|
if val.iface.Name != i.Name {
|
||||||
log.Log(INFO, val.iface.Name, "has changed to it's name to", i.Name)
|
log.Log(INFO, val.iface.Name, "has changed to it's name to", i.Name)
|
||||||
me.ifmap[i.Index].iface = &i
|
me.ifmap[i.Index].iface = &i
|
||||||
me.changed = true
|
me.changed = true
|
||||||
if (me.Interfaces != nil) {
|
if me.Interfaces != nil {
|
||||||
me.Interfaces.AddText(i.Name)
|
me.Interfaces.AddText(i.Name)
|
||||||
me.Interfaces.SetText(i.Name)
|
me.Interfaces.SetText(i.Name)
|
||||||
}
|
}
|
||||||
|
@ -72,15 +72,15 @@ 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 realAAAA() []string {
|
func realAAAA() []string {
|
||||||
var aaaa []string
|
var aaaa []string
|
||||||
|
|
||||||
for s, t := range me.ipmap {
|
for s, t := range me.ipmap {
|
||||||
if (t.IsReal()) {
|
if t.IsReal() {
|
||||||
if (t.ipv6) {
|
if t.ipv6 {
|
||||||
aaaa = append(aaaa, s)
|
aaaa = append(aaaa, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,8 @@ func realA() []string {
|
||||||
var a []string
|
var a []string
|
||||||
|
|
||||||
for s, t := range me.ipmap {
|
for s, t := range me.ipmap {
|
||||||
if (t.IsReal()) {
|
if t.IsReal() {
|
||||||
if (t.ipv4) {
|
if t.ipv4 {
|
||||||
a = append(a, s)
|
a = append(a, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,12 +111,12 @@ func checkDNS() (map[string]*IPtype, map[string]*IPtype) {
|
||||||
for s, t := range me.ipmap {
|
for s, t := range me.ipmap {
|
||||||
i := t.iface
|
i := t.iface
|
||||||
ipt := "IPv4"
|
ipt := "IPv4"
|
||||||
if (t.ipv6) {
|
if t.ipv6 {
|
||||||
ipt = "IPv6"
|
ipt = "IPv6"
|
||||||
}
|
}
|
||||||
if (t.IsReal()) {
|
if t.IsReal() {
|
||||||
log.Log(INFO, "\tIP is Real ", ipt, i.Index, i.Name, s)
|
log.Log(INFO, "\tIP is Real ", ipt, i.Index, i.Name, s)
|
||||||
if (t.ipv6) {
|
if t.ipv6 {
|
||||||
ipv6s[s] = t
|
ipv6s[s] = t
|
||||||
} else {
|
} else {
|
||||||
ipv4s[s] = t
|
ipv4s[s] = t
|
||||||
|
@ -149,21 +149,21 @@ func checkIP(ip *net.IPNet, i net.Interface) bool {
|
||||||
me.ipmap[realip].ip = ip.IP
|
me.ipmap[realip].ip = ip.IP
|
||||||
me.ipmap[realip].iface = &i
|
me.ipmap[realip].iface = &i
|
||||||
t := "IPv4"
|
t := "IPv4"
|
||||||
if (IsIPv6(ip.String())) {
|
if IsIPv6(ip.String()) {
|
||||||
me.ipmap[realip].ipv6 = true
|
me.ipmap[realip].ipv6 = true
|
||||||
me.ipmap[realip].ipv4 = false
|
me.ipmap[realip].ipv4 = false
|
||||||
t = "IPv6"
|
t = "IPv6"
|
||||||
if (me.IPv6 != nil) {
|
if me.IPv6 != nil {
|
||||||
me.IPv6.Set(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.Set(realip)
|
me.IPv4.SetValue(realip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (IsReal(&ip.IP)) {
|
if IsReal(&ip.IP) {
|
||||||
log.Log(INFO, "\tIP is Real ", t, i.Index, i.Name, realip)
|
log.Log(INFO, "\tIP is Real ", t, i.Index, i.Name, realip)
|
||||||
} else {
|
} else {
|
||||||
log.Log(INFO, "\tIP is not Real", t, i.Index, i.Name, realip)
|
log.Log(INFO, "\tIP is not Real", t, i.Index, i.Name, realip)
|
||||||
|
@ -215,10 +215,10 @@ func updateRealAAAA() {
|
||||||
var all4 []string
|
var all4 []string
|
||||||
var all6 []string
|
var all6 []string
|
||||||
for s, t := range me.ipmap {
|
for s, t := range me.ipmap {
|
||||||
if (t.ipv4) {
|
if t.ipv4 {
|
||||||
all4 = append(all4, s)
|
all4 = append(all4, s)
|
||||||
log.Log(NET, "IPv4 =", s)
|
log.Log(NET, "IPv4 =", s)
|
||||||
} else if (t.ipv6) {
|
} else if t.ipv6 {
|
||||||
all6 = append(all6, s)
|
all6 = append(all6, s)
|
||||||
log.Log(NET, "IPv6 =", s)
|
log.Log(NET, "IPv6 =", s)
|
||||||
} else {
|
} else {
|
||||||
|
@ -232,14 +232,14 @@ func updateRealAAAA() {
|
||||||
s4 := strings.Join(all4, "\n")
|
s4 := strings.Join(all4, "\n")
|
||||||
s6 := strings.Join(all6, "\n")
|
s6 := strings.Join(all6, "\n")
|
||||||
|
|
||||||
if (me.IPv4.Get() != s4) {
|
if me.IPv4.String() != s4 {
|
||||||
log.Log(CHANGE, "IPv4 addresses have changed", s4)
|
log.Log(CHANGE, "IPv4 addresses have changed", s4)
|
||||||
me.IPv4.Set(s4)
|
me.IPv4.SetValue(s4)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
if (me.IPv6.Get() != s6) {
|
if me.IPv6.String() != s6 {
|
||||||
log.Log(CHANGE, "IPv6 addresses have changed", s6)
|
log.Log(CHANGE, "IPv6 addresses have changed", s6)
|
||||||
me.IPv6.Set(s6)
|
me.IPv6.SetValue(s6)
|
||||||
me.changed = true
|
me.changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ func updateRealAAAA() {
|
||||||
func deleteChanges() bool {
|
func deleteChanges() 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 {
|
||||||
log.Log(CHANGE, "DELETE int =", i, "name =", t.name, t.iface)
|
log.Log(CHANGE, "DELETE int =", i, "name =", t.name, t.iface)
|
||||||
delete(me.ifmap, i)
|
delete(me.ifmap, i)
|
||||||
changed = true
|
changed = true
|
||||||
|
@ -256,7 +256,7 @@ func deleteChanges() bool {
|
||||||
t.gone = true
|
t.gone = true
|
||||||
}
|
}
|
||||||
for s, t := range me.ipmap {
|
for s, t := range me.ipmap {
|
||||||
if (t.gone) {
|
if t.gone {
|
||||||
log.Log(CHANGE, "DELETE name =", s, "IPv4 =", t.ipv4)
|
log.Log(CHANGE, "DELETE name =", s, "IPv4 =", t.ipv4)
|
||||||
log.Log(CHANGE, "DELETE name =", s, "IPv6 =", t.ipv6)
|
log.Log(CHANGE, "DELETE name =", s, "IPv6 =", t.ipv6)
|
||||||
log.Log(CHANGE, "DELETE name =", s, "iface =", t.iface)
|
log.Log(CHANGE, "DELETE name =", s, "iface =", t.iface)
|
||||||
|
@ -271,19 +271,25 @@ func deleteChanges() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) GetIPv6() []string {
|
func (ls *LinuxStatus) GetIPv6() []string {
|
||||||
if ! me.Ready() {return nil}
|
if !me.Ready() {
|
||||||
tmp := me.workingIPv6.Get()
|
return nil
|
||||||
|
}
|
||||||
|
tmp := me.workingIPv6.String()
|
||||||
return strings.Split(tmp, "\n")
|
return strings.Split(tmp, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) GetIPv4() []string {
|
func (ls *LinuxStatus) GetIPv4() []string {
|
||||||
if ! me.Ready() {return nil}
|
if !me.Ready() {
|
||||||
tmp := me.workingIPv4.Get()
|
return nil
|
||||||
|
}
|
||||||
|
tmp := me.workingIPv4.String()
|
||||||
return strings.Split(tmp, "\n")
|
return strings.Split(tmp, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) GetNameservers() []string {
|
func (ls *LinuxStatus) GetNameservers() []string {
|
||||||
if ! me.Ready() {return nil}
|
if !me.Ready() {
|
||||||
tmp := me.resolver.Get()
|
return nil
|
||||||
|
}
|
||||||
|
tmp := me.resolver.String()
|
||||||
return strings.Split(tmp, "\n")
|
return strings.Split(tmp, "\n")
|
||||||
}
|
}
|
||||||
|
|
6
new.go
6
new.go
|
@ -4,7 +4,7 @@ package linuxstatus
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New() *LinuxStatus {
|
func New() *LinuxStatus {
|
||||||
|
@ -12,7 +12,7 @@ func New() *LinuxStatus {
|
||||||
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
|
||||||
}
|
}
|
||||||
me = &LinuxStatus {
|
me = &LinuxStatus{
|
||||||
hidden: true,
|
hidden: true,
|
||||||
ready: false,
|
ready: false,
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ func New() *LinuxStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) InitWindow() {
|
func (ls *LinuxStatus) InitWindow() {
|
||||||
if ! ls.Initialized() {
|
if !ls.Initialized() {
|
||||||
log.Log(WARN, "not initalized yet (no parent for the window?)")
|
log.Log(WARN, "not initalized yet (no parent for the window?)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
6
proc.go
6
proc.go
|
@ -26,7 +26,7 @@ func GetProcessNameByPort(port int) string {
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
fields := strings.Fields(line)
|
fields := strings.Fields(line)
|
||||||
log.Log(PROC, "searchProcNet() portHex:", portHex)
|
log.Log(PROC, "searchProcNet() portHex:", portHex)
|
||||||
if (len(fields) > 9) {
|
if len(fields) > 9 {
|
||||||
log.Log(PROC, "searchProcNet() fields[9]", fields[9])
|
log.Log(PROC, "searchProcNet() fields[9]", fields[9])
|
||||||
}
|
}
|
||||||
log.Log(PROC, "searchProcNet() lines:", line)
|
log.Log(PROC, "searchProcNet() lines:", line)
|
||||||
|
@ -36,7 +36,7 @@ func GetProcessNameByPort(port int) string {
|
||||||
// Convert the hexadecimal string to an integer
|
// Convert the hexadecimal string to an integer
|
||||||
value, _ := strconv.ParseInt(parts[1], 16, 64)
|
value, _ := strconv.ParseInt(parts[1], 16, 64)
|
||||||
log.Log(PROC, "searchProcNet() value, port =", value, port, "parts[1] =", parts[1])
|
log.Log(PROC, "searchProcNet() value, port =", value, port, "parts[1] =", parts[1])
|
||||||
if (port == int(value)) {
|
if port == int(value) {
|
||||||
log.Log(PROC, "searchProcNet() THIS IS THE LINE:", fields)
|
log.Log(PROC, "searchProcNet() THIS IS THE LINE:", fields)
|
||||||
return fields[9]
|
return fields[9]
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func GetProcessNameByPort(port int) string {
|
||||||
for _, fd := range fds {
|
for _, fd := range fds {
|
||||||
fdLink, _ := os.Readlink(filepath.Join(fdPath, fd.Name()))
|
fdLink, _ := os.Readlink(filepath.Join(fdPath, fd.Name()))
|
||||||
var s string
|
var s string
|
||||||
s = "socket:["+inode+"]"
|
s = "socket:[" + inode + "]"
|
||||||
if strings.Contains(fdLink, "socket:[") {
|
if strings.Contains(fdLink, "socket:[") {
|
||||||
log.Log(PROC, "searchProcNet() fdLink has socket:", fdLink)
|
log.Log(PROC, "searchProcNet() fdLink has socket:", fdLink)
|
||||||
log.Log(PROC, "searchProcNet() proc.Name() =", proc.Name(), "s =", s)
|
log.Log(PROC, "searchProcNet() proc.Name() =", proc.Name(), "s =", s)
|
||||||
|
|
|
@ -7,8 +7,9 @@ package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/gui"
|
||||||
|
"go.wit.com/lib/gadgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
var me *LinuxStatus
|
var me *LinuxStatus
|
||||||
|
@ -40,7 +41,6 @@ type LinuxStatus struct {
|
||||||
Interfaces *gui.Node
|
Interfaces *gui.Node
|
||||||
speed *gadgets.OneLiner
|
speed *gadgets.OneLiner
|
||||||
speedActual *gadgets.OneLiner
|
speedActual *gadgets.OneLiner
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPtype struct {
|
type IPtype struct {
|
||||||
|
|
8
timer.go
8
timer.go
|
@ -1,9 +1,9 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// timeFunction takes a function as an argument and returns the execution time.
|
// timeFunction takes a function as an argument and returns the execution time.
|
||||||
|
@ -31,6 +31,8 @@ func sortLines(input string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LinuxStatus) SetSpeedActual(s string) {
|
func (ls *LinuxStatus) SetSpeedActual(s string) {
|
||||||
if ! ls.Ready() {return}
|
if !ls.Ready() {
|
||||||
ls.speedActual.Set(s)
|
return
|
||||||
|
}
|
||||||
|
ls.speedActual.SetValue(s)
|
||||||
}
|
}
|
||||||
|
|
12
unix.go
12
unix.go
|
@ -5,11 +5,11 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"net"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -57,14 +57,14 @@ func dumpIPs(host string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
check if ddclient is installed, working, and/or configured
|
check if ddclient is installed, working, and/or configured
|
||||||
https://github.com/ddclient/ddclient
|
https://github.com/ddclient/ddclient
|
||||||
*/
|
*/
|
||||||
func ddclient() {
|
func ddclient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
check if ddupdate is installed, working, and/or configured
|
check if ddupdate is installed, working, and/or configured
|
||||||
*/
|
*/
|
||||||
func ddupdate() {
|
func ddupdate() {
|
||||||
}
|
}
|
||||||
|
|
18
update.go
18
update.go
|
@ -1,21 +1,21 @@
|
||||||
package linuxstatus
|
package linuxstatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ls *LinuxStatus) Update() {
|
func (ls *LinuxStatus) Update() {
|
||||||
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"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Log(INFO, "Update() START")
|
log.Log(INFO, "Update() START")
|
||||||
duration := timeFunction(func () {
|
duration := timeFunction(func() {
|
||||||
linuxLoop()
|
linuxLoop()
|
||||||
})
|
})
|
||||||
ls.setSpeed(duration)
|
ls.setSpeed(duration)
|
||||||
|
@ -28,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.Set(s)
|
ls.speedActual.SetValue(s)
|
||||||
|
|
||||||
if (duration > 500 * time.Millisecond ) {
|
if duration > 500*time.Millisecond {
|
||||||
ls.speed.Set("SLOW")
|
ls.speed.SetValue("SLOW")
|
||||||
} else if (duration > 100 * time.Millisecond ) {
|
} else if duration > 100*time.Millisecond {
|
||||||
ls.speed.Set("OK")
|
ls.speed.SetValue("OK")
|
||||||
} else {
|
} else {
|
||||||
ls.speed.Set("FAST")
|
ls.speed.SetValue("FAST")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue