fix crash on nil
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
6b0763c3fd
commit
df91e3b191
11
main.go
11
main.go
|
@ -85,6 +85,9 @@ func lookupAAAA(hostname string) string {
|
||||||
// lookup the IP address from DNS
|
// lookup the IP address from DNS
|
||||||
dnsRR := dnssecsocket.Dnstrace(hostname, "AAAA")
|
dnsRR := dnssecsocket.Dnstrace(hostname, "AAAA")
|
||||||
spew.Dump(dnsRR)
|
spew.Dump(dnsRR)
|
||||||
|
if (dnsRR == nil) {
|
||||||
|
return "BROKEN"
|
||||||
|
}
|
||||||
ipaddr := dns.Field(dnsRR, 1)
|
ipaddr := dns.Field(dnsRR, 1)
|
||||||
log.Println("ipaddr", ipaddr)
|
log.Println("ipaddr", ipaddr)
|
||||||
return ipaddr
|
return ipaddr
|
||||||
|
@ -122,11 +125,14 @@ func main() {
|
||||||
gui.Data.Width = int(pbC.Width)
|
gui.Data.Width = int(pbC.Width)
|
||||||
gui.Data.Height = int(pbC.Height)
|
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()
|
hostname := fqdn.Get()
|
||||||
log.Println("fqdn.Get() = ", hostname)
|
log.Println("fqdn.Get() = ", hostname)
|
||||||
gui.Data.Hostname = hostname
|
gui.Data.Hostname = hostname
|
||||||
// TODO: figure out the IPv6 address the right way
|
|
||||||
// probably dig <hostname> AAAA
|
// this is a recursive dig for the AAAA record
|
||||||
|
// TODO: check for dns hijacking
|
||||||
ipAAAA := lookupAAAA(hostname)
|
ipAAAA := lookupAAAA(hostname)
|
||||||
gui.Data.IPv6 = ipAAAA
|
gui.Data.IPv6 = ipAAAA
|
||||||
|
|
||||||
|
@ -368,7 +374,6 @@ func watchGUI() {
|
||||||
}
|
}
|
||||||
if (gui.Data.State == "CREATE") {
|
if (gui.Data.State == "CREATE") {
|
||||||
log.Println("\tTRIGGERING CREATE HERE")
|
log.Println("\tTRIGGERING CREATE HERE")
|
||||||
|
|
||||||
event := pb.MakeAddVmEvent()
|
event := pb.MakeAddVmEvent()
|
||||||
event.Username = gui.Data.Current.Username
|
event.Username = gui.Data.Current.Username
|
||||||
event.Token = gui.Data.Current.Token
|
event.Token = gui.Data.Current.Token
|
||||||
|
|
Loading…
Reference in New Issue