diff options
| -rw-r--r-- | gui.go | 10 | ||||
| -rw-r--r-- | main.go | 26 | ||||
| -rw-r--r-- | net.go | 1 | ||||
| -rw-r--r-- | netlink.go | 66 | ||||
| -rw-r--r-- | unix.go | 2 |
5 files changed, 21 insertions, 84 deletions
@@ -15,16 +15,13 @@ import ( // This setups up the dns control panel window func setupControlPanelWindow() { - me.window = myGui.New2().Window("DNS and IPv6 Control Panel").Standard() + // me.window = myGui.New2().Window("DNS and IPv6 Control Panel").Standard() + me.window = myGui.NewWindow("DNS and IPv6 Control Panel").Standard() me.window.Dump(true) sleep(1) addDNSTab("DNS") - if (args.GuiDebug) { - gui.DebugWindow() - } - gui.ShowDebugValues() } func addDNSTab(title string) { @@ -41,8 +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.StartS("gocui") - gui.Redraw("gocui") + gui.LoadPlugin("gocui") }) g2.NewButton("Network Interfaces", func () { @@ -37,16 +37,25 @@ func main() { // Example_listLink() log("Toolkit = ", args.Toolkit) - // gui.InitPlugins([]string{"andlabs"}) - // gui.SetDebug(true) - // myGui = gui.Main(initGUI) - myGui = gui.Start() + for i, t := range args.Toolkit { + log("trying to load plugin", i, t) + gui.LoadPlugin(t) + } + + // will set all debugging flags + gui.SetDebug(true) + + myGui = gui.New() sleep(1) setupControlPanelWindow() sleep(1) - myGui.LoadPlugin("gocui") - // gui.Redraw("gocui") - sleep(1) + // sleep(1) + if (args.GuiDebug) { + gui.DebugWindow() + } + gui.ShowDebugValues() + + // forever monitor for network and dns changes checkNetworkChanges() } @@ -70,7 +79,8 @@ func checkNetworkChanges() { } } -// Run this every once and a while +// This checks for changes to the network settings +// and verifies that DNS is working or not working func dnsTTL() { me.changed = false log("FQDN =", me.fqdn.GetText()) @@ -4,7 +4,6 @@ package main import ( "net" "strings" - // "git.wit.org/wit/gui" ) var DEBUGNET bool = false diff --git a/netlink.go b/netlink.go deleted file mode 100644 index 7d3c3f5..0000000 --- a/netlink.go +++ /dev/null @@ -1,66 +0,0 @@ -package main - -// examples of what ifconfig does -// example of AF_NETLINK change: -// https://stackoverflow.com/questions/579783/how-to-detect-ip-address-change-programmatically-in-linux/2353441#2353441 -// from that page, a link to watch for any ip event: -// https://github.com/angt/ipevent/blob/master/ipevent.c - -// https://github.com/mdlayher/talks : Linux, Netlink, and Go in 7 minutes or less! (GopherCon 2018, lightning talk) - -/* - c example from ipevent.c : - int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - - struct sockaddr_nl snl = { - .nl_family = AF_NETLINK, - .nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR, - }; -*/ - -/* -import ( -// "os" -// "os/exec" - // "log" - // "net" - // "unix" - "github.com/vishvananda/netlink" - "github.com/jsimonetti/rtnetlink" -// "git.wit.org/wit/gui" -// "github.com/davecgh/go-spew/spew" -) - -// In golang, write a function to register with netlink to detect changes to any network interface Use tab indentation. Do not include example usage. - -func registerNetlink() error { - // Create netlink socket - sock, err := netlink.Socket(rtnetlink.NETLINK_ROUTE, 0) - if err != nil { - return err - } - // Register for interface change events - err = netlink.AddMembership(sock, netlink.RTNLGRP_LINK) - if err != nil { - return err - } - // Close the socket - defer sock.Close() - // Handle incoming notifications - for { - msgs, _, err := sock.Receive() - if err != nil { - return err - } - for _, msg := range msgs { - switch msg.Header.Type { - case unix.RTM_NEWLINK: - // Do something with new link - case unix.RTM_DELLINK: - // Do something with deleted link - } - } - } - return nil -} -*/ @@ -8,8 +8,6 @@ import ( "os" "os/exec" "net" -// "git.wit.org/wit/gui" -// "github.com/davecgh/go-spew/spew" ) func CheckSuperuser() bool { |
