Compare commits
No commits in common. "c16bb5b088ce71fd6d032228b505cb5e133fcb3c" and "3ce3a39226bd6c0e738cdf76a55b05be1bad3cc3" have entirely different histories.
c16bb5b088
...
3ce3a39226
|
@ -1,4 +1,3 @@
|
||||||
control-panel-dns
|
control-panel-dns
|
||||||
/files/*
|
/files/*
|
||||||
/*.deb
|
/*.deb
|
||||||
*.swp
|
|
||||||
|
|
40
Makefile
40
Makefile
|
@ -1,9 +1,5 @@
|
||||||
run: build
|
run: build
|
||||||
./control-panel-dns >/tmp/witgui.log.stderr 2>&1
|
./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
|
debug: build
|
||||||
./control-panel-dns --verbose --verbose-net --gui-debug
|
./control-panel-dns --verbose --verbose-net --gui-debug
|
||||||
|
@ -21,12 +17,6 @@ build:
|
||||||
# GO111MODULE="off" go get -v -x .
|
# GO111MODULE="off" go get -v -x .
|
||||||
GO111MODULE="off" go build -v -o control-panel-dns
|
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:
|
test:
|
||||||
GO111MODULE="off" go test -v
|
GO111MODULE="off" go test -v
|
||||||
|
|
||||||
|
@ -67,31 +57,3 @@ 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 v2.35.0 => github.com/marcottedan/saml2aws/v2 master
|
||||||
# replace github.com/versent/saml2aws/v2 => /Users/dmarcotte/git/saml2aws/
|
# 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
|
|
||||||
|
|
||||||
log:
|
|
||||||
reset
|
|
||||||
tail -f /tmp/witgui.* /tmp/guilogfile
|
|
||||||
|
|
1
args.go
1
args.go
|
@ -12,7 +12,6 @@ type LogOptions struct {
|
||||||
VerboseDNS bool `arg:"--verbose-dns" help:"debug your dns settings"`
|
VerboseDNS bool `arg:"--verbose-dns" help:"debug your dns settings"`
|
||||||
LogFile string `help:"write all output to a file"`
|
LogFile string `help:"write all output to a file"`
|
||||||
// User string `arg:"env:USER"`
|
// User string `arg:"env:USER"`
|
||||||
Display string `arg:"env:DISPLAY"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var args struct {
|
var args struct {
|
||||||
|
|
59
bash.go
59
bash.go
|
@ -1,59 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"os/signal"
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/creack/pty"
|
|
||||||
"golang.org/x/term"
|
|
||||||
)
|
|
||||||
|
|
||||||
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("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(logError, "exit in mainBash()")
|
|
||||||
exit(err)
|
|
||||||
}
|
|
||||||
}
|
|
2
dns.go
2
dns.go
|
@ -23,7 +23,7 @@ func (h *Host) verifyETC() bool {
|
||||||
func (h *Host) updateIPs(host string) {
|
func (h *Host) updateIPs(host string) {
|
||||||
ips, err := net.LookupIP(host)
|
ips, err := net.LookupIP(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log(logError, "updateIPs failed", err)
|
exit(err)
|
||||||
}
|
}
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
log(host, ip)
|
log(host, ip)
|
||||||
|
|
|
@ -13,8 +13,7 @@ func watchSysClassNet() {
|
||||||
// Create new watcher.
|
// Create new watcher.
|
||||||
watcher, err := fsnotify.NewWatcher()
|
watcher, err := fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log(logError, "watchSysClassNet() failed:", err)
|
exit(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
defer watcher.Close()
|
defer watcher.Close()
|
||||||
|
|
||||||
|
@ -42,8 +41,7 @@ func watchSysClassNet() {
|
||||||
// Add a path.
|
// Add a path.
|
||||||
err = watcher.Add("/tmp")
|
err = watcher.Add("/tmp")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log(logError, "watchSysClassNet() watcher.Add() failed:", err)
|
exit(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block main goroutine forever.
|
// Block main goroutine forever.
|
||||||
|
|
170
gui.go
170
gui.go
|
@ -2,64 +2,68 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"net"
|
"net"
|
||||||
"git.wit.org/wit/gui"
|
"git.wit.org/wit/gui"
|
||||||
"git.wit.org/wit/shell"
|
"git.wit.org/wit/shell"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This setups up the dns control panel window
|
// This initializes the first window
|
||||||
func setupControlPanelWindow() {
|
func initGUI() {
|
||||||
me.window = myGui.New2().Window("DNS and IPv6 Control Panel").Standard()
|
gui.Config.Title = "DNS and IPv6 Control Panel"
|
||||||
me.window.Dump(true)
|
gui.Config.Width = 640
|
||||||
|
gui.Config.Height = 480
|
||||||
|
gui.Config.Exit = myDefaultExit
|
||||||
|
|
||||||
sleep(1)
|
me.window = gui.NewWindow()
|
||||||
|
me.window.Dump()
|
||||||
addDNSTab("DNS")
|
addDNSTab("DNS")
|
||||||
|
|
||||||
if (args.GuiDebug) {
|
if (args.GuiDebug) {
|
||||||
gui.DebugWindow()
|
gui.DebugWindow()
|
||||||
}
|
}
|
||||||
gui.ShowDebugValues()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func addDNSTab(title string) {
|
func addDNSTab(title string) {
|
||||||
var g2 *gui.Node
|
var g2 *gui.Node
|
||||||
|
|
||||||
me.tab = me.window.NewTab(title)
|
me.tab = me.window.NewTab(title)
|
||||||
|
// log("addDemoTab() newNode.Dump")
|
||||||
|
// newNode.Dump()
|
||||||
|
|
||||||
|
me.notes = me.tab.NewGroup("junk")
|
||||||
|
dd := me.notes.NewDropdown("demoCombo2")
|
||||||
|
dd.AddDropdownName("more 1")
|
||||||
|
dd.AddDropdownName("more 2")
|
||||||
|
dd.AddDropdownName("more 3")
|
||||||
|
dd.Custom = func() {
|
||||||
|
s := dd.GetText()
|
||||||
|
output("dd.Custom( dd.GetText() ) =" + s + "\n", true)
|
||||||
|
}
|
||||||
|
me.notes.NewButton("hello", func () {
|
||||||
|
log("world")
|
||||||
|
})
|
||||||
|
|
||||||
g2 = me.tab.NewGroup("Real Stuff")
|
g2 = me.tab.NewGroup("Real Stuff")
|
||||||
|
|
||||||
g2.NewButton("gui.DebugWindow()", func () {
|
|
||||||
gui.DebugWindow()
|
|
||||||
})
|
|
||||||
|
|
||||||
g2.NewButton("Load 'gocui'", func () {
|
|
||||||
// this set the xterm and mate-terminal window title. maybe works generally?
|
|
||||||
fmt.Println("\033]0;" + title + "blah \007")
|
|
||||||
gui.StartS("gocui")
|
|
||||||
gui.Redraw("gocui")
|
|
||||||
})
|
|
||||||
|
|
||||||
g2.NewButton("Network Interfaces", func () {
|
g2.NewButton("Network Interfaces", func () {
|
||||||
for i, t := range me.ifmap {
|
for i, t := range me.ifmap {
|
||||||
log("name =", t.iface.Name)
|
log("name =", t.iface.Name)
|
||||||
log("int =", i, "name =", t.name, t.iface)
|
log("int =", i, "name =", t.name, t.iface)
|
||||||
log("iface = " + t.iface.Name)
|
output("iface = " + t.iface.Name + "\n", true)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
g2.NewButton("Hostname", func () {
|
g2.NewButton("Hostname", func () {
|
||||||
getHostname()
|
getHostname()
|
||||||
|
output("FQDN = " + me.fqdn + "\n", true)
|
||||||
})
|
})
|
||||||
g2.NewButton("Actual AAAA", func () {
|
g2.NewButton("Actual AAAA", func () {
|
||||||
var aaaa []string
|
var aaaa []string
|
||||||
aaaa = realAAAA()
|
aaaa = realAAAA()
|
||||||
for _, s := range aaaa {
|
for _, s := range aaaa {
|
||||||
log("my actual AAAA = ", s)
|
output("my actual AAAA = " + s + "\n", true)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -69,15 +73,7 @@ func addDNSTab(title string) {
|
||||||
g2.NewButton("os.User()", func () {
|
g2.NewButton("os.User()", func () {
|
||||||
user, _ := user.Current()
|
user, _ := user.Current()
|
||||||
spew.Dump(user)
|
spew.Dump(user)
|
||||||
log("os.Getuid =", user.Username, os.Getuid())
|
log("os.Getuid =", os.Getuid())
|
||||||
if (me.uid != nil) {
|
|
||||||
me.uid.SetText(user.Username + " (" + strconv.Itoa(os.Getuid()) + ")")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
g2.NewButton("dig +trace", func () {
|
|
||||||
o := shell.Run("dig +trace +noadditional DS " + me.hostname + " @8.8.8.8")
|
|
||||||
log(o)
|
|
||||||
// log(o)
|
|
||||||
})
|
})
|
||||||
g2.NewButton("Example_listLink()", func () {
|
g2.NewButton("Example_listLink()", func () {
|
||||||
Example_listLink()
|
Example_listLink()
|
||||||
|
@ -85,6 +81,16 @@ func addDNSTab(title string) {
|
||||||
g2.NewButton("Escalate()", func () {
|
g2.NewButton("Escalate()", func () {
|
||||||
Escalate()
|
Escalate()
|
||||||
})
|
})
|
||||||
|
g2.NewButton("pprof(goroutine)", func () {
|
||||||
|
loggo()
|
||||||
|
// panic("correctly inside of gui goroutine (goroutine 1?)")
|
||||||
|
})
|
||||||
|
g2.NewButton("gui.DebugWindow()", func () {
|
||||||
|
gui.DebugWindow()
|
||||||
|
})
|
||||||
|
g2.NewButton("NewCheckbox(test)", func () {
|
||||||
|
me.notes.NewCheckbox("test")
|
||||||
|
})
|
||||||
g2.NewButton("LookupAddr(<raw ipv6>) == fire from /etc/hosts", func () {
|
g2.NewButton("LookupAddr(<raw ipv6>) == fire from /etc/hosts", func () {
|
||||||
host, err := net.LookupAddr("2600:1700:afd5:6000:b26e:bfff:fe80:3c52")
|
host, err := net.LookupAddr("2600:1700:afd5:6000:b26e:bfff:fe80:3c52")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -114,41 +120,25 @@ func myDefaultExit(n *gui.Node) {
|
||||||
|
|
||||||
func nsupdateGroup(w *gui.Node) {
|
func nsupdateGroup(w *gui.Node) {
|
||||||
g := w.NewGroup("dns update")
|
g := w.NewGroup("dns update")
|
||||||
|
g.NewLabel("UID = " + me.user)
|
||||||
grid := g.NewGrid("gridnuts", 2, 2)
|
g.NewButton("DNS AAAA", func () {
|
||||||
|
var aaaa []string
|
||||||
grid.SetNext(1,1)
|
var out string
|
||||||
grid.NewLabel("hostname =")
|
h := me.fqdn
|
||||||
me.fqdn = grid.NewLabel("?")
|
// h := "fire.lab.wit.org"
|
||||||
me.hostname = ""
|
aaaa = dnsAAAA(h)
|
||||||
|
log(SPEW, me)
|
||||||
grid.NewLabel("UID =")
|
if (aaaa == nil) {
|
||||||
me.uid = grid.NewLabel("?")
|
out += "There are no DNS AAAA records for hostname: " + h + "\n"
|
||||||
|
}
|
||||||
grid.NewLabel("DNS AAAA =")
|
for _, s := range aaaa {
|
||||||
me.DnsAAAA = grid.NewLabel("?")
|
out += "host " + h + " DNS AAAA = " + s + "\n"
|
||||||
|
}
|
||||||
grid.NewLabel("DNS A =")
|
})
|
||||||
me.DnsA = grid.NewLabel("?")
|
g.NewButton("dig +trace", func () {
|
||||||
|
o := shell.Run("dig +trace +noadditional DS " + me.fqdn + " @8.8.8.8")
|
||||||
grid.NewLabel("IPv4 =")
|
output(o, false)
|
||||||
me.IPv4 = grid.NewLabel("?")
|
// log(o)
|
||||||
|
|
||||||
grid.NewLabel("IPv6 =")
|
|
||||||
me.IPv6 = grid.NewLabel("?")
|
|
||||||
|
|
||||||
grid.NewLabel("interfaces =")
|
|
||||||
me.Interfaces = grid.NewCombobox("Interfaces")
|
|
||||||
|
|
||||||
grid.NewLabel("DNS Status =")
|
|
||||||
me.DnsStatus = grid.NewLabel("unknown")
|
|
||||||
|
|
||||||
g.NewButton("Update DNS", func () {
|
|
||||||
log("updateDNS()")
|
|
||||||
updateDNS()
|
|
||||||
me.tab.Margin()
|
|
||||||
me.tab.Pad()
|
|
||||||
grid.Pad()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,51 +150,5 @@ func output(s string, a bool) {
|
||||||
outJunk = s
|
outJunk = s
|
||||||
}
|
}
|
||||||
me.output.SetText(outJunk)
|
me.output.SetText(outJunk)
|
||||||
log(outJunk)
|
//log(outJunk)
|
||||||
}
|
|
||||||
|
|
||||||
func updateDNS() {
|
|
||||||
var aaaa []string
|
|
||||||
h := me.hostname
|
|
||||||
if (h == "") {
|
|
||||||
h = "unknown.lab.wit.org"
|
|
||||||
// h = "hpdevone.lab.wit.org"
|
|
||||||
}
|
|
||||||
log("dnsAAAA()()")
|
|
||||||
aaaa = dnsAAAA(h)
|
|
||||||
log("dnsAAAA()()")
|
|
||||||
log(SPEW, me)
|
|
||||||
if (aaaa == nil) {
|
|
||||||
log("There are no DNS AAAA records for hostname: ", h)
|
|
||||||
}
|
|
||||||
var broken int = 0
|
|
||||||
var all string
|
|
||||||
for _, s := range aaaa {
|
|
||||||
log("host", h, "DNS AAAA =", s)
|
|
||||||
all += s + "\n"
|
|
||||||
if ( me.ipmap[s] == nil) {
|
|
||||||
log("THIS IS THE WRONG AAAA DNS ENTRY: host", h, "DNS AAAA =", s)
|
|
||||||
broken = 2
|
|
||||||
} else {
|
|
||||||
if (broken == 0) {
|
|
||||||
broken = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
all = strings.TrimSpace(all)
|
|
||||||
me.DnsAAAA.SetText(all)
|
|
||||||
if (broken == 1) {
|
|
||||||
me.DnsStatus.SetText("WORKING")
|
|
||||||
} else {
|
|
||||||
me.DnsStatus.SetText("BROKEN")
|
|
||||||
log("Need to run go-nsupdate here")
|
|
||||||
}
|
|
||||||
|
|
||||||
user, _ := user.Current()
|
|
||||||
spew.Dump(user)
|
|
||||||
log("os.Getuid =", user.Username, os.Getuid())
|
|
||||||
if (me.uid != nil) {
|
|
||||||
me.uid.SetText(user.Username + " (" + strconv.Itoa(os.Getuid()) + ")")
|
|
||||||
}
|
|
||||||
log("updateDNS() END")
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/bin/bash -x
|
||||||
|
|
||||||
|
## Tunnel ID: 818143
|
||||||
|
# Creation Date:Feb 12, 2023
|
||||||
|
# Description:
|
||||||
|
# IPv6 Tunnel Endpoints
|
||||||
|
# Server IPv4 Address:184.105.253.14
|
||||||
|
# Server IPv6 Address:2001:470:1f10:2a::1/64
|
||||||
|
# Client IPv4 Address:74.87.91.117
|
||||||
|
# Client IPv6 Address:2001:470:1f10:2a::2/64
|
||||||
|
# Routed IPv6 Prefixes
|
||||||
|
# Routed /64:2001:470:1f11:2a::/64
|
||||||
|
# Routed /48:Assign /48
|
||||||
|
# DNS Resolvers
|
||||||
|
# Anycast IPv6 Caching Nameserver:2001:470:20::2
|
||||||
|
# Anycast IPv4 Caching Nameserver:74.82.42.42
|
||||||
|
# DNS over HTTPS / DNS over TLS:ordns.he.net
|
||||||
|
# rDNS DelegationsEdit
|
||||||
|
# rDNS Delegated NS1:
|
||||||
|
# rDNS Delegated NS2:
|
||||||
|
# rDNS Delegated NS3:
|
||||||
|
# rDNS Delegated NS4:
|
||||||
|
# rDNS Delegated NS5:
|
||||||
|
|
||||||
|
# ifconfig sit0 up
|
||||||
|
# ifconfig sit0 inet6 tunnel ::184.105.253.14
|
||||||
|
# ifconfig sit1 up
|
||||||
|
# ifconfig sit1 inet6 add 2001:470:1f10:2a::2/64
|
||||||
|
# route -A inet6 add ::/0 dev sit1
|
||||||
|
|
||||||
|
if [ "$1" = "down" ]; then
|
||||||
|
ip tunnel del he-ipv6
|
||||||
|
rmmod sit
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "ping" ]; then
|
||||||
|
ping -c 3 2001:470:1f10:13d::1
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
modprobe ipv6
|
||||||
|
ip tunnel add he-ipv6 mode sit remote 184.105.253.14 local 40.132.180.131 ttl 255
|
||||||
|
ip link set he-ipv6 up
|
||||||
|
ip addr add 2001:470:1f10:13d::2/64 dev he-ipv6
|
||||||
|
ip route add ::/0 dev he-ipv6
|
||||||
|
ip -f inet6 addr
|
||||||
|
ifconfig he-ipv6 mtu 1460
|
||||||
|
|
||||||
|
|
||||||
|
# old attempt from the something or pabtz hotel
|
||||||
|
# modprobe ipv6
|
||||||
|
# ip tunnel add he-ipv6 mode sit remote 184.105.253.14 local 74.87.91.117 ttl 255
|
||||||
|
# ip link set he-ipv6 up
|
||||||
|
# ip addr add 2001:470:1f10:2a::2/64 dev he-ipv6
|
||||||
|
# ip route add ::/0 dev he-ipv6
|
||||||
|
# ip -f inet6 addr
|
13
hostname.go
13
hostname.go
|
@ -18,20 +18,13 @@ import "git.wit.org/jcarr/dnssecsocket"
|
||||||
|
|
||||||
func getHostname() {
|
func getHostname() {
|
||||||
var err error
|
var err error
|
||||||
var s string = "gui.Label == nil"
|
me.fqdn, err = fqdn.FqdnHostname()
|
||||||
s, err = fqdn.FqdnHostname()
|
|
||||||
if (err != nil) {
|
if (err != nil) {
|
||||||
log("FQDN hostname error =", err)
|
log("FQDN hostname error =", err)
|
||||||
|
exit()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (me.fqdn != nil) {
|
log("FQDN hostname is", me.fqdn)
|
||||||
if (me.hostname != s) {
|
|
||||||
me.fqdn.SetText(s)
|
|
||||||
me.hostname = s
|
|
||||||
me.changed = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log("FQDN =", s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func dnsAAAA(s string) []string {
|
func dnsAAAA(s string) []string {
|
||||||
|
|
129
log.go
129
log.go
|
@ -1,30 +1,123 @@
|
||||||
|
//
|
||||||
|
// 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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
witlog "git.wit.org/wit/gui/log"
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"runtime/pprof"
|
||||||
|
golog "log"
|
||||||
|
"time"
|
||||||
|
"reflect"
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
// "net"
|
||||||
)
|
)
|
||||||
|
|
||||||
// various debugging flags
|
var LOGOFF bool = false // turn this off, all logging stops
|
||||||
var logNow bool = true // useful for active development
|
var WARN bool
|
||||||
var logError bool = true
|
var INFO bool
|
||||||
var logWarn bool = false
|
|
||||||
var logInfo bool = false
|
|
||||||
var logVerbose bool = false
|
|
||||||
|
|
||||||
var SPEW witlog.Spewt
|
type spewt struct {
|
||||||
|
a bool
|
||||||
|
}
|
||||||
|
|
||||||
// var log interface{}
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
func log(a ...any) {
|
func log(a ...any) {
|
||||||
witlog.Where = "wit/gui"
|
if (LOGOFF) {
|
||||||
witlog.Log(a...)
|
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...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func sleep(a ...any) {
|
func loggo() {
|
||||||
witlog.Sleep(a...)
|
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||||
}
|
log("runtime.NumGoroutine() = ", runtime.NumGoroutine())
|
||||||
|
|
||||||
func exit(a ...any) {
|
|
||||||
log(logError, "got to log() exit")
|
|
||||||
witlog.Exit(a...)
|
|
||||||
}
|
}
|
||||||
|
|
45
main.go
45
main.go
|
@ -1,19 +1,17 @@
|
||||||
// GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
|
// GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
|
||||||
// Copyright (c) 2023 WIT.COM, Inc.
|
// Copyright (c) 2023 WIT.COM, Inc.
|
||||||
// This is a control panel for DNS
|
// This is a control panel for DNS
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
// "net"
|
||||||
arg "github.com/alexflint/go-arg"
|
arg "github.com/alexflint/go-arg"
|
||||||
"git.wit.org/wit/gui"
|
"git.wit.org/wit/gui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var p *arg.Parser
|
var p *arg.Parser
|
||||||
var myGui *gui.Node
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
p = arg.MustParse(&args)
|
p = arg.MustParse(&args)
|
||||||
|
@ -25,6 +23,7 @@ func main() {
|
||||||
me.ifmap = make(map[int]*IFtype)
|
me.ifmap = make(map[int]*IFtype)
|
||||||
me.dnsTTL = 5 // recheck DNS is working every 2 minutes // TODO: watch rx packets?
|
me.dnsTTL = 5 // recheck DNS is working every 2 minutes // TODO: watch rx packets?
|
||||||
|
|
||||||
|
go checkNetworkChanges()
|
||||||
|
|
||||||
log()
|
log()
|
||||||
log(true, "this is true")
|
log(true, "this is true")
|
||||||
|
@ -33,31 +32,24 @@ func main() {
|
||||||
sleep(.3)
|
sleep(.3)
|
||||||
sleep(.2)
|
sleep(.2)
|
||||||
sleep("done scanning net")
|
sleep("done scanning net")
|
||||||
|
// exit("done scanning net")
|
||||||
|
|
||||||
// Example_listLink()
|
// Example_listLink()
|
||||||
|
// exit()
|
||||||
|
|
||||||
log("Toolkit = ", args.Toolkit)
|
log("Toolkit = ", args.Toolkit)
|
||||||
// gui.InitPlugins([]string{"andlabs"})
|
// gui.InitPlugins([]string{"andlabs"})
|
||||||
// gui.SetDebug(true)
|
gui.SetDebug(args.GuiDebug)
|
||||||
// myGui = gui.Main(initGUI)
|
gui.Main(initGUI)
|
||||||
myGui = gui.Start()
|
|
||||||
sleep(1)
|
|
||||||
setupControlPanelWindow()
|
|
||||||
sleep(1)
|
|
||||||
myGui.LoadPlugin("gocui")
|
|
||||||
// gui.Redraw("gocui")
|
|
||||||
sleep(1)
|
|
||||||
checkNetworkChanges()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Poll for changes to the networking settings
|
Poll for changes to the networking settings
|
||||||
*/
|
*/
|
||||||
func checkNetworkChanges() {
|
func checkNetworkChanges() {
|
||||||
var ttl int = 0
|
var ttl int = 3
|
||||||
var ttlsleep int = 5
|
|
||||||
for {
|
for {
|
||||||
sleep(ttlsleep)
|
sleep(1)
|
||||||
ttl -= 1
|
ttl -= 1
|
||||||
if (ttl < 0) {
|
if (ttl < 0) {
|
||||||
if (runtime.GOOS == "linux") {
|
if (runtime.GOOS == "linux") {
|
||||||
|
@ -72,29 +64,16 @@ func checkNetworkChanges() {
|
||||||
|
|
||||||
// Run this every once and a while
|
// Run this every once and a while
|
||||||
func dnsTTL() {
|
func dnsTTL() {
|
||||||
me.changed = false
|
output("FQDN = " + me.fqdn + "\n", false)
|
||||||
log("FQDN =", me.fqdn.GetText())
|
|
||||||
getHostname()
|
getHostname()
|
||||||
scanInterfaces()
|
scanInterfaces()
|
||||||
for i, t := range me.ifmap {
|
for i, t := range me.ifmap {
|
||||||
log(strconv.Itoa(i) + " iface = " + t.iface.Name)
|
output(strconv.Itoa(i) + " iface = " + t.iface.Name + "\n", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
var aaaa []string
|
var aaaa []string
|
||||||
aaaa = realAAAA()
|
aaaa = realAAAA()
|
||||||
var all string
|
|
||||||
for _, s := range aaaa {
|
for _, s := range aaaa {
|
||||||
log("my actual AAAA = ",s)
|
output("my actual AAAA = " + s + "\n", true)
|
||||||
all += s + "\n"
|
|
||||||
}
|
|
||||||
// me.IPv6.SetText(all)
|
|
||||||
|
|
||||||
if (me.changed) {
|
|
||||||
stamp := time.Now().Format("2006/01/02 15:04:05")
|
|
||||||
s := stamp + " Network things changed"
|
|
||||||
log(logError, "Network things changed on", stamp)
|
|
||||||
updateDNS()
|
|
||||||
me.output.SetText(s)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// loggo()
|
||||||
}
|
}
|
||||||
|
|
39
net.go
39
net.go
|
@ -78,11 +78,7 @@ func checkInterface(i net.Interface) {
|
||||||
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.ipchange = true
|
||||||
if (me.Interfaces != nil) {
|
|
||||||
me.Interfaces.AddText(i.Name)
|
|
||||||
me.Interfaces.SetText(i.Name)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
me.ifmap[i.Index].gone = false
|
me.ifmap[i.Index].gone = false
|
||||||
|
@ -90,11 +86,7 @@ func checkInterface(i net.Interface) {
|
||||||
if (val.iface.Name != i.Name) {
|
if (val.iface.Name != i.Name) {
|
||||||
log(val.iface.Name, "has changed to it's name to", i.Name)
|
log(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.ipchange = true
|
||||||
if (me.Interfaces != nil) {
|
|
||||||
me.Interfaces.AddText(i.Name)
|
|
||||||
me.Interfaces.SetText(i.Name)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,15 +156,9 @@ func checkIP(ip *net.IPNet, i net.Interface) bool {
|
||||||
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) {
|
|
||||||
me.IPv6.SetText(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) {
|
|
||||||
me.IPv4.SetText(realip)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (IsReal(&ip.IP)) {
|
if (IsReal(&ip.IP)) {
|
||||||
log("\tIP is Real ", t, i.Index, i.Name, realip)
|
log("\tIP is Real ", t, i.Index, i.Name, realip)
|
||||||
|
@ -187,7 +173,7 @@ func checkIP(ip *net.IPNet, i net.Interface) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func scanInterfaces() {
|
func scanInterfaces() {
|
||||||
me.changed = false
|
me.ipchange = false
|
||||||
ifaces, _ := net.Interfaces()
|
ifaces, _ := net.Interfaces()
|
||||||
// me.ifnew = ifaces
|
// me.ifnew = ifaces
|
||||||
log(DEBUGNET, SPEW, ifaces)
|
log(DEBUGNET, SPEW, ifaces)
|
||||||
|
@ -213,23 +199,6 @@ func scanInterfaces() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteChanges()
|
deleteChanges()
|
||||||
var all4 string
|
|
||||||
var all6 string
|
|
||||||
for s, t := range me.ipmap {
|
|
||||||
if (t.ipv4) {
|
|
||||||
all4 += s + "\n"
|
|
||||||
log("IPv4 =", s)
|
|
||||||
} else if (t.ipv6) {
|
|
||||||
all6 += s + "\n"
|
|
||||||
log("IPv6 =", s)
|
|
||||||
} else {
|
|
||||||
log("???? =", s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
all4 = strings.TrimSpace(all4)
|
|
||||||
all6 = strings.TrimSpace(all6)
|
|
||||||
me.IPv4.SetText(all4)
|
|
||||||
me.IPv6.SetText(all6)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete network interfaces and ip addresses from the gui
|
// delete network interfaces and ip addresses from the gui
|
||||||
|
@ -238,7 +207,6 @@ func deleteChanges() {
|
||||||
if (t.gone) {
|
if (t.gone) {
|
||||||
log("DELETE int =", i, "name =", t.name, t.iface)
|
log("DELETE int =", i, "name =", t.name, t.iface)
|
||||||
delete(me.ifmap, i)
|
delete(me.ifmap, i)
|
||||||
me.changed = true
|
|
||||||
}
|
}
|
||||||
t.gone = true
|
t.gone = true
|
||||||
}
|
}
|
||||||
|
@ -249,7 +217,6 @@ func deleteChanges() {
|
||||||
log("DELETE name =", s, "iface =", t.iface)
|
log("DELETE name =", s, "iface =", t.iface)
|
||||||
log("DELETE name =", s, "ip =", t.ip)
|
log("DELETE name =", s, "ip =", t.ip)
|
||||||
delete(me.ipmap, s)
|
delete(me.ipmap, s)
|
||||||
me.changed = true
|
|
||||||
}
|
}
|
||||||
t.gone = true
|
t.gone = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@ func Example_listLink() {
|
||||||
// Dial a connection to the rtnetlink socket
|
// Dial a connection to the rtnetlink socket
|
||||||
conn, err := rtnetlink.Dial(nil)
|
conn, err := rtnetlink.Dial(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log(logError, "Example_listLink() failed", err)
|
exit(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
|
12
structs.go
12
structs.go
|
@ -12,25 +12,17 @@ var me Host
|
||||||
type Host struct {
|
type Host struct {
|
||||||
hostname string // mirrors
|
hostname string // mirrors
|
||||||
domainname string // kernel.org
|
domainname string // kernel.org
|
||||||
// fqdn string // mirrors.kernel.org
|
fqdn string // mirrors.kernel.org
|
||||||
dnsTTL int // Recheck DNS is working every TTL (in seconds)
|
dnsTTL int // Recheck DNS is working every TTL (in seconds)
|
||||||
changed bool // set to true if things changed
|
|
||||||
user string // name of the user
|
user string // name of the user
|
||||||
ipmap map[string]*IPtype // the current ip addresses
|
ipmap map[string]*IPtype // the current ip addresses
|
||||||
dnsmap map[string]*IPtype // the current dns addresses
|
dnsmap map[string]*IPtype // the current dns addresses
|
||||||
ifmap map[int]*IFtype // the current interfaces
|
ifmap map[int]*IFtype // the current interfaces
|
||||||
|
ipchange bool // set to true if things change
|
||||||
window *gui.Node // the main window
|
window *gui.Node // the main window
|
||||||
tab *gui.Node // the main dns tab
|
tab *gui.Node // the main dns tab
|
||||||
notes *gui.Node // using this to put notes here
|
notes *gui.Node // using this to put notes here
|
||||||
output *gui.Node // Textbox for dumping output
|
output *gui.Node // Textbox for dumping output
|
||||||
uid *gui.Node // user
|
|
||||||
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
|
|
||||||
DnsAAAA *gui.Node // the actual DNS AAAA results
|
|
||||||
DnsA *gui.Node // the actual DNS A results (ignore for status since mostly never happens?)
|
|
||||||
DnsStatus *gui.Node // the current state of DNS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPtype struct {
|
type IPtype struct {
|
||||||
|
|
3
unix.go
3
unix.go
|
@ -24,7 +24,6 @@ func Escalate() {
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log(logError, "exit in Escalate()")
|
|
||||||
exit(err)
|
exit(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +45,7 @@ func DumpPublicDNSZone(zone string) {
|
||||||
func dumpIPs(host string) {
|
func dumpIPs(host string) {
|
||||||
ips, err := net.LookupIP(host)
|
ips, err := net.LookupIP(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log(logError, "dumpIPs() failed:", err)
|
exit(err)
|
||||||
}
|
}
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
log(host, ip)
|
log(host, ip)
|
||||||
|
|
Loading…
Reference in New Issue