From c030e346b53a651f724d1fefd80be56b9af1b05a Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 26 Mar 2025 23:00:30 +0100 Subject: [PATCH] Add a bit of jitter to the TTL of xtransport cached IP addresses --- dnscrypt-proxy/xtransport.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dnscrypt-proxy/xtransport.go b/dnscrypt-proxy/xtransport.go index a362298b..ed504245 100644 --- a/dnscrypt-proxy/xtransport.go +++ b/dnscrypt-proxy/xtransport.go @@ -36,6 +36,7 @@ const ( DefaultTimeout = 30 * time.Second SystemResolverIPTTL = 12 * time.Hour MinResolverIPTTL = 4 * time.Hour + ResolverIPTTLMaxJitter = 15 * time.Minute ExpiredCachedIPGraceTTL = 15 * time.Minute ) @@ -111,6 +112,7 @@ func (xTransport *XTransport) saveCachedIP(host string, ip net.IP, ttl time.Dura if ttl < MinResolverIPTTL { ttl = MinResolverIPTTL } + ttl += time.Duration(rand.Int63n(int64(ResolverIPTTLMaxJitter))) expiration := time.Now().Add(ttl) item.expiration = &expiration }