mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Act multicast updates for safety
This commit is contained in:
		
							parent
							
								
									a072e063d8
								
							
						
					
					
						commit
						337626a32c
					
				
					 3 changed files with 11 additions and 9 deletions
				
			
		
							
								
								
									
										2
									
								
								go.mod
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
										
									
									
									
								
							| 
						 | 
					@ -17,5 +17,3 @@ require (
 | 
				
			||||||
	golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
 | 
						golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
 | 
				
			||||||
	golang.org/x/text v0.3.2
 | 
						golang.org/x/text v0.3.2
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					 | 
				
			||||||
go 1.13
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,6 +60,13 @@ func (a *AdminSocket) Init(c *yggdrasil.Core, state *config.NodeState, log *log.
 | 
				
			||||||
	a.handlers = make(map[string]handler)
 | 
						a.handlers = make(map[string]handler)
 | 
				
			||||||
	current := state.GetCurrent()
 | 
						current := state.GetCurrent()
 | 
				
			||||||
	a.listenaddr = current.AdminListen
 | 
						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
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,13 +82,6 @@ func (a *AdminSocket) UpdateConfig(config *config.NodeConfig) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (a *AdminSocket) SetupAdminHandlers(na *AdminSocket) {
 | 
					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) {
 | 
						a.AddHandler("getSelf", []string{}, func(in Info) (Info, error) {
 | 
				
			||||||
		ip := a.core.Address().String()
 | 
							ip := a.core.Address().String()
 | 
				
			||||||
		subnet := a.core.Subnet()
 | 
							subnet := a.core.Subnet()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -109,6 +109,10 @@ func (m *Multicast) Stop() error {
 | 
				
			||||||
// and then signals the various module goroutines to reconfigure themselves if
 | 
					// and then signals the various module goroutines to reconfigure themselves if
 | 
				
			||||||
// needed.
 | 
					// needed.
 | 
				
			||||||
func (m *Multicast) UpdateConfig(config *config.NodeConfig) {
 | 
					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...")
 | 
						m.log.Debugln("Reloading multicast configuration...")
 | 
				
			||||||
	if m.IsStarted() {
 | 
						if m.IsStarted() {
 | 
				
			||||||
		if len(config.MulticastInterfaces) == 0 || config.LinkLocalTCPPort != m.listenPort {
 | 
							if len(config.MulticastInterfaces) == 0 || config.LinkLocalTCPPort != m.listenPort {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue