mirror of
https://github.com/matrix-construct/construct
synced 2024-10-01 05:08:59 +02:00
ircd::net::dns: Enforce min ttl for cache entries; add conf option.
This commit is contained in:
parent
3b7816763e
commit
f37176d698
2 changed files with 12 additions and 1 deletions
|
@ -89,6 +89,7 @@ struct ircd::net::dns::opts
|
|||
/// (internal) DNS cache
|
||||
struct ircd::net::dns::cache
|
||||
{
|
||||
static conf::item<seconds> min_ttl;
|
||||
static conf::item<seconds> clear_nxdomain;
|
||||
|
||||
std::multimap<std::string, rfc1035::record::A, std::less<>> A;
|
||||
|
|
12
ircd/net.cc
12
ircd/net.cc
|
@ -2308,6 +2308,13 @@ ircd::net::dns::cache::clear_nxdomain
|
|||
{ "default", 43200L },
|
||||
};
|
||||
|
||||
decltype(ircd::net::dns::cache::min_ttl)
|
||||
ircd::net::dns::cache::min_ttl
|
||||
{
|
||||
{ "name", "ircd.net.dns.cache.min_ttl" },
|
||||
{ "default", 900L },
|
||||
};
|
||||
|
||||
decltype(ircd::net::dns::prefetch_ipport)
|
||||
ircd::net::dns::prefetch_ipport{[]
|
||||
(std::exception_ptr, const auto &record)
|
||||
|
@ -3135,7 +3142,10 @@ try
|
|||
// indicating when they expire. This makes more sense for our caches.
|
||||
const auto &now{ircd::time()};
|
||||
for(size_t i(0); i < header.ancount; ++i)
|
||||
an[i].ttl = now + an[i].ttl;
|
||||
{
|
||||
const uint &min_ttl(seconds(cache.min_ttl).count());
|
||||
an[i].ttl = now + std::max(an[i].ttl, min_ttl);
|
||||
}
|
||||
}
|
||||
|
||||
// The callback to the user will be passed a vector_view of pointers
|
||||
|
|
Loading…
Reference in a new issue