2024-01-06 05:24:11 -06:00
|
|
|
// This creates a simple hello world window
|
|
|
|
package main
|
|
|
|
|
2024-01-21 00:15:20 -06:00
|
|
|
import (
|
|
|
|
"go.wit.com/lib/gadgets"
|
|
|
|
"go.wit.com/lib/gui/cloudflare"
|
2024-01-06 05:24:11 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func fix() bool {
|
2024-01-07 10:38:17 -06:00
|
|
|
// make and toggle the fixWindow display
|
|
|
|
if me.fixWindow == nil {
|
2024-01-21 00:15:20 -06:00
|
|
|
me.fixWindow = gadgets.NewBasicWindow(me.myGui, "fix window")
|
|
|
|
me.fixWindow.SetTitle("fix window")
|
2024-01-07 10:38:17 -06:00
|
|
|
me.fixWindow.Make()
|
|
|
|
me.fixWindow.Draw()
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
me.fixWindow.Toggle()
|
|
|
|
|
2024-01-21 00:15:20 -06:00
|
|
|
if !me.statusDNS.Ready() {
|
2024-01-06 20:14:11 -06:00
|
|
|
log.Log(CHANGE, "The IPv6 Control Panel is not Ready() yet")
|
2024-01-06 05:24:11 -06:00
|
|
|
return false
|
|
|
|
}
|
2024-01-06 16:59:33 -06:00
|
|
|
if me.statusOS.ValidHostname() {
|
2024-01-06 21:02:41 -06:00
|
|
|
log.Log(CHANGE, "GOOD Your hostname is VALID:", me.statusOS.GetHostname())
|
2024-01-06 05:24:11 -06:00
|
|
|
} else {
|
2024-01-06 20:14:11 -06:00
|
|
|
log.Log(CHANGE, "You must first fix your hostname:", me.statusOS.GetHostname())
|
2024-01-06 05:24:11 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
if me.digStatus.IPv4() {
|
2024-01-06 21:02:41 -06:00
|
|
|
log.Log(CHANGE, "GOOD IPv4 addresses are resolving")
|
2024-01-06 05:24:11 -06:00
|
|
|
} else {
|
2024-01-06 20:14:11 -06:00
|
|
|
log.Log(CHANGE, "You must first figure out why you can't look up IPv4 addresses")
|
|
|
|
log.Log(CHANGE, "Are you on the internet at all?")
|
2024-01-06 05:24:11 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
if me.digStatus.IPv6() {
|
2024-01-06 21:02:41 -06:00
|
|
|
log.Log(CHANGE, "GOOD IPv6 addresses are resolving")
|
2024-01-06 05:24:11 -06:00
|
|
|
} else {
|
2024-01-06 20:14:11 -06:00
|
|
|
log.Log(CHANGE, "You must first figure out why you can't look up IPv6 addresses")
|
2024-01-06 05:24:11 -06:00
|
|
|
return false
|
|
|
|
}
|
2024-01-21 00:15:20 -06:00
|
|
|
if !me.statusDNS.IPv4() {
|
|
|
|
log.Log(CHANGE, "OK You do not have real IPv4 addresses. Nothing to fix here")
|
2024-01-06 05:24:11 -06:00
|
|
|
}
|
2024-01-21 00:15:20 -06:00
|
|
|
if !me.statusDNS.IPv6() {
|
2024-01-06 20:14:11 -06:00
|
|
|
if fixIPv6dns() {
|
|
|
|
log.Log(CHANGE, "IPv6 DNS Repair is underway")
|
|
|
|
return false
|
|
|
|
}
|
2024-01-06 21:17:06 -06:00
|
|
|
log.Log(CHANGE, "GOOD IPv6 DNS is working!")
|
2024-01-06 05:24:11 -06:00
|
|
|
}
|
2024-01-06 21:02:41 -06:00
|
|
|
log.Log(CHANGE, "GOOD YOU SHOULD BE IN IPv6 BLISS")
|
2024-01-06 05:24:11 -06:00
|
|
|
return true
|
|
|
|
}
|
2024-01-06 19:00:51 -06:00
|
|
|
|
2024-01-06 20:14:11 -06:00
|
|
|
func fixIPv6dns() bool {
|
|
|
|
log.Log(INFO, "What are my IPv6 addresses?")
|
|
|
|
var broken bool = false
|
2024-01-06 19:58:58 -06:00
|
|
|
osAAAA := make(map[string]string)
|
|
|
|
dnsAAAA := make(map[string]string)
|
|
|
|
|
|
|
|
for _, aaaa := range me.statusOS.GetIPv6() {
|
2024-01-06 20:14:11 -06:00
|
|
|
log.Log(INFO, "FOUND OS AAAA ip", aaaa)
|
2024-01-06 19:58:58 -06:00
|
|
|
osAAAA[aaaa] = "os"
|
2024-01-06 19:00:51 -06:00
|
|
|
}
|
|
|
|
|
2024-01-06 20:14:11 -06:00
|
|
|
log.Log(INFO, "What are the AAAA resource records in DNS?")
|
2024-01-06 19:58:58 -06:00
|
|
|
for _, aaaa := range me.statusDNS.GetIPv6() {
|
2024-01-06 20:14:11 -06:00
|
|
|
log.Log(INFO, "FOUND DNS AAAA ip", aaaa)
|
2024-01-06 19:58:58 -06:00
|
|
|
dnsAAAA[aaaa] = "dns"
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove old DNS entries first
|
|
|
|
for aaaa, _ := range dnsAAAA {
|
2024-01-07 10:38:17 -06:00
|
|
|
if osAAAA[aaaa] == "os" {
|
|
|
|
log.Log(INFO, "DNS AAAA is in OS", aaaa)
|
|
|
|
} else {
|
2024-01-06 20:14:11 -06:00
|
|
|
broken = true
|
2024-01-07 05:46:59 -06:00
|
|
|
log.Log(INFO, "DNS AAAA is not in OS", aaaa)
|
2024-01-08 22:34:08 -06:00
|
|
|
// addToFixWindow("DELETE", aaaa)
|
|
|
|
me.problems.addIPerror(RR, DELETE, aaaa)
|
2024-01-07 05:46:59 -06:00
|
|
|
/*
|
2024-01-21 00:15:20 -06:00
|
|
|
if deleteFromDNS(aaaa) {
|
|
|
|
log.Log(INFO, "Delete AAAA", aaaa, "Worked")
|
|
|
|
} else {
|
|
|
|
log.Log(INFO, "Delete AAAA", aaaa, "Failed")
|
|
|
|
}
|
2024-01-07 05:46:59 -06:00
|
|
|
*/
|
2024-01-06 19:58:58 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// now add new DNS entries
|
|
|
|
for aaaa, _ := range osAAAA {
|
|
|
|
if dnsAAAA[aaaa] == "dns" {
|
2024-01-06 20:14:11 -06:00
|
|
|
log.Log(INFO, "OS AAAA is in DNS", aaaa)
|
2024-01-06 19:58:58 -06:00
|
|
|
} else {
|
2024-01-06 20:14:11 -06:00
|
|
|
broken = true
|
|
|
|
log.Log(INFO, "OS AAAA is not in DNS", aaaa)
|
2024-01-07 05:46:59 -06:00
|
|
|
addToFixWindow("CREATE", aaaa)
|
|
|
|
/*
|
2024-01-21 00:15:20 -06:00
|
|
|
if addToDNS(aaaa) {
|
|
|
|
log.Log(INFO, "Add AAAA", aaaa, "Worked")
|
|
|
|
} else {
|
|
|
|
log.Log(INFO, "Add AAAA", aaaa, "Failed")
|
|
|
|
}
|
2024-01-07 05:46:59 -06:00
|
|
|
*/
|
2024-01-06 19:58:58 -06:00
|
|
|
}
|
|
|
|
}
|
2024-01-06 20:14:11 -06:00
|
|
|
|
|
|
|
// if anything doesn't match, return false
|
|
|
|
return broken
|
2024-01-06 19:58:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func deleteFromDNS(aaaa string) bool {
|
2024-01-07 11:23:51 -06:00
|
|
|
log.Log(CHANGE, "Delete this from DNS !!!!", aaaa)
|
|
|
|
api := me.statusDNS.API()
|
|
|
|
log.Log(CHANGE, "your API provider is =", api)
|
|
|
|
if api == "cloudflare" {
|
|
|
|
log.Log(CHANGE, "Let's try a DELETE via the Cloudflare API")
|
|
|
|
hostname := me.statusOS.GetHostname()
|
|
|
|
b, response := cloudflare.Delete("wit.com", hostname, aaaa)
|
|
|
|
log.Log(CHANGE, "response was:", response)
|
|
|
|
return b
|
|
|
|
}
|
2024-01-06 19:58:58 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func addToDNS(aaaa string) bool {
|
2024-01-07 11:23:51 -06:00
|
|
|
log.Log(CHANGE, "Add this to DNS !!!!", aaaa)
|
2024-01-06 21:02:41 -06:00
|
|
|
api := me.statusDNS.API()
|
2024-01-07 11:23:51 -06:00
|
|
|
log.Log(CHANGE, "your API provider is =", api)
|
2024-01-06 21:02:41 -06:00
|
|
|
if api == "cloudflare" {
|
2024-01-07 11:23:51 -06:00
|
|
|
log.Log(CHANGE, "Let's try a CREATE via the Cloudflare API")
|
2024-01-06 21:02:41 -06:00
|
|
|
hostname := me.statusOS.GetHostname()
|
|
|
|
return cloudflare.Create("wit.com", hostname, aaaa)
|
|
|
|
}
|
2024-01-06 19:58:58 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func exists(m map[string]bool, s string) bool {
|
|
|
|
if _, ok := m[s]; ok {
|
|
|
|
return true
|
2024-01-06 19:00:51 -06:00
|
|
|
}
|
2024-01-06 19:58:58 -06:00
|
|
|
return false
|
2024-01-06 19:00:51 -06:00
|
|
|
}
|
2024-01-07 05:46:59 -06:00
|
|
|
|
|
|
|
func addToFixWindow(t string, ip string) {
|
2024-01-07 10:38:17 -06:00
|
|
|
log.Log(INFO, "addToFixWindow() START")
|
2024-01-21 00:15:20 -06:00
|
|
|
if !me.problems.Ready() {
|
|
|
|
return
|
|
|
|
}
|
2024-01-08 22:34:08 -06:00
|
|
|
me.problems.addIPerror(RR, CREATE, ip)
|
2024-01-07 10:38:17 -06:00
|
|
|
log.Log(INFO, "addToFixWindow() END")
|
2024-01-07 05:46:59 -06:00
|
|
|
}
|
|
|
|
|
2024-01-21 00:15:20 -06:00
|
|
|
func drawFixWindow(sw *gadgets.BasicWindow) {
|
2024-01-07 05:46:59 -06:00
|
|
|
log.Log(WARN, "drawFixWindow() START")
|
2024-01-07 10:38:17 -06:00
|
|
|
box := sw.Box()
|
|
|
|
box.NewLabel("test")
|
2024-01-07 05:46:59 -06:00
|
|
|
}
|