getting close to nsupdate

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-13 07:49:13 -05:00
parent 9975aefe1e
commit 5d7004ad92
3 changed files with 45 additions and 9 deletions

16
gui.go
View File

@ -38,7 +38,7 @@ func addDNSTab(title string) {
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.LoadPlugin("gocui")
myGui.LoadToolkit("gocui")
})
g2.NewButton("Network Interfaces", func () {
@ -59,6 +59,11 @@ func addDNSTab(title string) {
}
})
g2.NewButton("Update DNS", func () {
log("updateDNS()")
updateDNS()
})
g2.NewButton("checkDNS()", func () {
checkDNS()
})
@ -139,12 +144,8 @@ func nsupdateGroup(w *gui.Node) {
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()
g.NewButton("go-nsupdate", func () {
nsupdate()
})
}
@ -194,6 +195,7 @@ func updateDNS() {
} else {
me.DnsStatus.SetText("BROKEN")
log("Need to run go-nsupdate here")
nsupdate()
}
user, _ := user.Current()

View File

@ -39,13 +39,13 @@ func main() {
log("Toolkit = ", args.Toolkit)
for i, t := range args.Toolkit {
log("trying to load plugin", i, t)
gui.LoadPlugin(t)
myGui.LoadToolkit(t)
}
// will set all debugging flags
gui.SetDebug(true)
myGui = gui.New()
myGui = gui.New().LoadToolkit("gocui")
sleep(1)
setupControlPanelWindow()
sleep(1)
@ -54,6 +54,7 @@ func main() {
gui.DebugWindow()
}
gui.ShowDebugValues()
go gui.Watchdog()
// forever monitor for network and dns changes
checkNetworkChanges()

33
nsupdate.go Normal file
View File

@ -0,0 +1,33 @@
// 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 (
"os"
)
// ./go-nsupdate \
// --tsig-algorithm=hmac-sha512 \
// --tsig-secret="OWh5/ZHIyaz7B8J9m9ZDqZ8448Pke0PTpkYbZmFcOf5a6rEzgmcwrG91u1BHi1/4us+mKKEobDPLw1x6sD+ZJw==" \
// -i eno2 farm001.lab.wit.org
func nsupdate() {
var tsigSecret string
log(true, "nsupdate() START")
cmd := "go-nsupdate --tsig-algorithm=hmac-sha512"
tsigSecret = os.Getenv("TIG_SECRET")
cmd += " --tig-secret=\"" + tsigSecret + "\""
cmd += " -i wlo1 " + me.hostname
log(true, "nsupdate() RUN:", cmd)
for s, t := range me.ipmap {
if (t.IsReal()) {
if (t.ipv6) {
log(true, "nsupdate() found real AAAA =", s, "on iface", t.iface.Name)
}
}
}
}