blob: 53e81018639cd783dfa15e5dd508e724375d1d1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// 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 (
"log"
"strconv"
"runtime"
"time"
"embed"
"git.wit.org/wit/gui"
)
var myGui *gui.Node
//go:embed plugins/*.so
var resToolkit embed.FS
func main() {
// 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 = 2 // recheck DNS is working every 2 minutes // TODO: watch rx packets?
// will set all debugging flags
// gui.SetDebug(true)
// myGui = gui.New().InitEmbed(resToolkit).LoadToolkit("gocui")
myGui = gui.New().Default()
sleep(.2)
setupControlPanelWindow()
sleep(.2)
if (args.GuiDebug) {
gui.DebugWindow()
}
gui.ShowDebugValues()
// forever monitor for network and dns changes
checkNetworkChanges()
}
/*
Poll for changes to the networking settings
*/
func checkNetworkChanges() {
var ttl int = 0
for {
sleep(0.5)
ttl -= 1
if (ttl < 0) {
if (runtime.GOOS == "linux") {
dnsTTL()
} else {
log.Println("Windows and MacOS don't work yet")
}
ttl = me.dnsTTL
}
}
}
// This checks for changes to the network settings
// and verifies that DNS is working or not working
func dnsTTL() {
me.changed = false
log.Println("FQDN =", me.fqdn.GetText())
getHostname()
scanInterfaces()
for i, t := range me.ifmap {
log.Println(strconv.Itoa(i) + " iface = " + t.iface.Name)
}
var aaaa []string
aaaa = realAAAA()
var all string
for _, s := range aaaa {
log.Println("my actual AAAA = ",s)
all += s + "\n"
}
// me.IPv6.SetText(all)
if (me.changed) {
stamp := time.Now().Format("2006/01/02 15:04:05")
log.Println(logError, "Network things changed on", stamp)
updateDNS()
}
}
|