From b5057d60adcbd438b5db80cde812e2c419e22140 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 24 May 2018 15:05:12 +0100 Subject: [PATCH] Fix enabling/disabling multicast --- src/yggdrasil/multicast.go | 4 ++++ yggdrasil.go | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/yggdrasil/multicast.go b/src/yggdrasil/multicast.go index d20a0b82..f3355916 100644 --- a/src/yggdrasil/multicast.go +++ b/src/yggdrasil/multicast.go @@ -16,6 +16,10 @@ type multicast struct { func (m *multicast) init(core *Core) { m.core = core 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 allifaces, err := net.Interfaces() if err != nil { diff --git a/yggdrasil.go b/yggdrasil.go index 385878a5..4f98b6a8 100644 --- a/yggdrasil.go +++ b/yggdrasil.go @@ -48,9 +48,11 @@ func generateConfig(isAutoconf bool) *nodeConfig { cfg := nodeConfig{} if isAutoconf { cfg.Listen = "[::]:0" + cfg.MulticastInterfaces = []string{".*"} } else { r1 := rand.New(rand.NewSource(time.Now().UnixNano())) cfg.Listen = fmt.Sprintf("[::]:%d", r1.Intn(65534-32768)+32768) + cfg.MulticastInterfaces = []string{} } cfg.AdminListen = "[::1]:9001" cfg.EncryptionPublicKey = hex.EncodeToString(bpub[:]) @@ -59,7 +61,6 @@ func generateConfig(isAutoconf bool) *nodeConfig { cfg.SigningPrivateKey = hex.EncodeToString(spriv[:]) cfg.Peers = []string{} cfg.AllowedEncryptionPublicKeys = []string{} - cfg.MulticastInterfaces = []string{".*"} cfg.IfName = core.GetTUNDefaultIfName() cfg.IfMTU = core.GetTUNDefaultIfMTU() cfg.IfTAPMode = core.GetTUNDefaultIfTAPMode() @@ -71,6 +72,7 @@ func generateConfig(isAutoconf bool) *nodeConfig { // with -genconf. func doGenconf() string { cfg := generateConfig(false) + cfg.MulticastInterfaces = append(cfg.MulticastInterfaces, ".*") bs, err := hjson.Marshal(cfg) if err != nil { panic(err)