From b91bb6131766233820f51873bf9ae1b6c84f5906 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo <wally@apcera.com> Date: Tue, 23 Aug 2016 20:32:19 -0700 Subject: [PATCH 1/2] Fix issue with empty host values from lookup addr --- nats-top.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nats-top.go b/nats-top.go index 103ef10..43fcb59 100644 --- a/nats-top.go +++ b/nats-top.go @@ -202,9 +202,14 @@ func generateParagraph( // them for subsequent polls. if addr, present := resolvedHosts[conn.IP]; !present { addrs, err := net.LookupAddr(conn.IP) - if err == nil && len(addrs) > 0 { + if err == nil && len(addrs) > 0 && len(addrs[0]) > 0 { hostname = addrs[0] resolvedHosts[conn.IP] = hostname + } else { + // Otherwise just continue to use ip:port as resolved host + // can be an empty string even though there were no errors. + hostname = fmt.Sprintf("%s:%d", conn.IP, conn.Port) + resolvedHosts[conn.IP] = hostname } } else { hostname = addr From fdffc2ce5c59877dd5c2a263903e06d76fc0ee41 Mon Sep 17 00:00:00 2001 From: Waldemar Quevedo <wally@apcera.com> Date: Tue, 23 Aug 2016 20:37:54 -0700 Subject: [PATCH 2/2] Bug fix for host alignment... --- nats-top.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nats-top.go b/nats-top.go index 43fcb59..be551de 100644 --- a/nats-top.go +++ b/nats-top.go @@ -215,7 +215,7 @@ func generateParagraph( hostname = addr } } else { - hostname = fmt.Sprintf("%s:%d", hostname, conn.Port) + hostname = fmt.Sprintf("%s:%d", conn.IP, conn.Port) } // host