mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Add LinkLocalTCPPort option
This commit is contained in:
		
							parent
							
								
									07822a74c7
								
							
						
					
					
						commit
						9d5ca85424
					
				
					 3 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -22,6 +22,7 @@ type NodeConfig struct {
 | 
			
		|||
	SigningPublicKey            string                 `comment:"Your public signing key. You should not ordinarily need to share\nthis with anyone."`
 | 
			
		||||
	SigningPrivateKey           string                 `comment:"Your private signing key. DO NOT share this with anyone!"`
 | 
			
		||||
	MulticastInterfaces         []string               `comment:"Regular expressions for which interfaces multicast peer discovery\nshould be enabled on. If none specified, multicast peer discovery is\ndisabled. The default value is .* which uses all interfaces."`
 | 
			
		||||
	LinkLocalTCPPort            uint16                 `comment:"The port number to be used for the link-local TCP listeners for the\nconfigured MulticastInterfaces. This option does not affect listeners\nspecified in the Listen option. Unless you plan to firewall link-local\ntraffic, it is best to leave this as the default value of 0."`
 | 
			
		||||
	IfName                      string                 `comment:"Local network interface name for TUN/TAP adapter, or \"auto\" to select\nan interface automatically, or \"none\" to run without TUN/TAP."`
 | 
			
		||||
	IfTAPMode                   bool                   `comment:"Set local network interface to TAP mode rather than TUN mode if\nsupported by your platform - option will be ignored if not."`
 | 
			
		||||
	IfMTU                       int                    `comment:"Maximux Transmission Unit (MTU) size for your local TUN/TAP interface.\nDefault is the largest supported size for your platform. The lowest\npossible value is 1280."`
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,12 +16,16 @@ type multicast struct {
 | 
			
		|||
	sock        *ipv6.PacketConn
 | 
			
		||||
	groupAddr   string
 | 
			
		||||
	listeners   map[string]*tcpListener
 | 
			
		||||
	listenPort  uint16
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (m *multicast) init(core *Core) {
 | 
			
		||||
	m.core = core
 | 
			
		||||
	m.reconfigure = make(chan chan error, 1)
 | 
			
		||||
	m.listeners = make(map[string]*tcpListener)
 | 
			
		||||
	m.core.configMutex.RLock()
 | 
			
		||||
	m.listenPort = m.core.config.LinkLocalTCPPort
 | 
			
		||||
	m.core.configMutex.RUnlock()
 | 
			
		||||
	go func() {
 | 
			
		||||
		for {
 | 
			
		||||
			e := <-m.reconfigure
 | 
			
		||||
| 
						 | 
				
			
			@ -148,12 +152,14 @@ func (m *multicast) announce() {
 | 
			
		|||
				var listener *tcpListener
 | 
			
		||||
				if l, ok := m.listeners[iface.Name]; !ok || l.listener == nil {
 | 
			
		||||
					// No listener was found - let's create one
 | 
			
		||||
					listenaddr := fmt.Sprintf("[%s%%%s]:0", addrIP, iface.Name)
 | 
			
		||||
					listenaddr := fmt.Sprintf("[%s%%%s]:%d", addrIP, iface.Name, m.listenPort)
 | 
			
		||||
					if li, err := m.core.link.tcp.listen(listenaddr); err == nil {
 | 
			
		||||
						m.core.log.Debugln("Started multicasting on", iface.Name)
 | 
			
		||||
						// Store the listener so that we can stop it later if needed
 | 
			
		||||
						m.listeners[iface.Name] = li
 | 
			
		||||
						listener = li
 | 
			
		||||
					} else {
 | 
			
		||||
						m.core.log.Warnln("Not multicasting on", iface.Name, "due to error:", err)
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					// An existing listener was found
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue