ready to pull DNS records

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-02-18 07:29:24 -06:00
parent 1dfd895074
commit 98a94c67ff
6 changed files with 63 additions and 14 deletions

View File

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

View File

@ -9,6 +9,7 @@ type LogOptions struct {
LogFile string `help:"write all output to a file"`
Verbose bool
VerboseNet bool `arg:"--verbose-net" help:"debug network settings"`
VerboseDNS bool `arg:"--verbose-dns" help:"debug dns settings"`
// GuiDebug bool `help:"open up the wit/gui Debugging Window"`
// GuiDemo bool `help:"open the wit/gui Demo Window"`
User string `arg:"env:USER"`

47
dns.go
View File

@ -5,13 +5,11 @@
package main
import (
// "os"
// "os/exec"
"net"
// "git.wit.org/wit/gui"
// "github.com/davecgh/go-spew/spew"
)
var dnsTTL int = 3600; // Recheck DNS is working every TTL (in seconds)
/*
Check a bunch of things. If they don't work right, then things are not correctly configured
They are things like:
@ -33,3 +31,44 @@ func (h *Host) updateIPs(host string) {
log(host, ip)
}
}
func (h *Host) setIPv4(ipv4s map[string]*IPtype) {
for ip, t := range ipv4s {
log("IPv4", ip, t)
}
}
func (h *Host) checkDNS() {
var ip4 bool = false
var ip6 bool = false
for s, t := range h.ipmap {
i := t.iface
ipt := "IPv4"
if (t.ipv6) {
ipt = "IPv6"
}
if (! t.IsReal()) {
log(args.VerboseDNS, "\tIP is not Real", ipt, i.Index, i.Name, s)
continue
}
log(args.VerboseDNS, "\tIP is Real ", ipt, i.Index, i.Name, s)
if (t.ipv6) {
ip6 = true
} else {
ip4 = true
}
}
if (ip4 == true) {
log(args.VerboseDNS, "IPv4 should work. Wow. You actually have a real IPv4 address")
} else {
log(args.VerboseDNS, "IPv4 is broken. (be nice and setup ipv4-only.wit.com)")
}
if (ip6 == true) {
log(args.VerboseDNS, "IPv6 should be working. Need to test it here.")
} else {
log(args.VerboseDNS, "IPv6 is broken. Need to fix it here.")
}
}

10
gui.go
View File

@ -71,16 +71,8 @@ func addDNSTab(window *gui.Node, title string) {
log("int =", i, "name =", t.name, t.iface)
}
})
g2.NewButton("dump Host.ipmap", func () {
for s, t := range me.ipmap {
log("name =", s, "ipv4 =", t.ipv4)
log("name =", s, "ipv6 =", t.ipv6)
log("name =", s, "iface =", t.iface)
log("name =", s, "ip =", t.ip)
}
})
g2.NewButton("checkDNS()", func () {
checkDNS()
me.checkDNS()
})
g2.NewButton("os.Hostname()", func () {
name, err = os.Hostname()

14
net.go
View File

@ -91,7 +91,13 @@ func checkInterface(i net.Interface) {
}
}
func checkDNS() {
func checkDNS() (map[string]*IPtype, map[string]*IPtype) {
var ipv4s map[string]*IPtype
var ipv6s map[string]*IPtype
ipv4s = make(map[string]*IPtype)
ipv6s = make(map[string]*IPtype)
for s, t := range me.ipmap {
i := t.iface
ipt := "IPv4"
@ -100,10 +106,16 @@ func checkDNS() {
}
if (t.IsReal()) {
log("\tIP is Real ", ipt, i.Index, i.Name, s)
if (t.ipv6) {
ipv6s[s] = t
} else {
ipv4s[s] = t
}
} else {
log("\tIP is not Real", ipt, i.Index, i.Name, s)
}
}
return ipv6s, ipv4s
}
// Will figure out if an IP address is new

View File

@ -6,6 +6,8 @@ package main
// 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);