From 337626a32cc38c13e6809e63aff60b2c4be1b0ae Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 23 Oct 2019 11:12:51 +0100 Subject: [PATCH] Act multicast updates for safety --- go.mod | 2 -- src/admin/admin.go | 14 +++++++------- src/multicast/multicast.go | 4 ++++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index d1a3587f..83c22924 100644 --- a/go.mod +++ b/go.mod @@ -17,5 +17,3 @@ require ( golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a golang.org/x/text v0.3.2 ) - -go 1.13 diff --git a/src/admin/admin.go b/src/admin/admin.go index f7637998..8028bcc6 100644 --- a/src/admin/admin.go +++ b/src/admin/admin.go @@ -60,6 +60,13 @@ func (a *AdminSocket) Init(c *yggdrasil.Core, state *config.NodeState, log *log. a.handlers = make(map[string]handler) current := state.GetCurrent() a.listenaddr = current.AdminListen + a.AddHandler("list", []string{}, func(in Info) (Info, error) { + handlers := make(map[string]interface{}) + for handlername, handler := range a.handlers { + handlers[handlername] = Info{"fields": handler.args} + } + return Info{"list": handlers}, nil + }) return nil } @@ -75,13 +82,6 @@ func (a *AdminSocket) UpdateConfig(config *config.NodeConfig) { } func (a *AdminSocket) SetupAdminHandlers(na *AdminSocket) { - a.AddHandler("list", []string{}, func(in Info) (Info, error) { - handlers := make(map[string]interface{}) - for handlername, handler := range a.handlers { - handlers[handlername] = Info{"fields": handler.args} - } - return Info{"list": handlers}, nil - }) a.AddHandler("getSelf", []string{}, func(in Info) (Info, error) { ip := a.core.Address().String() subnet := a.core.Subnet() diff --git a/src/multicast/multicast.go b/src/multicast/multicast.go index 6c1af1c4..deffecd2 100644 --- a/src/multicast/multicast.go +++ b/src/multicast/multicast.go @@ -109,6 +109,10 @@ func (m *Multicast) Stop() error { // and then signals the various module goroutines to reconfigure themselves if // needed. func (m *Multicast) UpdateConfig(config *config.NodeConfig) { + m.Act(m, func() { m._updateConfig(config) }) +} + +func (m *Multicast) _updateConfig(config *config.NodeConfig) { m.log.Debugln("Reloading multicast configuration...") if m.IsStarted() { if len(config.MulticastInterfaces) == 0 || config.LinkLocalTCPPort != m.listenPort {