fix: command handlers are now atomically locked

This commit is contained in:
evilsocket 2019-02-26 13:26:28 +01:00
commit e46ea6c9a9
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
3 changed files with 21 additions and 12 deletions

View file

@ -11,7 +11,6 @@ import (
"runtime/pprof"
"sort"
"strings"
"sync"
"time"
"github.com/bettercap/readline"
@ -95,8 +94,6 @@ type Session struct {
Events *EventPool `json:"-"`
UnkCmdCallback UnknownCommandCallback `json:"-"`
Firewall firewall.FirewallManager `json:"-"`
cmdLock sync.Mutex
}
func New() (*Session, error) {
@ -121,8 +118,6 @@ func New() (*Session, error) {
Modules: make([]Module, 0),
Events: nil,
UnkCmdCallback: nil,
cmdLock: sync.Mutex{},
}
if *s.Options.CpuProfile != "" {
@ -391,9 +386,6 @@ 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