Skip to content

Commit

Permalink
net: Decrease nMaxIPs when learning from DNS seeds
Browse files Browse the repository at this point in the history
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 bitcoin#16070.
  • Loading branch information
laanwj committed Apr 11, 2024
1 parent e319569 commit f2e3662
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,11 @@ void CConnman::ThreadDNSAddressSeed()
if (!resolveSource.SetInternal(host)) {
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)};
if (!addresses.empty()) {
for (const CNetAddr& ip : addresses) {
Expand Down

0 comments on commit f2e3662

Please sign in to comment.