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