From b53b85409f21af756105b6cbbaf7f81f30527059 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 22 Apr 2024 12:09:17 -0400 Subject: [PATCH] Merge bitcoin/bitcoin#29850: net: Decrease nMaxIPs when learning from DNS seeds f2e3662e57eca1330962faf38ff428a564d50a11 net: Decrease nMaxIPs when learning from DNS seeds (laanwj) Pull request description: 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 larger number of results can be returned. Closes #16070. ACKs for top commit: Sjors: utACK f2e3662e57eca1330962faf38ff428a564d50a11 achow101: ACK f2e3662e57eca1330962faf38ff428a564d50a11 1440000bytes: utACK https://github.com/bitcoin/bitcoin/pull/29850/commits/f2e3662e57eca1330962faf38ff428a564d50a11 mzumsande: utACK f2e3662e57eca1330962faf38ff428a564d50a11 Tree-SHA512: 3f108c2baba7adfedb8019daaf60aa00e628b38d3942e1319c7183a4683670be01929ced9e6372c8e983c902e8633f81fbef12d7cdcaadd7f77ed729c1019942 --- src/net.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 351c114d60..be0656f227 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -3062,7 +3062,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) {