mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Clean up old listeners first
This commit is contained in:
		
							parent
							
								
									f4e17b9a9f
								
							
						
					
					
						commit
						c0d5a8c0bd
					
				
					 1 changed files with 9 additions and 9 deletions
				
			
		| 
						 | 
					@ -115,6 +115,15 @@ func (m *multicast) announce() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for {
 | 
						for {
 | 
				
			||||||
		interfaces := m.interfaces()
 | 
							interfaces := m.interfaces()
 | 
				
			||||||
 | 
							// There might be interfaces that we configured listeners for but are no
 | 
				
			||||||
 | 
							// longer up - if that's the case then we should stop the listeners
 | 
				
			||||||
 | 
							for name, listener := range m.listeners {
 | 
				
			||||||
 | 
								if _, ok := interfaces[name]; !ok {
 | 
				
			||||||
 | 
									listener.stop <- true
 | 
				
			||||||
 | 
									delete(m.listeners, name)
 | 
				
			||||||
 | 
									m.core.log.Debugln("No longer multicasting on", name)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		// Now that we have a list of valid interfaces from the operating system,
 | 
							// Now that we have a list of valid interfaces from the operating system,
 | 
				
			||||||
		// we can start checking if we can send multicasts on them
 | 
							// we can start checking if we can send multicasts on them
 | 
				
			||||||
		for _, iface := range interfaces {
 | 
							for _, iface := range interfaces {
 | 
				
			||||||
| 
						 | 
					@ -164,15 +173,6 @@ func (m *multicast) announce() {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			time.Sleep(time.Second)
 | 
								time.Sleep(time.Second)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// There might be interfaces that we configured listeners for but are no
 | 
					 | 
				
			||||||
		// longer up - if that's the case then we should stop the listeners
 | 
					 | 
				
			||||||
		for name, listener := range m.listeners {
 | 
					 | 
				
			||||||
			if _, ok := interfaces[name]; !ok {
 | 
					 | 
				
			||||||
				listener.stop <- true
 | 
					 | 
				
			||||||
				delete(m.listeners, name)
 | 
					 | 
				
			||||||
				m.core.log.Debugln("No longer multicasting on", name)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		time.Sleep(time.Second * 5)
 | 
							time.Sleep(time.Second * 5)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue