summaryrefslogtreecommitdiff
path: root/hostname.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-12-20 03:13:43 -0600
committerJeff Carr <[email protected]>2023-12-20 03:13:43 -0600
commit4c3be58461858c511a25da62e63e29c9b90a63a6 (patch)
treea365654c7789aba6a120564fecac3d8ce8422f89 /hostname.go
parent1532d885e0e4d6de1db6075a96d1af086ff62312 (diff)
make a cloudflare packagev0.1.2
move cloudflare stuff to a package display cloudflare API values dns protobuf example sort output, but gocli formatting is bad cloudflare window can be closed first time success pushing AAAA records for my box enable a cloudflare button RFC 8482. DNS servers we use should respond to ANY We should support ANY requests via DNS as long as we enforce TCP over UDP populate the API provider domain NS record changes are tracked check hostname OS configuration detect domain name changes lookup of NS records for my domain name button to investigate port 53 daemon start dns resolver detection and debugging measure dns resolution speed sort todo items Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'hostname.go')
-rw-r--r--hostname.go71
1 files changed, 59 insertions, 12 deletions
diff --git a/hostname.go b/hostname.go
index 62803c1..06e2ce7 100644
--- a/hostname.go
+++ b/hostname.go
@@ -6,8 +6,12 @@
package main
import (
- "log"
"git.wit.org/wit/shell"
+
+ // dnssec IPv6 socket library
+ "git.wit.org/jcarr/dnssecsocket"
+
+ "git.wit.org/jcarr/control-panel-dns/cloudflare"
)
// will try to get this hosts FQDN
@@ -16,15 +20,13 @@ import "github.com/Showmax/go-fqdn"
// this is the king of dns libraries
import "github.com/miekg/dns"
-// dnssec IPv6 socket library
-import "git.wit.org/jcarr/dnssecsocket"
func getHostname() {
var err error
var s string = "gui.Label == nil"
s, err = fqdn.FqdnHostname()
if (err != nil) {
- log.Println("FQDN hostname error =", err)
+ debug(LogError, "FQDN hostname error =", err)
return
}
if (me.fqdn != nil) {
@@ -34,7 +36,47 @@ func getHostname() {
me.changed = true
}
}
- log.Println("FQDN =", s)
+ debug(LogNet, "FQDN =", s)
+
+ dn := run("domainname")
+ if (me.domainname.S != dn) {
+ debug(LogChange, "domainname has changed from", me.domainname.S, "to", dn)
+ me.domainname.SetText(dn)
+ me.changed = true
+ }
+
+ hshort := run("hostname -s")
+ if (me.hostshort.S != hshort) {
+ debug(LogChange, "hostname -s has changed from", me.hostshort.S, "to", hshort)
+ me.hostshort.SetText(hshort)
+ me.changed = true
+ }
+
+ var test string
+ test = hshort + "." + dn
+ if (me.hostname != test) {
+ debug(LogInfo, "me.hostname", me.hostname, "does not equal", test)
+ if (me.hostnameStatus.S != "BROKEN") {
+ debug(LogChange, "me.hostname", me.hostname, "does not equal", test)
+ me.changed = true
+ me.hostnameStatus.SetText("BROKEN")
+ }
+ } else {
+ if (me.hostnameStatus.S != "VALID") {
+ debug(LogChange, "me.hostname", me.hostname, "is valid")
+ me.hostnameStatus.SetText("VALID")
+ me.changed = true
+ }
+ // enable the cloudflare button if the provider is cloudflare
+ if (me.cloudflareB == nil) {
+ debug(LogChange, "me.cloudflare == nil; me.DnsAPI.S =", me.DnsAPI.S)
+ if (me.DnsAPI.S == "cloudflare") {
+ me.cloudflareB = me.mainStatus.NewButton("cloudflare wit.com", func () {
+ cloudflare.CreateRR(myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
+ })
+ }
+ }
+ }
}
// returns true if the hostname is good
@@ -43,31 +85,36 @@ func getHostname() {
// and domainname and hostname
func goodHostname(h string) bool {
hostname := shell.Chomp(shell.Cat("/etc/hostname"))
- log.Println("hostname =", hostname)
+ debug(true, "hostname =", hostname)
hs := run("hostname -s")
dn := run("domainname")
- log.Println("hostname short =", hs, "domainname =", dn)
+ debug(true, "hostname short =", hs, "domainname =", dn)
tmp := hs + "." + dn
if (hostname == tmp) {
- log.Println("hostname seems to be good", hostname)
+ debug(true, "hostname seems to be good", hostname)
return true
}
return false
}
-func dnsAAAA(s string) []string {
+func digAAAA(s string) []string {
var aaaa []string
// lookup the IP address from DNS
rrset := dnssecsocket.Dnstrace(s, "AAAA")
- log.Println(args.VerboseDNS, SPEW, rrset)
+ // debug(true, args.VerboseDNS, SPEW, rrset)
for i, rr := range rrset {
- log.Println(args.VerboseDNS, "r.Answer =", i, rr)
ipaddr := dns.Field(rr, 1)
+ // how the hell do you detect a RRSIG AAAA record here?
+ if (ipaddr == "28") {
+ continue
+ }
+ debug(LogNow, "r.Answer =", i, "rr =", rr, "ipaddr =", ipaddr)
aaaa = append(aaaa, ipaddr)
+ me.ipv6s[ipaddr] = rr
}
- log.Println(args.VerboseDNS, "aaaa =", aaaa)
+ debug(true, args.VerboseDNS, "aaaa =", aaaa)
return aaaa
}