mirror of
https://github.com/bettercap/bettercap
synced 2025-07-07 13:32:07 -07:00
fix: locking the session object when it's read by the api module (fixes #349)
This commit is contained in:
parent
7951981815
commit
7b7739358d
2 changed files with 15 additions and 0 deletions
|
@ -186,6 +186,9 @@ func (api *RestAPI) sessionRoute(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session.I.Lock()
|
||||||
|
defer session.I.Unlock()
|
||||||
|
|
||||||
path := r.URL.String()
|
path := r.URL.String()
|
||||||
switch {
|
switch {
|
||||||
case path == "/api/session":
|
case path == "/api/session":
|
||||||
|
|
|
@ -108,6 +108,18 @@ func New() (*Session, error) {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Session) Lock() {
|
||||||
|
s.Env.Lock()
|
||||||
|
s.Lan.Lock()
|
||||||
|
s.WiFi.Lock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Session) Unlock() {
|
||||||
|
s.Env.Unlock()
|
||||||
|
s.Lan.Unlock()
|
||||||
|
s.WiFi.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Session) Module(name string) (err error, mod Module) {
|
func (s *Session) Module(name string) (err error, mod Module) {
|
||||||
for _, m := range s.Modules {
|
for _, m := range s.Modules {
|
||||||
if m.Name() == name {
|
if m.Name() == name {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue