mirror of
https://github.com/bettercap/bettercap
synced 2025-07-11 15:46:59 -07:00
new: exposing modules realtime status from the rest api
This commit is contained in:
parent
1220874473
commit
2b117e14d6
2 changed files with 42 additions and 19 deletions
|
@ -22,6 +22,14 @@ type Module interface {
|
|||
Stop() error
|
||||
}
|
||||
|
||||
type JSONModule struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Author string `json:"author"`
|
||||
Parameters map[string]*ModuleParam `json:"parameters"`
|
||||
Running bool `json:"running"`
|
||||
}
|
||||
|
||||
type SessionModule struct {
|
||||
Name string `json:"name"`
|
||||
Session *Session `json:"-"`
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
|
@ -40,28 +41,42 @@ var (
|
|||
|
||||
type UnknownCommandCallback func(cmd string) bool
|
||||
|
||||
type ModuleList []Module
|
||||
|
||||
type Session struct {
|
||||
Options core.Options `json:"options"`
|
||||
Interface *network.Endpoint `json:"interface"`
|
||||
Gateway *network.Endpoint `json:"gateway"`
|
||||
Firewall firewall.FirewallManager `json:"-"`
|
||||
Env *Environment `json:"env"`
|
||||
Lan *network.LAN `json:"lan"`
|
||||
WiFi *network.WiFi `json:"wifi"`
|
||||
BLE *network.BLE `json:"ble"`
|
||||
Queue *packets.Queue `json:"packets"`
|
||||
Input *readline.Instance `json:"-"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
Active bool `json:"active"`
|
||||
GPS nmea.GNGGA `json:"gps"`
|
||||
Prompt Prompt `json:"-"`
|
||||
Options core.Options `json:"options"`
|
||||
Interface *network.Endpoint `json:"interface"`
|
||||
Gateway *network.Endpoint `json:"gateway"`
|
||||
Env *Environment `json:"env"`
|
||||
Lan *network.LAN `json:"lan"`
|
||||
WiFi *network.WiFi `json:"wifi"`
|
||||
BLE *network.BLE `json:"ble"`
|
||||
Queue *packets.Queue `json:"packets"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
Active bool `json:"active"`
|
||||
GPS nmea.GNGGA `json:"gps"`
|
||||
Modules ModuleList `json:"modules"`
|
||||
|
||||
CoreHandlers []CommandHandler `json:"-"`
|
||||
Modules []Module `json:"-"`
|
||||
Input *readline.Instance `json:"-"`
|
||||
Prompt Prompt `json:"-"`
|
||||
CoreHandlers []CommandHandler `json:"-"`
|
||||
Events *EventPool `json:"-"`
|
||||
UnkCmdCallback UnknownCommandCallback `json:"-"`
|
||||
Firewall firewall.FirewallManager `json:"-"`
|
||||
}
|
||||
|
||||
Events *EventPool `json:"-"`
|
||||
|
||||
UnkCmdCallback UnknownCommandCallback `json:"-"`
|
||||
func (mm ModuleList) MarshalJSON() ([]byte, error) {
|
||||
mods := []JSONModule{}
|
||||
for _, m := range mm {
|
||||
mods = append(mods, JSONModule{
|
||||
Name: m.Name(),
|
||||
Description: m.Description(),
|
||||
Author: m.Author(),
|
||||
Parameters: m.Parameters(),
|
||||
Running: m.Running(),
|
||||
})
|
||||
}
|
||||
return json.Marshal(mods)
|
||||
}
|
||||
|
||||
func New() (*Session, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue