Skip to content

Commit

Permalink
Merge pull request #41 from wallyqs/fix-host-alignment
Browse files Browse the repository at this point in the history
Host column alignment fixes
  • Loading branch information
Waldemar Quevedo authored Aug 24, 2016
2 parents ad683d0 + fdffc2c commit 3f9d4ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nats-top.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,20 @@ 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
}
} else {
hostname = fmt.Sprintf("%s:%d", hostname, conn.Port)
hostname = fmt.Sprintf("%s:%d", conn.IP, conn.Port)
}

// host
Expand Down

0 comments on commit 3f9d4ab

Please sign in to comment.