5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-14 04:30:32 +00:00

Modify source address check for CKR

This commit is contained in:
Neil Alexander 2018-11-05 23:22:45 +00:00
parent 7218b5a56c
commit cfdbc481a5
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
2 changed files with 7 additions and 6 deletions

View File

@ -99,7 +99,7 @@ func (c *cryptokey) getPublicKeyForAddress(addr address) (boxPubKey, error) {
// Check if the address is a valid Yggdrasil address - if so it // Check if the address is a valid Yggdrasil address - if so it
// is exempt from all CKR checking // is exempt from all CKR checking
if addr.isValid() { if addr.isValid() {
return return boxPubKey{}, errors.New("Cannot look up CKR for Yggdrasil addresses")
} }
// Check if there's a cache entry for this addr // Check if there's a cache entry for this addr

View File

@ -124,14 +124,11 @@ func (r *router) sendPacket(bs []byte) {
} }
var sourceAddr address var sourceAddr address
var sourceSubnet subnet var sourceSubnet subnet
var dest address
var snet subnet
copy(sourceAddr[:], bs[8:]) copy(sourceAddr[:], bs[8:])
copy(sourceSubnet[:], bs[8:]) copy(sourceSubnet[:], bs[8:])
if !sourceAddr.isValid() && !sourceSubnet.isValid() {
return
}
var dest address
copy(dest[:], bs[24:]) copy(dest[:], bs[24:])
var snet subnet
copy(snet[:], bs[24:]) copy(snet[:], bs[24:])
if !dest.isValid() && !snet.isValid() { if !dest.isValid() && !snet.isValid() {
if key, err := r.cryptokey.getPublicKeyForAddress(dest); err == nil { if key, err := r.cryptokey.getPublicKeyForAddress(dest); err == nil {
@ -144,6 +141,10 @@ func (r *router) sendPacket(bs []byte) {
} else { } else {
return return
} }
} else {
if !sourceAddr.isValid() && !sourceSubnet.isValid() {
return
}
} }
doSearch := func(packet []byte) { doSearch := func(packet []byte) {
var nodeID, mask *NodeID var nodeID, mask *NodeID