mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
net: switch to dummy internal ip for dns seed source
This addresss the TODO to avoid resolving twice.
This commit is contained in:
20
src/net.cpp
20
src/net.cpp
@@ -1604,7 +1604,12 @@ void CConnman::ThreadDNSAddressSeed()
|
||||
std::vector<CNetAddr> vIPs;
|
||||
std::vector<CAddress> vAdd;
|
||||
ServiceFlags requiredServiceBits = nRelevantServices;
|
||||
if (LookupHost(GetDNSHost(seed, &requiredServiceBits).c_str(), vIPs, 0, true))
|
||||
std::string host = GetDNSHost(seed, &requiredServiceBits);
|
||||
CNetAddr resolveSource;
|
||||
if (!resolveSource.SetInternal(host)) {
|
||||
continue;
|
||||
}
|
||||
if (LookupHost(host.c_str(), vIPs, 0, true))
|
||||
{
|
||||
BOOST_FOREACH(const CNetAddr& ip, vIPs)
|
||||
{
|
||||
@@ -1614,18 +1619,7 @@ void CConnman::ThreadDNSAddressSeed()
|
||||
vAdd.push_back(addr);
|
||||
found++;
|
||||
}
|
||||
}
|
||||
if (interruptNet) {
|
||||
return;
|
||||
}
|
||||
// TODO: The seed name resolve may fail, yielding an IP of [::], which results in
|
||||
// addrman assigning the same source to results from different seeds.
|
||||
// This should switch to a hard-coded stable dummy IP for each seed name, so that the
|
||||
// resolve is not required at all.
|
||||
if (!vIPs.empty()) {
|
||||
CService seedSource;
|
||||
Lookup(seed.name.c_str(), seedSource, 0, true);
|
||||
addrman.Add(vAdd, seedSource);
|
||||
addrman.Add(vAdd, resolveSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user