mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
fix: protecting concurrent access to LAN hosts
This commit is contained in:
parent
3e8ae0339b
commit
241db0cc66
6 changed files with 43 additions and 23 deletions
|
@ -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
|
||||
})))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue