mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 20:00:27 +00:00
Fix Yggdrasil subnet routing
This commit is contained in:
parent
bc62af7f7d
commit
2f75075da3
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user