mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2026-10-12 02:01:53 +00:00
Update the sievecache dependency
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
# Version 2.1.11
|
||||
- The sievecache dependency was updated to fix a bug causing the cache to crash.
|
||||
|
||||
# Version 2.1.10
|
||||
- Hot-reloading of configuration files is now optional and disabled by default.
|
||||
It can be enabled by setting `enable_hot_reload = true` in the configuration file.
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
AppVersion = "2.1.10"
|
||||
AppVersion = "2.1.11"
|
||||
DefaultConfigFileName = "dnscrypt-proxy.toml"
|
||||
)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ require (
|
||||
github.com/jedisct1/go-dnsstamps v0.0.0-20240423203910-07a0735c7774
|
||||
github.com/jedisct1/go-hpke-compact v0.0.0-20241212093903-5caa4621366f
|
||||
github.com/jedisct1/go-minisign v0.0.0-20241212093149-d2f9f49435c7
|
||||
github.com/jedisct1/go-sieve-cache v0.1.5
|
||||
github.com/jedisct1/go-sieve-cache v0.1.6
|
||||
github.com/jedisct1/xsecretbox v0.0.0-20241212092125-3afc4917ac41
|
||||
github.com/k-sone/critbitgo v1.4.0
|
||||
github.com/kardianos/service v1.2.2
|
||||
|
||||
@@ -51,8 +51,8 @@ github.com/jedisct1/go-hpke-compact v0.0.0-20241212093903-5caa4621366f h1:h5/HKr
|
||||
github.com/jedisct1/go-hpke-compact v0.0.0-20241212093903-5caa4621366f/go.mod h1:IjVYCPbDciyDZpJpUIYodX+FvctxGmnHVZ/ZwGBCjNA=
|
||||
github.com/jedisct1/go-minisign v0.0.0-20241212093149-d2f9f49435c7 h1:FWpSWRD8FbVkKQu8M1DM9jF5oXFLyE+XpisIYfdzbic=
|
||||
github.com/jedisct1/go-minisign v0.0.0-20241212093149-d2f9f49435c7/go.mod h1:BMxO138bOokdgt4UaxZiEfypcSHX0t6SIFimVP1oRfk=
|
||||
github.com/jedisct1/go-sieve-cache v0.1.5 h1:ZmkjZc7xvx5CHUw/ePJbRu61KZa6KRyzJlN45x5HBS8=
|
||||
github.com/jedisct1/go-sieve-cache v0.1.5/go.mod h1:EN88bnjKpiyS9TfZZNbUkCwgpWueZSaUi4vgVtw2988=
|
||||
github.com/jedisct1/go-sieve-cache v0.1.6 h1:cbAUZpdAX2iuX8+eb/nb4G/VlGyFXcKGLAbY9Zaz4XA=
|
||||
github.com/jedisct1/go-sieve-cache v0.1.6/go.mod h1:EN88bnjKpiyS9TfZZNbUkCwgpWueZSaUi4vgVtw2988=
|
||||
github.com/jedisct1/xsecretbox v0.0.0-20241212092125-3afc4917ac41 h1:TPF+VETyhqUOY51j3KF0uk5cgHQ2Bzi6XCorcGNGfTs=
|
||||
github.com/jedisct1/xsecretbox v0.0.0-20241212092125-3afc4917ac41/go.mod h1:eh2PYNEklsNDqUxnbnN9Duvpw1b+ZectZAtDUDRj2tA=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
|
||||
+11
-7
@@ -3,7 +3,7 @@ package sievecache
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash/fnv"
|
||||
"hash/maphash"
|
||||
)
|
||||
|
||||
// Default number of shards to use if not specified explicitly.
|
||||
@@ -90,13 +90,17 @@ func FromSync[K comparable, V any](syncCache *SyncSieveCache[K, V]) *ShardedSiev
|
||||
return shardedCache
|
||||
}
|
||||
|
||||
var hashSeed = maphash.MakeSeed()
|
||||
|
||||
// getShard returns the shard index for a given key.
|
||||
func (c *ShardedSieveCache[K, V]) getShardIndex(key K) int {
|
||||
h := fnv.New32a()
|
||||
var h maphash.Hash
|
||||
h.SetSeed(hashSeed)
|
||||
|
||||
// Use type switch to handle different key types efficiently
|
||||
switch k := any(key).(type) {
|
||||
case string:
|
||||
h.Write([]byte(k))
|
||||
h.WriteString(k)
|
||||
case []byte:
|
||||
h.Write(k)
|
||||
case int:
|
||||
@@ -119,9 +123,11 @@ func (c *ShardedSieveCache[K, V]) getShardIndex(key K) int {
|
||||
h.Write(buf[:])
|
||||
default:
|
||||
// For other types, convert to string
|
||||
h.Write([]byte(ToString(k)))
|
||||
h.WriteString(ToString(k))
|
||||
}
|
||||
return int(h.Sum32()) % c.numShards
|
||||
|
||||
hashValue := h.Sum64()
|
||||
return int(hashValue % uint64(c.numShards))
|
||||
}
|
||||
|
||||
// ToString converts a value to string for hashing.
|
||||
@@ -347,5 +353,3 @@ func (c *ShardedSieveCache[K, V]) RecommendedCapacity(minFactor, maxFactor, lowT
|
||||
|
||||
return max(c.numShards, totalRecommended)
|
||||
}
|
||||
|
||||
// Using fmt.Sprintf instead of a custom implementation for better reliability
|
||||
|
||||
Vendored
+1
-1
@@ -63,7 +63,7 @@ github.com/jedisct1/go-hpke-compact
|
||||
# github.com/jedisct1/go-minisign v0.0.0-20241212093149-d2f9f49435c7
|
||||
## explicit; go 1.23.4
|
||||
github.com/jedisct1/go-minisign
|
||||
# github.com/jedisct1/go-sieve-cache v0.1.5
|
||||
# github.com/jedisct1/go-sieve-cache v0.1.6
|
||||
## explicit; go 1.21
|
||||
github.com/jedisct1/go-sieve-cache/pkg/sievecache
|
||||
# github.com/jedisct1/xsecretbox v0.0.0-20241212092125-3afc4917ac41
|
||||
|
||||
Reference in New Issue
Block a user