From df91e3b1914c1507233e1b6a6c4fb639b8141055 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 24 May 2019 21:50:23 -0700 Subject: [PATCH] fix crash on nil Signed-off-by: Jeff Carr --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index c0029ce..8c0c497 100644 --- a/main.go +++ b/main.go @@ -85,6 +85,9 @@ func lookupAAAA(hostname string) string { // lookup the IP address from DNS dnsRR := dnssecsocket.Dnstrace(hostname, "AAAA") spew.Dump(dnsRR) + if (dnsRR == nil) { + return "BROKEN" + } ipaddr := dns.Field(dnsRR, 1) log.Println("ipaddr", ipaddr) return ipaddr @@ -122,11 +125,14 @@ func main() { gui.Data.Width = int(pbC.Width) gui.Data.Height = int(pbC.Height) + // use this to discover what the OS thinks it's hostname is + // seems to be cross platform (?) hostname := fqdn.Get() log.Println("fqdn.Get() = ", hostname) gui.Data.Hostname = hostname - // TODO: figure out the IPv6 address the right way - // probably dig AAAA + + // this is a recursive dig for the AAAA record + // TODO: check for dns hijacking ipAAAA := lookupAAAA(hostname) gui.Data.IPv6 = ipAAAA @@ -368,7 +374,6 @@ func watchGUI() { } if (gui.Data.State == "CREATE") { log.Println("\tTRIGGERING CREATE HERE") - event := pb.MakeAddVmEvent() event.Username = gui.Data.Current.Username event.Token = gui.Data.Current.Token