mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25: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) {
|
||||
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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue