Skip to content

Commit

Permalink
Merge pull request #1881 from weaveworks/show-internet-forward-dns
Browse files Browse the repository at this point in the history
show forward DNS name for internet addresses
  • Loading branch information
rade authored Sep 22, 2016
2 parents 8462819 + 5ce5d54 commit 090d330
Show file tree
Hide file tree
Showing 2 changed files with 23 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
31 changes: 19 additions & 12 deletions render/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,31 @@ 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)
}

// DNSNames returns a prioritized list of snooped and reverse-resolved
// DNS names associated with node 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 090d330

Please sign in to comment.