mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-03-04 02:14:40 +01:00
Add a setMaxTTL() function
Will be useful to interprete HTTP cache headers in DoH
This commit is contained in:
parent
454e1bdfbc
commit
2eed62f1e2
1 changed files with 18 additions and 0 deletions
|
@ -73,3 +73,21 @@ func getMinTTL(msg *dns.Msg, minTTL uint32, maxTTL uint32, negCacheMinTTL uint32
|
|||
}
|
||||
return time.Duration(ttl) * time.Second
|
||||
}
|
||||
|
||||
func setMaxTTL(msg *dns.Msg, ttl uint32) {
|
||||
for _, rr := range msg.Answer {
|
||||
if ttl < rr.Header().Ttl {
|
||||
rr.Header().Ttl = ttl
|
||||
}
|
||||
}
|
||||
for _, rr := range msg.Ns {
|
||||
if ttl < rr.Header().Ttl {
|
||||
rr.Header().Ttl = ttl
|
||||
}
|
||||
}
|
||||
for _, rr := range msg.Extra {
|
||||
if ttl < rr.Header().Ttl {
|
||||
rr.Header().Ttl = ttl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue