5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-23 05:15:39 +00:00

Enforce CKR cache size more strongly

This commit is contained in:
Neil Alexander 2018-12-10 22:30:31 +00:00
parent 65e34bbbab
commit 90ace46587
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -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