mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
new: parsing device name from intercepted mdns:md values
This commit is contained in:
parent
654585ff1f
commit
431215b053
2 changed files with 18 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue