parent
42ca387a49
commit
a4659ec595
14
Makefile
14
Makefile
|
@ -1,8 +1,9 @@
|
|||
.PHONY: debian
|
||||
|
||||
run: build
|
||||
reset
|
||||
cp -f control-panel-dns ~/
|
||||
./control-panel-dns
|
||||
sudo ./control-panel-dns
|
||||
|
||||
build:
|
||||
-mkdir -p resources/
|
||||
|
@ -117,3 +118,14 @@ ssl-cert-hash:
|
|||
|
||||
sudo-cp:
|
||||
sudo cp -a lets-encrypt-r3.pem 8d33f237.0 /etc/ssl/certs/
|
||||
|
||||
# apt install uml-utilities
|
||||
fake0-up:
|
||||
tunctl -t fake0
|
||||
ifconfig fake0 up
|
||||
# ifconfig fake0 inet6 add 2001:470:1f12:2cd::2/64
|
||||
ifconfig fake0 inet6 add 2604:BBC0:1234:1234::1234/128
|
||||
|
||||
fake0-down:
|
||||
ifconfig fake0 down
|
||||
tunctl -d fake0
|
||||
|
|
39
errorBox.go
39
errorBox.go
|
@ -103,10 +103,34 @@ func (eb *errorBox) addIPerror(kind ProblemType, action ActionType, ip string) b
|
|||
}
|
||||
tmp := kind.String() + " " + ip
|
||||
if eb.fixes[tmp] != nil {
|
||||
log.Log(WARN, "Error is already here", kind, ip)
|
||||
log.Log(WARN, "kind =", kind)
|
||||
log.Log(WARN, "action =", action)
|
||||
log.Log(WARN, "ip =", ip)
|
||||
log.Log(WARN, "Error is already here tmp =", tmp)
|
||||
log.Log(WARN, "kind =", kind, "action =", action, "ip =", ip)
|
||||
log.Log(WARN, "Need to check here if this thing is fixed")
|
||||
thing := eb.fixes[tmp]
|
||||
switch action {
|
||||
case CREATE:
|
||||
log.Log(WARN, "ValidDNS() CREATE begun =", thing.problem.begun)
|
||||
if ValidDNS(ip) {
|
||||
log.Log(WARN, "ValidDNS() == true begun =", thing.problem.begun)
|
||||
if thing.problem.begun {
|
||||
log.Log(WARN, "CREATE WORKED. IP is in DNS.", ip)
|
||||
}
|
||||
} else {
|
||||
log.Log(WARN, "ValidDNS() == false. begun =", thing.problem.begun)
|
||||
}
|
||||
case DELETE:
|
||||
log.Log(WARN, "ValidDNS() DELETE begun =", thing.problem.begun)
|
||||
if ValidDNS(ip) {
|
||||
if thing.problem.begun {
|
||||
log.Log(WARN, "DELETE FAILED. IP is still in DNS", ip)
|
||||
}
|
||||
} else {
|
||||
log.Log(WARN, "ValidDNS() == false. begun =", thing.problem.begun)
|
||||
}
|
||||
default:
|
||||
log.Log(WARN, "ValidDNS() begun =", thing.problem.begun)
|
||||
log.Log(WARN, "ValidDNS() unhandled ACTION", action)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -209,8 +233,13 @@ func (eb *errorBox) Scan() []anError {
|
|||
log.Log(WARN, "Scan()", "attempted to fix has happened")
|
||||
} else {
|
||||
log.Log(WARN, "Scan()", "attempted to fix not yet happened")
|
||||
thing.Fix()
|
||||
if thing.Fix() {
|
||||
log.Log(WARN, "Scan()", "FIXED OK")
|
||||
} else {
|
||||
log.Log(WARN, "Scan()", "FIX FAILED")
|
||||
}
|
||||
}
|
||||
thing.button.Disable()
|
||||
|
||||
}
|
||||
return nil
|
||||
|
|
24
fix.go
24
fix.go
|
@ -57,6 +57,25 @@ func fix() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// returns true if the IP address is in DNS
|
||||
func ValidDNS(ip string) bool {
|
||||
// check for DNS AAAA RR's (Resource Record)
|
||||
for _, aaaa := range me.statusDNS.GetIPv6() {
|
||||
log.Log(WARN, "statusDNS.GetIPv6() FOUND DNS AAAA ip", aaaa)
|
||||
if ip == aaaa {
|
||||
return true
|
||||
}
|
||||
}
|
||||
// check for DNS A RR's (Resource Record)
|
||||
for _, a := range me.statusDNS.GetIPv4() {
|
||||
log.Log(WARN, "statusDNS.GetIPv4() FOUND DNS A ip", a)
|
||||
if ip == a {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func fixIPv6dns() bool {
|
||||
log.Log(INFO, "What are my IPv6 addresses?")
|
||||
var broken bool = false
|
||||
|
@ -137,6 +156,11 @@ func deleteFromDNS(aaaa string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// returns TRUE if there is a Resource Record in DNS for the AAAA value
|
||||
func inDNS(aaaa string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func addToDNS(aaaa string) bool {
|
||||
log.Log(CHANGE, "Add this to DNS !!!!", aaaa)
|
||||
api := me.statusDNS.API()
|
||||
|
|
|
@ -234,6 +234,17 @@ func (hs *hostnameStatus) GetIPv6() []string {
|
|||
return strings.Split(tmp, "\n")
|
||||
}
|
||||
|
||||
func (hs *hostnameStatus) GetIPv4() []string {
|
||||
if !hs.Ready() {
|
||||
return nil
|
||||
}
|
||||
// clean out any blank lines
|
||||
// todo: fix this whole hacky thing
|
||||
tmp := hs.dnsA.String()
|
||||
tmp = strings.TrimSpace(tmp)
|
||||
return strings.Split(tmp, "\n")
|
||||
}
|
||||
|
||||
func (hs *hostnameStatus) updateStatus() {
|
||||
if !hs.Ready() {
|
||||
return
|
||||
|
@ -349,7 +360,7 @@ func (hs *hostnameStatus) verifyIPv6() (bool, error) {
|
|||
|
||||
log.Log(INFO, "What are the AAAA resource records in DNS?")
|
||||
for _, aaaa := range me.statusDNS.GetIPv6() {
|
||||
log.Log(INFO, "FOUND DNS AAAA ip", aaaa)
|
||||
// log.Log(INFO, "FOUND DNS AAAA ip", aaaa)
|
||||
dnsAAAA[aaaa] = "dns"
|
||||
}
|
||||
|
||||
|
|
9
main.go
9
main.go
|
@ -15,8 +15,6 @@ import (
|
|||
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/gui/linuxstatus"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
//go:embed resources/*
|
||||
|
@ -26,15 +24,8 @@ 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.nsmap = make(map[string]string)
|
||||
|
||||
// initialize maps for the returned DNS records
|
||||
me.ipv4s = make(map[string]dns.RR)
|
||||
me.ipv6s = make(map[string]dns.RR)
|
||||
|
||||
me.myGui = gui.New()
|
||||
me.myGui.InitEmbed(resToolkit)
|
||||
me.myGui.Default()
|
||||
|
|
|
@ -9,8 +9,6 @@ import (
|
|||
"go.wit.com/lib/gadgets"
|
||||
|
||||
"go.wit.com/lib/gui/linuxstatus"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// It's probably a terrible idea to call this 'me'
|
||||
|
@ -42,15 +40,9 @@ type Host struct {
|
|||
|
||||
changed bool // set to true if things changed
|
||||
|
||||
ipmap map[string]*IPtype // the current ip addresses
|
||||
dnsmap map[string]*IPtype // the current dns addresses
|
||||
ifmap map[int]*IFtype // the current interfaces
|
||||
nsmap map[string]string // the NS records
|
||||
|
||||
// DNS A and AAAA results
|
||||
ipv4s map[string]dns.RR
|
||||
ipv6s map[string]dns.RR
|
||||
|
||||
// DNS stuff
|
||||
DnsStatus *gui.Node // the current state of DNS
|
||||
DnsSpeed *gui.Node // 'FAST', 'OK', 'SLOW', etc
|
||||
|
|
Loading…
Reference in New Issue