add interfaces to the dropdown menu
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
0b26e5f1ca
commit
8e2f94c4ac
34
Makefile
34
Makefile
|
@ -1,6 +1,10 @@
|
|||
run: build
|
||||
./control-panel-dns
|
||||
|
||||
install:
|
||||
go install -v go.wit.com/control-panel-dns@latest
|
||||
# go install -v git.wit.com/wit/control-panel-dns@latest
|
||||
|
||||
debug: build
|
||||
./control-panel-dns --verbose --verbose-net --gui-debug
|
||||
|
||||
|
@ -17,6 +21,12 @@ build:
|
|||
# GO111MODULE="off" go get -v -x .
|
||||
GO111MODULE="off" go build -v -o control-panel-dns
|
||||
|
||||
# ./control-panel-dns.v1: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./control-panel-dns.v1)
|
||||
# ./control-panel-dns.v1: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./control-panel-dns.v1)
|
||||
# compiling with CGO disabled means it compiles but then plugins don't load
|
||||
GLIBC_2.34-error:
|
||||
GO111MODULE="off" CGO_ENABLED=0 go build -v -o control-panel-dns
|
||||
|
||||
test:
|
||||
GO111MODULE="off" go test -v
|
||||
|
||||
|
@ -57,3 +67,27 @@ build-with-custom-go.mod:
|
|||
# )
|
||||
# replace github.com/versent/saml2aws/v2 v2.35.0 => github.com/marcottedan/saml2aws/v2 master
|
||||
# replace github.com/versent/saml2aws/v2 => /Users/dmarcotte/git/saml2aws/
|
||||
#
|
||||
check-cert:
|
||||
reset
|
||||
# https://crt.sh/?q=check.lab.wit.org
|
||||
# # https://letsencrypt.org/certificates/
|
||||
# openssl s_client -connect check.lab.wit.org:443 -showcerts
|
||||
openssl s_client -CApath /etc/ssl/certs/ -connect check.lab.wit.org:443 -showcerts
|
||||
# openssl s_client -CApath /etc/ssl/certs/ -connect check.lab.wit.org:443 -showcerts -trace -debug
|
||||
# openssl s_client -CAfile isrgrootx1.pem -connect check.lab.wit.org:443 -showcerts
|
||||
# cat isrgrootx1.pem lets-encrypt-r3.pem > full-chain.pem
|
||||
# full-chain.pem
|
||||
# openssl s_client -CAfile /etc/ssl/certs/wit-full-chain.pem -connect check.lab.wit.org:443 -showcerts
|
||||
|
||||
ssl-cert-hash:
|
||||
openssl x509 -hash -noout -in wit-full-chain.pem
|
||||
# cd /etc/ssl/certs && ln -s wit-full-chain.pem 4042bcee.0
|
||||
openssl x509 -hash -noout -in isrgrootx1.pem
|
||||
openssl x509 -hash -noout -in lets-encrypt-r3.pem
|
||||
|
||||
sudo-cp:
|
||||
sudo cp -a lets-encrypt-r3.pem 8d33f237.0 /etc/ssl/certs/
|
||||
|
||||
go-get:
|
||||
go install -v check.lab.wit.org/gui
|
||||
|
|
39
gui.go
39
gui.go
|
@ -18,12 +18,12 @@ func initGUI() {
|
|||
gui.Config.Exit = myDefaultExit
|
||||
|
||||
me.window = gui.NewWindow()
|
||||
me.window.Dump()
|
||||
addDNSTab("DNS")
|
||||
|
||||
if (args.GuiDebug) {
|
||||
gui.DebugWindow()
|
||||
}
|
||||
gui.ShowDebugValues()
|
||||
}
|
||||
|
||||
func addDNSTab(title string) {
|
||||
|
@ -68,7 +68,7 @@ func addDNSTab(title string) {
|
|||
Escalate()
|
||||
})
|
||||
g2.NewButton("pprof(goroutine)", func () {
|
||||
loggo()
|
||||
// loggo()
|
||||
// panic("correctly inside of gui goroutine (goroutine 1?)")
|
||||
})
|
||||
g2.NewButton("gui.DebugWindow()", func () {
|
||||
|
@ -106,10 +106,35 @@ func myDefaultExit(n *gui.Node) {
|
|||
|
||||
func nsupdateGroup(w *gui.Node) {
|
||||
g := w.NewGroup("dns update")
|
||||
me.uid = g.NewLabel("UID = " + me.user)
|
||||
me.fqdn = g.NewLabel("fqdn:")
|
||||
me.IPv4 = g.NewLabel("192.168.2.2")
|
||||
me.IPv6 = g.NewLabel("fe::02")
|
||||
|
||||
grid := g.NewGrid("fucknuts", 2, 2)
|
||||
|
||||
grid.SetNext(1,1)
|
||||
grid.NewLabel("hostname =")
|
||||
grid.SetNext(1,2)
|
||||
me.fqdn = grid.NewCombobox("foo(0,1)")
|
||||
me.fqdn.AddText("fire.lab.wit.com")
|
||||
me.fqdn.AddText("mirrors.wit.com")
|
||||
me.fqdn.SetText("sad.lab.wit.org")
|
||||
|
||||
grid.SetNext(2,1)
|
||||
grid.NewLabel("UID =")
|
||||
grid.SetNext(2,2)
|
||||
me.uid = grid.NewCombobox("foo(1,1)")
|
||||
me.uid.AddText("root (0)")
|
||||
me.uid.AddText("mail (8)")
|
||||
me.uid.AddText("jcarr (1000)")
|
||||
|
||||
grid.NewLabel("IPv4 =")
|
||||
me.IPv4 = grid.NewCombobox("foo(2,1)")
|
||||
|
||||
grid.NewLabel("IPv6 =")
|
||||
me.IPv6 = grid.NewCombobox("foo(1,3)")
|
||||
|
||||
grid.NewLabel("interfaces =")
|
||||
me.Interfaces = grid.NewCombobox("foo(1,3)")
|
||||
me.Interfaces.AddText("jcarr0")
|
||||
|
||||
g.NewButton("DNS AAAA", func () {
|
||||
var aaaa []string
|
||||
var out string
|
||||
|
@ -139,5 +164,5 @@ func output(s string, a bool) {
|
|||
outJunk = s
|
||||
}
|
||||
me.output.SetText(outJunk)
|
||||
//log(outJunk)
|
||||
log(outJunk)
|
||||
}
|
||||
|
|
128
log.go
128
log.go
|
@ -1,123 +1,29 @@
|
|||
//
|
||||
// version v1.1
|
||||
//
|
||||
// I like things to be easy.
|
||||
//
|
||||
// this means all the log settings are in one place. it should allow
|
||||
// things to be over-ridden externally to the library
|
||||
// but still allow command line --args to pass debugging settings
|
||||
//
|
||||
// I also have a generic sleep() and exit() in here because it's simple
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// log("something", foo, bar)
|
||||
// var DEBUG bool = true
|
||||
// log(DEBUG, "something else", someOtherVariable) # if DEBUG == false, return doing nothing
|
||||
// log(SPEW, "something else", someOtherVariable) # this get's sent to spew.Dump(). Very useful for debugging!
|
||||
//
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
golog "log"
|
||||
"time"
|
||||
"reflect"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
// "net"
|
||||
witlog "git.wit.org/wit/gui/log"
|
||||
)
|
||||
|
||||
var LOGOFF bool = false // turn this off, all logging stops
|
||||
var WARN bool
|
||||
var INFO bool
|
||||
// various debugging flags
|
||||
var logNow bool = true // useful for active development
|
||||
var logError bool = true
|
||||
var logWarn bool = false
|
||||
var logInfo bool = false
|
||||
var logVerbose bool = false
|
||||
|
||||
type spewt struct {
|
||||
a bool
|
||||
}
|
||||
var SPEW witlog.Spewt
|
||||
|
||||
var SPEW spewt
|
||||
|
||||
|
||||
/*
|
||||
sleep() # you know what this does? sleeps for 1 second. yep. dump. easy.
|
||||
sleep(.1) # you know what this does? yes, it sleeps for 1/10th of a second
|
||||
*/
|
||||
func sleep(a ...any) {
|
||||
if (a == nil) {
|
||||
time.Sleep(time.Second)
|
||||
return
|
||||
}
|
||||
|
||||
log(args.Verbose, "sleep", a[0])
|
||||
|
||||
switch a[0].(type) {
|
||||
case int:
|
||||
time.Sleep(time.Duration(a[0].(int)) * time.Second)
|
||||
case float64:
|
||||
time.Sleep(time.Duration(a[0].(float64) * 1000) * time.Millisecond)
|
||||
default:
|
||||
log("sleep a[0], type = ", a[0], reflect.TypeOf(a[0]))
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
exit() # yep. exits. I guess everything must be fine
|
||||
exit(3) # I guess 3 it is then
|
||||
exit("dont like apples") # ok. I'll make a note of that
|
||||
*/
|
||||
func exit(a ...any) {
|
||||
log("exit", a)
|
||||
//if (a) {
|
||||
// os.Exit(a)
|
||||
//}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
/*
|
||||
I've spent, am spending, too much time thinking about 'logging'. 'log', 'logrus', 'zap', whatever.
|
||||
I'm not twitter. i don't give a fuck about how many nanoseconds it takes to log. Anyway, this
|
||||
implementation is probably faster than all of those because you just set one bool to FALSE
|
||||
and it all stops.
|
||||
Sometimes I need to capture to stdout, sometimes stdout can't
|
||||
work because it doesn't exist for the user. This whole thing is a PITA. Then it's spread
|
||||
over 8 million references in every .go file. I'm tapping out and putting
|
||||
it in one place. here it is. Also, this makes having debug levels really fucking easy.
|
||||
You can define whatever level of logging you want from anywhere (command line) etc.
|
||||
|
||||
log() # doesn't do anything
|
||||
log(stuff) # sends it to whatever log you define in a single place. here is the place
|
||||
*/
|
||||
// var log interface{}
|
||||
|
||||
func log(a ...any) {
|
||||
if (LOGOFF) {
|
||||
return
|
||||
}
|
||||
|
||||
if (a == nil) {
|
||||
return
|
||||
}
|
||||
var blah bool
|
||||
if (reflect.TypeOf(a[0]) == reflect.TypeOf(blah)) {
|
||||
if (a[0] == false) {
|
||||
return
|
||||
}
|
||||
a = a[1:]
|
||||
}
|
||||
|
||||
if (reflect.TypeOf(a[0]) == reflect.TypeOf(SPEW)) {
|
||||
a = a[1:]
|
||||
// spew.Dump(a)
|
||||
scs := spew.ConfigState{MaxDepth: 1}
|
||||
scs.Dump(a)
|
||||
return
|
||||
}
|
||||
|
||||
golog.Println(a...)
|
||||
witlog.Where = "wit/gui"
|
||||
witlog.Log(a...)
|
||||
}
|
||||
|
||||
func loggo() {
|
||||
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||
log("runtime.NumGoroutine() = ", runtime.NumGoroutine())
|
||||
func sleep(a ...any) {
|
||||
witlog.Sleep(a...)
|
||||
}
|
||||
|
||||
func exit(a ...any) {
|
||||
witlog.Exit(a...)
|
||||
}
|
||||
|
|
6
main.go
6
main.go
|
@ -40,7 +40,7 @@ func main() {
|
|||
|
||||
log("Toolkit = ", args.Toolkit)
|
||||
// gui.InitPlugins([]string{"andlabs"})
|
||||
gui.SetDebug(args.GuiDebug)
|
||||
gui.SetDebug(true)
|
||||
gui.Main(initGUI)
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func checkNetworkChanges() {
|
|||
|
||||
// Run this every once and a while
|
||||
func dnsTTL() {
|
||||
output("FQDN = " + me.fqdn.GetText() + "\n", true)
|
||||
output("FQDN = " + me.fqdn.GetText() + "\n", false)
|
||||
getHostname()
|
||||
scanInterfaces()
|
||||
for i, t := range me.ifmap {
|
||||
|
@ -75,6 +75,8 @@ func dnsTTL() {
|
|||
aaaa = realAAAA()
|
||||
for _, s := range aaaa {
|
||||
output("my actual AAAA = " + s + "\n", true)
|
||||
me.IPv6.AddText(s)
|
||||
me.IPv6.SetText(s)
|
||||
}
|
||||
// loggo()
|
||||
}
|
||||
|
|
6
net.go
6
net.go
|
@ -79,6 +79,9 @@ func checkInterface(i net.Interface) {
|
|||
me.ifmap[i.Index].gone = false
|
||||
me.ifmap[i.Index].iface = &i
|
||||
me.ipchange = true
|
||||
if (me.Interfaces != nil) {
|
||||
me.Interfaces.AddText(i.Name)
|
||||
}
|
||||
return
|
||||
}
|
||||
me.ifmap[i.Index].gone = false
|
||||
|
@ -87,6 +90,9 @@ func checkInterface(i net.Interface) {
|
|||
log(val.iface.Name, "has changed to it's name to", i.Name)
|
||||
me.ifmap[i.Index].iface = &i
|
||||
me.ipchange = true
|
||||
if (me.Interfaces != nil) {
|
||||
me.Interfaces.AddText(i.Name)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ type Host struct {
|
|||
fqdn *gui.Node // display the full hostname
|
||||
IPv4 *gui.Node // show valid IPv4 addresses
|
||||
IPv6 *gui.Node // show valid IPv6 addresses
|
||||
Interfaces *gui.Node // Interfaces
|
||||
}
|
||||
|
||||
type IPtype struct {
|
||||
|
|
Loading…
Reference in New Issue