mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-30 13:35:19 +00:00
Merge pull request #93 from neilalexander/bugfixes
Fix MulticastInterfaces and accidental truncation of addresses on macOS/BSD
This commit is contained in:
commit
71d3a2b187
@ -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 {
|
||||
|
@ -137,7 +137,7 @@ func (tun *tunDevice) setupAddress(addr string) error {
|
||||
copy(ar.ifr_name[:], tun.iface.Name())
|
||||
ar.ifru_addr.sin6_len = uint8(unsafe.Sizeof(ar.ifru_addr))
|
||||
ar.ifru_addr.sin6_family = unix.AF_INET6
|
||||
parts := strings.Split(strings.TrimRight(addr, "/8"), ":")
|
||||
parts := strings.Split(strings.Split(addr, "/")[0], ":")
|
||||
for i := 0; i < 8; i++ {
|
||||
addr, _ := strconv.ParseUint(parts[i], 16, 16)
|
||||
b := make([]byte, 16)
|
||||
|
@ -84,7 +84,7 @@ func (tun *tunDevice) setupAddress(addr string) error {
|
||||
|
||||
ar.ifra_addr.sin6_len = uint8(unsafe.Sizeof(ar.ifra_addr))
|
||||
ar.ifra_addr.sin6_family = unix.AF_INET6
|
||||
parts := strings.Split(strings.TrimRight(addr, "/8"), ":")
|
||||
parts := strings.Split(strings.Split(addr, "/")[0], ":")
|
||||
for i := 0; i < 8; i++ {
|
||||
addr, _ := strconv.ParseUint(parts[i], 16, 16)
|
||||
b := make([]byte, 16)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user