poll every 2 seconds

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-02-17 11:55:17 -06:00
parent 89aa949db3
commit 00c2f38011
5 changed files with 61 additions and 8 deletions

View File

@ -2,6 +2,10 @@ run: build
reset
./control-panel-dns
verbose: build
reset
./control-panel-dns --verbose --verbose-net --gui-debug --toolkit-debug
build-release:
go get -v -u -x .
go build

View File

@ -9,6 +9,13 @@ Goals:
* Run as a daemon
* When run in GUI, add status via systray
# Rational
With the advent of IPv6, it is finally possible again to have real hostnames for
your machines, desktops, laptops, vm's, etc. This control panel will poll for
changes, find out what the DNS entries are, then, if they are not correct, attempt
to update the DNS server.
## References
Useful links and other

32
dynamic-dns-update.go Normal file
View File

@ -0,0 +1,32 @@
package main
/*
https://pkg.go.dev/github.com/miekg/dns#section-readme
DYNAMIC UPDATES
Dynamic updates reuses the DNS message format, but renames three of the sections. Question is Zone, Answer is Prerequisite, Authority is Update, only the Additional is not renamed. See RFC 2136 for the gory details.
You can set a rather complex set of rules for the existence of absence of certain resource records or names in a zone to specify if resource records should be added or removed. The table from RFC 2136 supplemented with the Go DNS function shows which functions exist to specify the prerequisites.
3.2.4 - Table Of Metavalues Used In Prerequisite Section
CLASS TYPE RDATA Meaning Function
--------------------------------------------------------------
ANY ANY empty Name is in use dns.NameUsed
ANY rrset empty RRset exists (value indep) dns.RRsetUsed
NONE ANY empty Name is not in use dns.NameNotUsed
NONE rrset empty RRset does not exist dns.RRsetNotUsed
zone rrset rr RRset exists (value dep) dns.Used
The prerequisite section can also be left empty. If you have decided on the prerequisites you can tell what RRs should be added or deleted. The next table shows the options you have and what functions to call.
3.4.2.6 - Table Of Metavalues Used In Update Section
CLASS TYPE RDATA Meaning Function
---------------------------------------------------------------
ANY ANY empty Delete all RRsets from name dns.RemoveName
ANY rrset empty Delete an RRset dns.RemoveRRset
NONE rrset rr Delete an RR from RRset dns.Remove
zone rrset rr Add to an RRset dns.Insert
*/

24
main.go
View File

@ -18,13 +18,7 @@ func main() {
// gui.InitPlugins([]string{"andlabs"})
if (runtime.GOOS == "linux") {
scanInterfaces()
} else {
log("Windows and MacOS don't work yet")
exit()
}
go checkNetworkChanges()
log()
log(true, "this is true")
@ -35,6 +29,20 @@ func main() {
sleep("done scanning net")
// exit("done scanning net")
watchNetworkInterfaces()
// watchNetworkInterfaces()
gui.Main(initGUI)
}
/*
Poll for changes to the networking settings
*/
func checkNetworkChanges() {
for {
sleep(2)
if (runtime.GOOS == "linux") {
scanInterfaces()
} else {
log("Windows and MacOS don't work yet")
}
}
}

2
net.go
View File

@ -10,6 +10,7 @@ import (
var DEBUGNET bool = false
// this doesn't work
/*
func watchNetworkInterfaces() {
// Get list of network interfaces
interfaces, _ := net.Interfaces()
@ -35,6 +36,7 @@ func watchNetworkInterfaces() {
}
}()
}
*/
func IsIPv6(address string) bool {
return strings.Count(address, ":") >= 2