Skip to content

Commit c030e34

Browse files
committed
Add a bit of jitter to the TTL of xtransport cached IP addresses
1 parent 5d2519e commit c030e34

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: dnscrypt-proxy/xtransport.go

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const (
3636
DefaultTimeout = 30 * time.Second
3737
SystemResolverIPTTL = 12 * time.Hour
3838
MinResolverIPTTL = 4 * time.Hour
39+
ResolverIPTTLMaxJitter = 15 * time.Minute
3940
ExpiredCachedIPGraceTTL = 15 * time.Minute
4041
)
4142

@@ -111,6 +112,7 @@ func (xTransport *XTransport) saveCachedIP(host string, ip net.IP, ttl time.Dura
111112
if ttl < MinResolverIPTTL {
112113
ttl = MinResolverIPTTL
113114
}
115+
ttl += time.Duration(rand.Int63n(int64(ResolverIPTTLMaxJitter)))
114116
expiration := time.Now().Add(ttl)
115117
item.expiration = &expiration
116118
}

0 commit comments

Comments
 (0)