mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-02 20:57:38 +03:00
Add a bit of jitter to the TTL of xtransport cached IP addresses
This commit is contained in:
parent
5d2519e2c1
commit
c030e346b5
1 changed files with 2 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue