summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go44
1 files changed, 37 insertions, 7 deletions
diff --git a/main.go b/main.go
index 7e172ad..d94137d 100644
--- a/main.go
+++ b/main.go
@@ -1,19 +1,27 @@
+// GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
+// Copyright (c) 2023 WIT.COM, Inc.
// This is a control panel for DNS
package main
import (
+ "strconv"
"runtime"
// "net"
- "git.wit.org/wit/gui"
arg "github.com/alexflint/go-arg"
+ "git.wit.org/wit/gui"
)
+var p *arg.Parser
+
func main() {
- arg.MustParse(&args)
+ p = arg.MustParse(&args)
+ parsedown()
// initialize the maps to track IP addresses and network interfaces
me.ipmap = make(map[string]*IPtype)
+ me.dnsmap = make(map[string]*IPtype)
me.ifmap = make(map[int]*IFtype)
+ me.dnsTTL = 5 // recheck DNS is working every 2 minutes // TODO: watch rx packets?
go checkNetworkChanges()
@@ -31,6 +39,7 @@ func main() {
log("Toolkit = ", args.Toolkit)
// gui.InitPlugins([]string{"andlabs"})
+ gui.SetDebug(args.GuiDebug)
gui.Main(initGUI)
}
@@ -38,12 +47,33 @@ func main() {
Poll for changes to the networking settings
*/
func checkNetworkChanges() {
+ var ttl int = 3
for {
- sleep(2)
- if (runtime.GOOS == "linux") {
- scanInterfaces()
- } else {
- log("Windows and MacOS don't work yet")
+ sleep(1)
+ ttl -= 1
+ if (ttl < 0) {
+ if (runtime.GOOS == "linux") {
+ dnsTTL()
+ } else {
+ log("Windows and MacOS don't work yet")
+ }
+ ttl = me.dnsTTL
}
}
}
+
+// Run this every once and a while
+func dnsTTL() {
+ output("FQDN = " + me.fqdn + "\n", false)
+ getHostname()
+ scanInterfaces()
+ for i, t := range me.ifmap {
+ output(strconv.Itoa(i) + " iface = " + t.iface.Name + "\n", true)
+ }
+ var aaaa []string
+ aaaa = realAAAA()
+ for _, s := range aaaa {
+ output("my actual AAAA = " + s + "\n", true)
+ }
+ // loggo()
+}