mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Admin socket and yggdrasilctl
improvements
This refactors the request parsing, as well as improving the output for some request types. It also tweaks `yggdrasilctl` output, which should help with #947.
This commit is contained in:
parent
5ef61faeff
commit
b67c313f44
5 changed files with 193 additions and 123 deletions
|
@ -20,15 +20,18 @@ func (m *Multicast) getMulticastInterfacesHandler(req *GetMulticastInterfacesReq
|
|||
}
|
||||
|
||||
func (m *Multicast) SetupAdminHandlers(a *admin.AdminSocket) {
|
||||
_ = a.AddHandler("getMulticastInterfaces", []string{}, func(in json.RawMessage) (interface{}, error) {
|
||||
req := &GetMulticastInterfacesRequest{}
|
||||
res := &GetMulticastInterfacesResponse{}
|
||||
if err := json.Unmarshal(in, &req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := m.getMulticastInterfacesHandler(req, res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
})
|
||||
_ = a.AddHandler(
|
||||
"getMulticastInterfaces", "Show which interfaces multicast is enabled on", []string{},
|
||||
func(in json.RawMessage) (interface{}, error) {
|
||||
req := &GetMulticastInterfacesRequest{}
|
||||
res := &GetMulticastInterfacesResponse{}
|
||||
if err := json.Unmarshal(in, &req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := m.getMulticastInterfacesHandler(req, res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue