Skip to content

Commit

Permalink
show forward DNS name for internet addresses
Browse files Browse the repository at this point in the history
...if available.

Follow-up to #1863.
  • Loading branch information
rade committed Sep 22, 2016
1 parent 8462819 commit 2da6dee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
11 changes: 4 additions & 7 deletions render/detailed/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"sort"
"strconv"

"github.com/weaveworks/scope/probe/endpoint"
"github.com/weaveworks/scope/render"
"github.com/weaveworks/scope/report"
)
Expand Down Expand Up @@ -113,12 +112,10 @@ func internetAddr(node report.Node, ep report.Node) (string, bool) {
if !ok {
return "", false
}
if set, ok := ep.Sets.Lookup(endpoint.ReverseDNSNames); ok && len(set) > 0 {
// TODO We show just one of the names, selected rather
// abitrarily. We don't have space to show all (except in the
// tooltip perhaps), but should think of better strategies for
// choosing the name to display.
addr = fmt.Sprintf("%s (%s)", set[0], addr)
if names := render.DNSNames(ep); len(names) > 0 {
// we show the "most important" name only, since we don't have
// space for more
addr = fmt.Sprintf("%s (%s)", names[0], addr)
}
return addr, true
}
Expand Down
29 changes: 17 additions & 12 deletions render/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,29 @@ func MapProcess2Name(n report.Node, _ report.Networks) report.Nodes {
return report.Nodes{name: node}
}

func externalNode(m report.Node) report.Node {
func externalNode(n report.Node) report.Node {
// First, check if it's a known service and emit a
// a specific node if it is
snoopedHostnames, _ := m.Sets.Lookup(endpoint.SnoopedDNSNames)
reverseHostnames, _ := m.Sets.Lookup(endpoint.ReverseDNSNames)
// Sort the names to make the lookup more deterministic
sort.StringSlice(snoopedHostnames).Sort()
sort.StringSlice(reverseHostnames).Sort()
// Intentionally prioritize snooped hostnames
for _, hostname := range append(snoopedHostnames, reverseHostnames...) {
for _, hostname := range DNSNames(n) {
if isKnownService(hostname) {
return NewDerivedPseudoNode(ServiceNodeIDPrefix+hostname, m)
return NewDerivedPseudoNode(ServiceNodeIDPrefix+hostname, n)
}
}

// emit one internet node for incoming, one for outgoing
if len(m.Adjacency) > 0 {
return NewDerivedPseudoNode(IncomingInternetID, m)
if len(n.Adjacency) > 0 {
return NewDerivedPseudoNode(IncomingInternetID, n)
}
return NewDerivedPseudoNode(OutgoingInternetID, m)
return NewDerivedPseudoNode(OutgoingInternetID, n)
}

func DNSNames(n report.Node) []string {
snoopedNames, _ := n.Sets.Lookup(endpoint.SnoopedDNSNames)
reverseNames, _ := n.Sets.Lookup(endpoint.ReverseDNSNames)
// sort the names, to make selection for display more
// deterministic
sort.StringSlice(snoopedNames).Sort()
sort.StringSlice(reverseNames).Sort()
// prioritize snooped names
return append(snoopedNames, reverseNames...)
}

0 comments on commit 2da6dee

Please sign in to comment.