net: Decrease nMaxIPs when learning from DNS seeds

Limit number of IPs learned from a single DNS seed to 32, to prevent the results from
one DNS seed from dominating AddrMan. Note that the number of results from a UDP DNS query is
bounded to 33 already, but it is possible for it to use TCP where a potentially enormous
number of results can be returned.

Closes #16070.

Github-Pull: #29850
Rebased-From: f2e3662e57
This commit is contained in:
laanwj 2024-04-11 14:38:32 +02:00 committed by Luke Dashjr
parent 96ec3b67a7
commit 7af5125276

View File

@ -2279,7 +2279,11 @@ void CConnman::ThreadDNSAddressSeed()
if (!resolveSource.SetInternal(host)) { if (!resolveSource.SetInternal(host)) {
continue; continue;
} }
unsigned int nMaxIPs = 256; // Limits number of IPs learned from a DNS seed // Limit number of IPs learned from a single DNS seed. This limit exists to prevent the results from
// one DNS seed from dominating AddrMan. Note that the number of results from a UDP DNS query is
// bounded to 33 already, but it is possible for it to use TCP where a larger number of results can be
// returned.
unsigned int nMaxIPs = 32;
const auto addresses{LookupHost(host, nMaxIPs, true)}; const auto addresses{LookupHost(host, nMaxIPs, true)};
if (!addresses.empty()) { if (!addresses.empty()) {
for (const CNetAddr& ip : addresses) { for (const CNetAddr& ip : addresses) {