mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Fix enabling/disabling multicast
This commit is contained in:
		
							parent
							
								
									b252854d21
								
							
						
					
					
						commit
						b5057d60ad
					
				
					 2 changed files with 7 additions and 1 deletions
				
			
		| 
						 | 
					@ -16,6 +16,10 @@ type multicast struct {
 | 
				
			||||||
func (m *multicast) init(core *Core) {
 | 
					func (m *multicast) init(core *Core) {
 | 
				
			||||||
	m.core = core
 | 
						m.core = core
 | 
				
			||||||
	m.groupAddr = "[ff02::114]:9001"
 | 
						m.groupAddr = "[ff02::114]:9001"
 | 
				
			||||||
 | 
					  // Check if we've been given any expressions
 | 
				
			||||||
 | 
					  if len(m.core.ifceExpr) == 0 {
 | 
				
			||||||
 | 
					    return
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
	// Ask the system for network interfaces
 | 
						// Ask the system for network interfaces
 | 
				
			||||||
	allifaces, err := net.Interfaces()
 | 
						allifaces, err := net.Interfaces()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,9 +48,11 @@ func generateConfig(isAutoconf bool) *nodeConfig {
 | 
				
			||||||
	cfg := nodeConfig{}
 | 
						cfg := nodeConfig{}
 | 
				
			||||||
	if isAutoconf {
 | 
						if isAutoconf {
 | 
				
			||||||
		cfg.Listen = "[::]:0"
 | 
							cfg.Listen = "[::]:0"
 | 
				
			||||||
 | 
							cfg.MulticastInterfaces = []string{".*"}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		r1 := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
							r1 := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
				
			||||||
		cfg.Listen = fmt.Sprintf("[::]:%d", r1.Intn(65534-32768)+32768)
 | 
							cfg.Listen = fmt.Sprintf("[::]:%d", r1.Intn(65534-32768)+32768)
 | 
				
			||||||
 | 
							cfg.MulticastInterfaces = []string{}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	cfg.AdminListen = "[::1]:9001"
 | 
						cfg.AdminListen = "[::1]:9001"
 | 
				
			||||||
	cfg.EncryptionPublicKey = hex.EncodeToString(bpub[:])
 | 
						cfg.EncryptionPublicKey = hex.EncodeToString(bpub[:])
 | 
				
			||||||
| 
						 | 
					@ -59,7 +61,6 @@ func generateConfig(isAutoconf bool) *nodeConfig {
 | 
				
			||||||
	cfg.SigningPrivateKey = hex.EncodeToString(spriv[:])
 | 
						cfg.SigningPrivateKey = hex.EncodeToString(spriv[:])
 | 
				
			||||||
	cfg.Peers = []string{}
 | 
						cfg.Peers = []string{}
 | 
				
			||||||
	cfg.AllowedEncryptionPublicKeys = []string{}
 | 
						cfg.AllowedEncryptionPublicKeys = []string{}
 | 
				
			||||||
	cfg.MulticastInterfaces = []string{".*"}
 | 
					 | 
				
			||||||
	cfg.IfName = core.GetTUNDefaultIfName()
 | 
						cfg.IfName = core.GetTUNDefaultIfName()
 | 
				
			||||||
	cfg.IfMTU = core.GetTUNDefaultIfMTU()
 | 
						cfg.IfMTU = core.GetTUNDefaultIfMTU()
 | 
				
			||||||
	cfg.IfTAPMode = core.GetTUNDefaultIfTAPMode()
 | 
						cfg.IfTAPMode = core.GetTUNDefaultIfTAPMode()
 | 
				
			||||||
| 
						 | 
					@ -71,6 +72,7 @@ func generateConfig(isAutoconf bool) *nodeConfig {
 | 
				
			||||||
// with -genconf.
 | 
					// with -genconf.
 | 
				
			||||||
func doGenconf() string {
 | 
					func doGenconf() string {
 | 
				
			||||||
	cfg := generateConfig(false)
 | 
						cfg := generateConfig(false)
 | 
				
			||||||
 | 
						cfg.MulticastInterfaces = append(cfg.MulticastInterfaces, ".*")
 | 
				
			||||||
	bs, err := hjson.Marshal(cfg)
 | 
						bs, err := hjson.Marshal(cfg)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		panic(err)
 | 
							panic(err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue