fix: protecting concurrent access to LAN hosts

This commit is contained in:
evilsocket 2018-02-20 11:33:30 +01:00
commit 241db0cc66
6 changed files with 43 additions and 23 deletions

View file

@ -8,6 +8,7 @@ import (
"time"
"github.com/evilsocket/bettercap-ng/core"
"github.com/evilsocket/bettercap-ng/network"
"github.com/evilsocket/readline"
)
@ -298,11 +299,11 @@ func (s *Session) registerCoreHandlers() {
readline.PcItem("alias", readline.PcItemDynamic(func(prefix string) []string {
prefix = core.Trim(prefix[5:])
macs := []string{""}
for mac := range s.Lan.Hosts {
s.Lan.EachHost(func(mac string, e *network.Endpoint) {
if prefix == "" || strings.HasPrefix(mac, prefix) == true {
macs = append(macs, mac)
}
}
})
return macs
})))