ready to pull DNS records
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
1dfd895074
commit
98a94c67ff
3
Makefile
3
Makefile
|
@ -4,6 +4,9 @@ run: build
|
||||||
verbose: build
|
verbose: build
|
||||||
./control-panel-dns --verbose --verbose-net --gui-debug --toolkit-debug
|
./control-panel-dns --verbose --verbose-net --gui-debug --toolkit-debug
|
||||||
|
|
||||||
|
dns: build
|
||||||
|
./control-panel-dns --verbose-dns
|
||||||
|
|
||||||
build-release:
|
build-release:
|
||||||
reset
|
reset
|
||||||
go get -v -u -x .
|
go get -v -u -x .
|
||||||
|
|
1
args.go
1
args.go
|
@ -9,6 +9,7 @@ type LogOptions struct {
|
||||||
LogFile string `help:"write all output to a file"`
|
LogFile string `help:"write all output to a file"`
|
||||||
Verbose bool
|
Verbose bool
|
||||||
VerboseNet bool `arg:"--verbose-net" help:"debug network settings"`
|
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"`
|
// GuiDebug bool `help:"open up the wit/gui Debugging Window"`
|
||||||
// GuiDemo bool `help:"open the wit/gui Demo Window"`
|
// GuiDemo bool `help:"open the wit/gui Demo Window"`
|
||||||
User string `arg:"env:USER"`
|
User string `arg:"env:USER"`
|
||||||
|
|
47
dns.go
47
dns.go
|
@ -5,13 +5,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "os"
|
|
||||||
// "os/exec"
|
|
||||||
"net"
|
"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
|
Check a bunch of things. If they don't work right, then things are not correctly configured
|
||||||
They are things like:
|
They are things like:
|
||||||
|
@ -33,3 +31,44 @@ func (h *Host) updateIPs(host string) {
|
||||||
log(host, ip)
|
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
10
gui.go
|
@ -71,16 +71,8 @@ func addDNSTab(window *gui.Node, title string) {
|
||||||
log("int =", i, "name =", t.name, t.iface)
|
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 () {
|
g2.NewButton("checkDNS()", func () {
|
||||||
checkDNS()
|
me.checkDNS()
|
||||||
})
|
})
|
||||||
g2.NewButton("os.Hostname()", func () {
|
g2.NewButton("os.Hostname()", func () {
|
||||||
name, err = os.Hostname()
|
name, err = os.Hostname()
|
||||||
|
|
14
net.go
14
net.go
|
@ -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 {
|
for s, t := range me.ipmap {
|
||||||
i := t.iface
|
i := t.iface
|
||||||
ipt := "IPv4"
|
ipt := "IPv4"
|
||||||
|
@ -100,10 +106,16 @@ func checkDNS() {
|
||||||
}
|
}
|
||||||
if (t.IsReal()) {
|
if (t.IsReal()) {
|
||||||
log("\tIP is Real ", ipt, i.Index, i.Name, s)
|
log("\tIP is Real ", ipt, i.Index, i.Name, s)
|
||||||
|
if (t.ipv6) {
|
||||||
|
ipv6s[s] = t
|
||||||
|
} else {
|
||||||
|
ipv4s[s] = t
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log("\tIP is not Real", ipt, i.Index, i.Name, s)
|
log("\tIP is not Real", ipt, i.Index, i.Name, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ipv6s, ipv4s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will figure out if an IP address is new
|
// Will figure out if an IP address is new
|
||||||
|
|
|
@ -6,6 +6,8 @@ package main
|
||||||
// from that page, a link to watch for any ip event:
|
// from that page, a link to watch for any ip event:
|
||||||
// https://github.com/angt/ipevent/blob/master/ipevent.c
|
// 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 :
|
c example from ipevent.c :
|
||||||
int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||||
|
|
Loading…
Reference in New Issue