5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-26 00:11:36 +00:00

Act multicast updates for safety

This commit is contained in:
Neil Alexander 2019-10-23 11:12:51 +01:00
parent a072e063d8
commit 337626a32c
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
3 changed files with 11 additions and 9 deletions

2
go.mod
View File

@ -17,5 +17,3 @@ require (
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
golang.org/x/text v0.3.2
)
go 1.13

View File

@ -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()

View File

@ -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 {