From 90ace46587f7f037df6f1698047886737cfd1e21 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 10 Dec 2018 22:30:31 +0000 Subject: [PATCH] Enforce CKR cache size more strongly --- src/yggdrasil/ckr.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/yggdrasil/ckr.go b/src/yggdrasil/ckr.go index 2324f612..d88b8d3c 100644 --- a/src/yggdrasil/ckr.go +++ b/src/yggdrasil/ckr.go @@ -244,11 +244,11 @@ func (c *cryptokey) getPublicKeyForAddress(addr address, addrlen int) (boxPubKey // Check if the routing cache is above a certain size, if it is evict // a random entry so we can make room for this one. We take advantage // of the fact that the iteration order is random here - if len(*routingcache) > 1024 { - for k := range *routingcache { - delete(*routingcache, k) + for k := range *routingcache { + if len(*routingcache) < 1024 { break } + delete(*routingcache, k) } // Cache the entry for future packets to get a faster lookup