mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
new: net.show now accepts a comma separated list of ip, macs or aliases to filter for
This commit is contained in:
parent
09caa4dd37
commit
a2b3ee79fb
4 changed files with 52 additions and 32 deletions
|
@ -118,6 +118,32 @@ func ParseTargets(targets string, aliasMap *Aliases) (ips []net.IP, macs []net.H
|
|||
return
|
||||
}
|
||||
|
||||
func ParseEndpoints(targets string, lan *LAN) ([]*Endpoint, error) {
|
||||
ips, macs, err := ParseTargets(targets, lan.Aliases())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tmp := make(map[string]*Endpoint)
|
||||
for _, ip := range ips {
|
||||
if e := lan.GetByIp(ip.String()); e != nil {
|
||||
tmp[e.HW.String()] = e
|
||||
}
|
||||
}
|
||||
|
||||
for _, mac := range macs {
|
||||
if e, found := lan.Get(mac.String()); found {
|
||||
tmp[e.HW.String()] = e
|
||||
}
|
||||
}
|
||||
|
||||
ret := make([]*Endpoint, 0)
|
||||
for _, e := range tmp {
|
||||
ret = append(ret, e)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func buildEndpointFromInterface(iface net.Interface) (*Endpoint, error) {
|
||||
addrs, err := iface.Addrs()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue