Compare commits

...

2 Commits

Author SHA1 Message Date
Jeff Carr 5e9f1591ca update worked correctly for the first time
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-06 21:02:41 -06:00
Jeff Carr de051d06f3 attempt cloudflare update
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-06 20:14:11 -06:00
4 changed files with 52 additions and 31 deletions

75
fix.go
View File

@ -3,98 +3,113 @@ package main
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/cloudflare"
) )
func fix() bool { func fix() bool {
log.Warn("") log.Log(CHANGE, "")
if ! me.statusDNS.Ready() { if ! me.statusDNS.Ready() {
log.Warn("The IPv6 Control Panel is not Ready() yet") log.Log(CHANGE, "The IPv6 Control Panel is not Ready() yet")
return false return false
} }
if me.statusOS.ValidHostname() { if me.statusOS.ValidHostname() {
log.Warn("Your hostname is VALID:", me.statusOS.GetHostname()) log.Log(CHANGE, "GOOD Your hostname is VALID:", me.statusOS.GetHostname())
} else { } else {
log.Warn("You must first fix your hostname:", me.statusOS.GetHostname()) log.Log(CHANGE, "You must first fix your hostname:", me.statusOS.GetHostname())
return false return false
} }
if me.digStatus.IPv4() { if me.digStatus.IPv4() {
log.Warn("IPv4 addresses are resolving") log.Log(CHANGE, "GOOD IPv4 addresses are resolving")
} else { } else {
log.Warn("You must first figure out why you can't look up IPv4 addresses") log.Log(CHANGE, "You must first figure out why you can't look up IPv4 addresses")
log.Warn("Are you on the internet at all?") log.Log(CHANGE, "Are you on the internet at all?")
return false return false
} }
if me.digStatus.IPv6() { if me.digStatus.IPv6() {
log.Warn("IPv6 addresses are resolving") log.Log(CHANGE, "GOOD IPv6 addresses are resolving")
} else { } else {
log.Warn("You must first figure out why you can't look up IPv6 addresses") log.Log(CHANGE, "You must first figure out why you can't look up IPv6 addresses")
return false return false
} }
if ! me.statusDNS.IPv4() { if ! me.statusDNS.IPv4() {
log.Warn("You do not have real IPv4 addresses. Nothing to fix here") log.Log(CHANGE, "OK You do not have real IPv4 addresses. Nothing to fix here")
} }
if ! me.statusDNS.IPv6() { if ! me.statusDNS.IPv6() {
log.Warn("IPv6 DNS is broken. Check what is broken here") log.Log(CHANGE, "IPv6 DNS is broken. Check what is broken here")
fixIPv6dns() if fixIPv6dns() {
log.Log(CHANGE, "IPv6 DNS Repair is underway")
return false return false
} }
log.Warn("YOU SHOULD BE IN IPv6 BLISS") }
log.Log(CHANGE, "GOOD YOU SHOULD BE IN IPv6 BLISS")
return true return true
} }
func fixIPv6dns() { func fixIPv6dns() bool {
log.Warn("What are my IPv6 addresses?") log.Log(INFO, "What are my IPv6 addresses?")
var broken bool = false
osAAAA := make(map[string]string) osAAAA := make(map[string]string)
dnsAAAA := make(map[string]string) dnsAAAA := make(map[string]string)
for _, aaaa := range me.statusOS.GetIPv6() { for _, aaaa := range me.statusOS.GetIPv6() {
log.Warn("FOUND OS AAAA ip", aaaa) log.Log(INFO, "FOUND OS AAAA ip", aaaa)
osAAAA[aaaa] = "os" osAAAA[aaaa] = "os"
} }
log.Warn("What are the AAAA resource records in DNS?") log.Log(INFO, "What are the AAAA resource records in DNS?")
for _, aaaa := range me.statusDNS.GetIPv6() { for _, aaaa := range me.statusDNS.GetIPv6() {
log.Warn("FOUND DNS AAAA ip", aaaa) log.Log(INFO, "FOUND DNS AAAA ip", aaaa)
dnsAAAA[aaaa] = "dns" dnsAAAA[aaaa] = "dns"
} }
// remove old DNS entries first // remove old DNS entries first
for aaaa, _ := range dnsAAAA { for aaaa, _ := range dnsAAAA {
if osAAAA[aaaa] == "dns" { if osAAAA[aaaa] == "dns" {
log.Warn("DNS AAAA is not in OS", aaaa) log.Log(INFO, "DNS AAAA is not in OS", aaaa)
broken = true
if deleteFromDNS(aaaa) { if deleteFromDNS(aaaa) {
log.Warn("Delete AAAA", aaaa, "Worked") log.Log(INFO, "Delete AAAA", aaaa, "Worked")
} else { } else {
log.Warn("Delete AAAA", aaaa, "Failed") log.Log(INFO, "Delete AAAA", aaaa, "Failed")
} }
} else { } else {
log.Warn("DNS AAAA is in OS", aaaa) log.Log(INFO, "DNS AAAA is in OS", aaaa)
} }
} }
// now add new DNS entries // now add new DNS entries
for aaaa, _ := range osAAAA { for aaaa, _ := range osAAAA {
if dnsAAAA[aaaa] == "dns" { if dnsAAAA[aaaa] == "dns" {
log.Warn("OS AAAA is in DNS", aaaa) log.Log(INFO, "OS AAAA is in DNS", aaaa)
} else { } else {
log.Warn("OS AAAA is not in DNS", aaaa) broken = true
log.Log(INFO, "OS AAAA is not in DNS", aaaa)
if addToDNS(aaaa) { if addToDNS(aaaa) {
log.Warn("Add AAAA", aaaa, "Worked") log.Log(INFO, "Add AAAA", aaaa, "Worked")
} else { } else {
log.Warn("Add AAAA", aaaa, "Failed") log.Log(INFO, "Add AAAA", aaaa, "Failed")
}
} }
} }
} }
// if anything doesn't match, return false
return broken
}
func deleteFromDNS(aaaa string) bool { func deleteFromDNS(aaaa string) bool {
log.Warn("deleteFromDNS", aaaa) log.Log(CHANGE, "deleteFromDNS", aaaa)
return false return false
} }
func addToDNS(aaaa string) bool { func addToDNS(aaaa string) bool {
log.Warn("TODO: Add this to DNS !!!!", aaaa) log.Log(CHANGE, "TODO: Add this to DNS !!!!", aaaa)
log.Warn("what is your API provider?") api := me.statusDNS.API()
log.Log(CHANGE, "what is your API provider?", api)
if api == "cloudflare" {
log.Log(CHANGE, "Let's try an ADD via the Cloudflare API")
hostname := me.statusOS.GetHostname()
return cloudflare.Create("wit.com", hostname, aaaa)
}
return false return false
} }

