diff --git a/crash1-fqdn b/crash1-fqdn index e9a6fb4..e02c07a 100644 --- a/crash1-fqdn +++ b/crash1-fqdn @@ -1,3 +1,5 @@ +This thing segfault'd with fqdn lookup on weird network errors when I was at the office on wifi + 2019/06/01 21:11:47 connecting to ws://v000185.testing.com.customers.wprod.wit.com:9000/event 2019/06/01 21:11:47 fqdn.Get() = librem15.lab.wit.com INFO[0000] *** error: read udp [2604:bbc0:1:22::f5d3:7f44]:50435->[2001:500:12::d0d]:53: i/o timeout diff --git a/fqdn.go b/fqdn.go index 78bd22b..d5f7773 100644 --- a/fqdn.go +++ b/fqdn.go @@ -1,30 +1,36 @@ package main -import ( - "net" - "os" - "strings" -) +import "net" +import "os" +import "strings" +import "log" // Get Fully Qualified Domain Name // returns "unknown" or hostanme in case of error -func FqdnGet() string { +func fqdnGet() string { + log.Println("fqdnGet() START") hostname, err := os.Hostname() if err != nil { return "unknown" } + log.Println("\tfqdnGet() net.LookupIP(hostname) hostname =", hostname) addrs, err := net.LookupIP(hostname) if err != nil { + log.Println("\tfqdnGet() net.LookupIP(hostname) err =", err) return hostname } + log.Println("\tfqdnGet() range addrs") for _, addr := range addrs { + log.Println("\tfqdnGet() addr = ", addr) if ipv4 := addr.To4(); ipv4 != nil { ip, err := ipv4.MarshalText() + log.Println("\tfqdnGet() ip = ", string(ip)) if err != nil { return hostname } + log.Println("\tfqdnGet() net.LookupAddr = ", string(ip)) hosts, err := net.LookupAddr(string(ip)) if err != nil || len(hosts) == 0 { return hostname diff --git a/main.go b/main.go index 8b529b9..c130d69 100644 --- a/main.go +++ b/main.go @@ -106,8 +106,8 @@ func main() { // use this to discover what the OS thinks it's hostname is // seems to be cross platform (?) // Windows: WMIC computersystem where caption='current_pc_name' rename new_pc_name - hostname := FqdnGet() - log.Println("fqdn.Get() = ", hostname) + hostname := fqdnGet() + log.Println("fqdnGet() = ", hostname) config.Hostname = hostname // this is a recursive dig for the AAAA record