mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
new: properly exposing module handlers and parameters from api.rest
This commit is contained in:
parent
87ac32cd6b
commit
b98db78926
4 changed files with 64 additions and 22 deletions
|
@ -43,6 +43,30 @@ type UnknownCommandCallback func(cmd string) bool
|
|||
|
||||
type ModuleList []Module
|
||||
|
||||
type JSONModule struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Author string `json:"author"`
|
||||
Parameters map[string]*ModuleParam `json:"parameters"`
|
||||
Handlers []ModuleHandler `json:"handlers"`
|
||||
Running bool `json:"running"`
|
||||
}
|
||||
|
||||
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(),
|
||||
Handlers: m.Handlers(),
|
||||
Running: m.Running(),
|
||||
})
|
||||
}
|
||||
return json.Marshal(mods)
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
Options core.Options `json:"options"`
|
||||
Interface *network.Endpoint `json:"interface"`
|
||||
|
@ -65,20 +89,6 @@ type Session struct {
|
|||
Firewall firewall.FirewallManager `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) {
|
||||
var err error
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue