Refactor admin socket somewhat, allow modules to set up their own handlers

This commit is contained in:
Neil Alexander 2019-05-19 22:02:04 +01:00
parent 8ef1978cb1
commit d575b83ec1
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 379 additions and 400 deletions

13
src/multicast/admin.go Normal file
View file

@ -0,0 +1,13 @@
package multicast
import "github.com/yggdrasil-network/yggdrasil-go/src/admin"
func (m *Multicast) SetupAdminHandlers(a *admin.AdminSocket) {
a.AddHandler("getMulticastInterfaces", []string{}, func(in admin.Info) (admin.Info, error) {
var intfs []string
for _, v := range m.interfaces() {
intfs = append(intfs, v.Name)
}
return admin.Info{"multicast_interfaces": intfs}, nil
})
}