5
gui.go
View File

@ -193,7 +193,10 @@ func mainWindow(title string) {
me.digStatus.window.Toggle() me.digStatus.window.Toggle()
}) })
gr.NewButton("cloudflare wit.com", func () { gr.NewButton("cloudflare wit.com", func () {
cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06") if me.witcom != nil {
me.witcom.Toggle()
}
me.witcom = cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
}) })
gr.NewButton("Debug", func () { gr.NewButton("Debug", func () {
me.debug.Toggle() me.debug.Toggle()

View File

@ -29,6 +29,7 @@ func myreg(f *log.LogFlag, b bool, name string, desc string) {
func init() { func init() {
myreg(&NOW, true, "NOW", "temp debugging stuff") myreg(&NOW, true, "NOW", "temp debugging stuff")
myreg(&INFO, false, "INFO", "normal debugging stuff")
myreg(&NET, false, "NET", "Network Logging") myreg(&NET, false, "NET", "Network Logging")
myreg(&DNS, false, "DNS", "dnsStatus.update()") myreg(&DNS, false, "DNS", "dnsStatus.update()")
myreg(&PROC, false, "PROC", "/proc logging") myreg(&PROC, false, "PROC", "/proc logging")

View File

@ -6,6 +6,7 @@ import (
"time" "time"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/gui/gadgets"
// "go.wit.com/gui/cloudflare"
"go.wit.com/control-panels/dns/linuxstatus" "go.wit.com/control-panels/dns/linuxstatus"
"github.com/miekg/dns" "github.com/miekg/dns"
@ -57,6 +58,7 @@ type Host struct {
statusIPv6 *gadgets.OneLiner statusIPv6 *gadgets.OneLiner
digStatusButton *gui.Node digStatusButton *gui.Node
witcom *gadgets.BasicWindow
} }
type IPtype struct { type IPtype struct {