From 041e3a0c6ede6cd96308caf49b2230d5bcb58dac Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 18 Feb 2023 23:37:11 -0600 Subject: v0.0.2 next step: acutally try to nsupdate upto the point where DNS update is next. start displaying real AAAA & naming buttons add RFC 2136 defining nsupdate. Vixie et al in 1997 Personal thansk to Paul for meeting with me some years back ready to pull DNS records starting a checkDNS() function dampen output. actually track IPs poll every 2 seconds (netlink is not the right thing here) ready to start looking for changes screw everything about logging. I hate log.whatthefuck*(){} Do you know what I don't care about? log() You shouldn't care either. Ignore it until you need it that is what logging is for. building something that works. So, here you go. a damn log() function in one place Also, because I'm annoyed today sleep() and exit() Because, when I want you to sleep or exit, I don't want to go to the top of a file and declare stupid shit related to nanoseconds or add "import os.Exit" or whatever the hell stop wasting my time. life is short. if he sit tunnelbroker down add IsRealIP() and IsIPv6() need a netlink function to trigger on changes (nope) put the gui plugin's in the debian package for now set the window title build a .deb package Signed-off-by: Jeff Carr --- hostname.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 hostname.go (limited to 'hostname.go') diff --git a/hostname.go b/hostname.go new file mode 100644 index 0000000..4725d2c --- /dev/null +++ b/hostname.go @@ -0,0 +1,45 @@ +// inspired from: +// https://github.com/mactsouk/opensource.com.git +// and +// https://coderwall.com/p/wohavg/creating-a-simple-tcp-server-in-go + +package main + +// import "net" + +// will try to get this hosts FQDN +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 + me.fqdn, err = fqdn.FqdnHostname() + if (err != nil) { + log("FQDN hostname error =", err) + exit() + return + } + log("FQDN hostname is", me.fqdn) + + var aaaa []string + aaaa = getAAAA(me.fqdn) + log("AAAA =", aaaa) +} + +func getAAAA(s string) []string { + // lookup the IP address from DNS + dnsRR := dnssecsocket.Dnstrace(s, "AAAA") + log(args.VerboseDNS, SPEW, dnsRR) + if (dnsRR == nil) { + return nil + } + ipaddr1 := dns.Field(dnsRR, 1) + ipaddr2 := dns.Field(dnsRR, 2) + log("ipaddr", ipaddr1, ipaddr2) + return []string{ipaddr1, ipaddr2} +} -- cgit v1.2.3