fix: exposing session modules as a map in api.rest for quick lookup

This commit is contained in:
evilsocket 2019-03-18 12:59:39 +01:00
commit 49aeb37b5c
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -39,7 +39,7 @@ type moduleJSON struct {
} }
func (mm ModuleList) MarshalJSON() ([]byte, error) { func (mm ModuleList) MarshalJSON() ([]byte, error) {
mods := []moduleJSON{} mods := make(map[string]moduleJSON)
for _, m := range mm { for _, m := range mm {
mJSON := moduleJSON{ mJSON := moduleJSON{
Name: m.Name(), Name: m.Name(),
@ -50,7 +50,7 @@ func (mm ModuleList) MarshalJSON() ([]byte, error) {
Running: m.Running(), Running: m.Running(),
State: m.Extra(), State: m.Extra(),
} }
mods = append(mods, mJSON) mods[m.Name()] = mJSON
} }
return json.Marshal(mods) return json.Marshal(mods)
} }