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:
Neil Alexander 2022-09-24 12:22:38 +01:00
parent 5ef61faeff
commit b67c313f44
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
5 changed files with 193 additions and 123 deletions

View file

@ -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
},
)
}