From a0f547cc1b2cf682005f27a66de5b230873fe91d Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 26 May 2018 21:50:47 +0100 Subject: [PATCH] Fix being able to enable/disable multicast --- src/yggdrasil/multicast.go | 4 ++++ yggdrasil.go | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/yggdrasil/multicast.go b/src/yggdrasil/multicast.go index afcf8b7f..6f11cb6a 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 9f1aa2aa..f85fd3ca 100644 --- a/yggdrasil.go +++ b/yggdrasil.go @@ -91,9 +91,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[:]) @@ -102,7 +104,6 @@ func generateConfig(isAutoconf bool) *nodeConfig { cfg.SigningPrivateKey = hex.EncodeToString(spriv[:]) cfg.Peers = []string{} cfg.AllowedEncryptionPublicKeys = []string{} - cfg.MulticastInterfaces = []string{".*"} cfg.IfName = core.DEBUG_GetTUNDefaultIfName() cfg.IfMTU = core.DEBUG_GetTUNDefaultIfMTU() cfg.IfTAPMode = core.DEBUG_GetTUNDefaultIfTAPMode() @@ -112,6 +113,7 @@ func generateConfig(isAutoconf bool) *nodeConfig { func doGenconf() string { cfg := generateConfig(false) + cfg.MulticastInterfaces = append(cfg.MulticastInterfaces, ".*") bs, err := hjson.Marshal(cfg) if err != nil { panic(err) @@ -151,12 +153,12 @@ func main() { // For now we will do a little bit to help the user adjust their // configuration to match the new configuration format changes := map[string]string{ - "Multicast": "", - "LinkLocal": "MulticastInterfaces", - "BoxPub": "EncryptionPublicKey", - "BoxPriv": "EncryptionPrivateKey", - "SigPub": "SigningPublicKey", - "SigPriv": "SigningPrivateKey", + "Multicast": "", + "LinkLocal": "MulticastInterfaces", + "BoxPub": "EncryptionPublicKey", + "BoxPriv": "EncryptionPrivateKey", + "SigPub": "SigningPublicKey", + "SigPriv": "SigningPrivateKey", "AllowedBoxPubs": "AllowedEncryptionPublicKeys", } for from, to := range changes {