Fix enabling/disabling multicast

This commit is contained in:
Neil Alexander 2018-05-24 15:05:12 +01:00
parent b252854d21
commit b5057d60ad
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 7 additions and 1 deletions

View file

@ -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 {

View file

@ -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)