mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
fix: locking session object instance while session.Run
This commit is contained in:
parent
b6979f2baf
commit
d5016bc506
2 changed files with 11 additions and 0 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"runtime/pprof"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bettercap/readline"
|
||||
|
@ -94,6 +95,8 @@ type Session struct {
|
|||
Events *EventPool `json:"-"`
|
||||
UnkCmdCallback UnknownCommandCallback `json:"-"`
|
||||
Firewall firewall.FirewallManager `json:"-"`
|
||||
|
||||
cmdLock sync.Mutex
|
||||
}
|
||||
|
||||
func New() (*Session, error) {
|
||||
|
@ -118,6 +121,8 @@ func New() (*Session, error) {
|
|||
Modules: make([]Module, 0),
|
||||
Events: nil,
|
||||
UnkCmdCallback: nil,
|
||||
|
||||
cmdLock: sync.Mutex{},
|
||||
}
|
||||
|
||||
if *s.Options.CpuProfile != "" {
|
||||
|
@ -386,6 +391,9 @@ func parseCapletCommand(line string) (is bool, caplet *caplets.Caplet, argv []st
|
|||
}
|
||||
|
||||
func (s *Session) Run(line string) error {
|
||||
s.cmdLock.Lock()
|
||||
defer s.cmdLock.Unlock()
|
||||
|
||||
line = str.TrimRight(line)
|
||||
// remove extra spaces after the first command
|
||||
// so that 'arp.spoof on' is normalized
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue