From cfdbc481a5502c9cbc5aa23b6a8e5c1b77f50dd2 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 5 Nov 2018 23:22:45 +0000 Subject: [PATCH] Modify source address check for CKR --- src/yggdrasil/ckr.go | 2 +- src/yggdrasil/router.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/yggdrasil/ckr.go b/src/yggdrasil/ckr.go index 0e195fd3..2b6c0d1f 100644 --- a/src/yggdrasil/ckr.go +++ b/src/yggdrasil/ckr.go @@ -99,7 +99,7 @@ func (c *cryptokey) getPublicKeyForAddress(addr address) (boxPubKey, error) { // Check if the address is a valid Yggdrasil address - if so it // is exempt from all CKR checking 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 diff --git a/src/yggdrasil/router.go b/src/yggdrasil/router.go index e369d836..dcce7271 100644 --- a/src/yggdrasil/router.go +++ b/src/yggdrasil/router.go @@ -124,14 +124,11 @@ func (r *router) sendPacket(bs []byte) { } var sourceAddr address var sourceSubnet subnet + var dest address + var snet subnet copy(sourceAddr[:], bs[8:]) copy(sourceSubnet[:], bs[8:]) - if !sourceAddr.isValid() && !sourceSubnet.isValid() { - return - } - var dest address copy(dest[:], bs[24:]) - var snet subnet copy(snet[:], bs[24:]) if !dest.isValid() && !snet.isValid() { if key, err := r.cryptokey.getPublicKeyForAddress(dest); err == nil { @@ -144,6 +141,10 @@ func (r *router) sendPacket(bs []byte) { } else { return } + } else { + if !sourceAddr.isValid() && !sourceSubnet.isValid() { + return + } } doSearch := func(packet []byte) { var nodeID, mask *NodeID