5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-23 12:15:39 +00:00

Fix Yggdrasil subnet routing

This commit is contained in:
Neil Alexander 2018-11-06 14:28:57 +00:00
parent bc62af7f7d
commit 2f75075da3
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -1,6 +1,7 @@
package yggdrasil
import (
"bytes"
"encoding/hex"
"errors"
"fmt"
@ -49,15 +50,12 @@ func (c *cryptokey) isValidSource(addr address) bool {
ip := net.IP(addr[:])
// Does this match our node's address?
if addr == c.core.router.addr {
if bytes.Equal(addr[:16], c.core.router.addr[:16]) {
return true
}
// Does this match our node's subnet?
var subnet net.IPNet
copy(subnet.IP, c.core.router.subnet[:])
copy(subnet.Mask, net.CIDRMask(64, 128))
if subnet.Contains(ip) {
if bytes.Equal(addr[:8], c.core.router.subnet[:8]) {
return true
}