new: parsing device name from intercepted mdns:md values

This commit is contained in:
evilsocket 2018-09-22 14:13:43 +02:00
commit 431215b053
2 changed files with 18 additions and 6 deletions

View file

@ -154,3 +154,20 @@ func (t *Endpoint) String() string {
}
return fmt.Sprintf("%s%s ( %s ) - %s", ipPart, t.HwAddress, t.Vendor, core.Bold(t.Hostname))
}
func (t *Endpoint) OnMeta(meta map[string]string) {
host := ""
for k, v := range meta {
// simple heuristics to get the longest candidate name
if strings.HasSuffix(k, ":hostname") && len(v) > len(host) {
host = v
} else if k == "mdns:md" && len(v) > len(host) {
host = v
}
t.Meta.Set(k, v)
}
if t.Hostname == "" {
t.Hostname = host
}
}

View file

@ -95,12 +95,7 @@ func (s *Session) startNetMon() {
}
if existing != nil && event.Meta != nil {
for k, v := range event.Meta {
if strings.HasSuffix(k, ":hostname") && existing.Hostname == "" {
existing.Hostname = v
}
existing.Meta.Set(k, v)
}
existing.OnMeta(event.Meta)
}
}
}