mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 15:20:30 +00:00
Fix being able to enable/disable multicast
This commit is contained in:
parent
bc899c395a
commit
a0f547cc1b
@ -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 {
|
||||||
|
16
yggdrasil.go
16
yggdrasil.go
@ -91,9 +91,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[:])
|
||||||
@ -102,7 +104,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.DEBUG_GetTUNDefaultIfName()
|
cfg.IfName = core.DEBUG_GetTUNDefaultIfName()
|
||||||
cfg.IfMTU = core.DEBUG_GetTUNDefaultIfMTU()
|
cfg.IfMTU = core.DEBUG_GetTUNDefaultIfMTU()
|
||||||
cfg.IfTAPMode = core.DEBUG_GetTUNDefaultIfTAPMode()
|
cfg.IfTAPMode = core.DEBUG_GetTUNDefaultIfTAPMode()
|
||||||
@ -112,6 +113,7 @@ func generateConfig(isAutoconf bool) *nodeConfig {
|
|||||||
|
|
||||||
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)
|
||||||
@ -151,12 +153,12 @@ func main() {
|
|||||||
// For now we will do a little bit to help the user adjust their
|
// For now we will do a little bit to help the user adjust their
|
||||||
// configuration to match the new configuration format
|
// configuration to match the new configuration format
|
||||||
changes := map[string]string{
|
changes := map[string]string{
|
||||||
"Multicast": "",
|
"Multicast": "",
|
||||||
"LinkLocal": "MulticastInterfaces",
|
"LinkLocal": "MulticastInterfaces",
|
||||||
"BoxPub": "EncryptionPublicKey",
|
"BoxPub": "EncryptionPublicKey",
|
||||||
"BoxPriv": "EncryptionPrivateKey",
|
"BoxPriv": "EncryptionPrivateKey",
|
||||||
"SigPub": "SigningPublicKey",
|
"SigPub": "SigningPublicKey",
|
||||||
"SigPriv": "SigningPrivateKey",
|
"SigPriv": "SigningPrivateKey",
|
||||||
"AllowedBoxPubs": "AllowedEncryptionPublicKeys",
|
"AllowedBoxPubs": "AllowedEncryptionPublicKeys",
|
||||||
}
|
}
|
||||||
for from, to := range changes {
|
for from, to := range changes {
|
||||||
|
Loading…
Reference in New Issue
Block a user