mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #10446: net: avoid extra dns query per seed
c1be285chainparams: make supported service bits option explicit (Cory Fields)d5c7c1cnet: use an internal address for fixed seeds (Cory Fields)6cdc488net: switch to dummy internal ip for dns seed source (Cory Fields)6d0bd5bnet: do not allow resolving to an internal address (Cory Fields)7f31762net: add an internal subnet for representing unresolved hostnames (Cory Fields) Tree-SHA512: 9bf1042bef546ac3ef0e0d3a9a5555eb21628ff2674a0cf8c6367194b22bfdab477adf452c0e7c56f44e0fb37debc5e14bdb623452e076fb9c492c7702601d7a
This commit is contained in:
24
src/net.cpp
24
src/net.cpp
@@ -240,7 +240,7 @@ bool RemoveLocal(const CService& addr)
|
||||
/** Make a particular network entirely off-limits (no automatic connects to it) */
|
||||
void SetLimited(enum Network net, bool fLimited)
|
||||
{
|
||||
if (net == NET_UNROUTABLE)
|
||||
if (net == NET_UNROUTABLE || net == NET_INTERNAL)
|
||||
return;
|
||||
LOCK(cs_mapLocalHost);
|
||||
vfLimited[net] = fLimited;
|
||||
@@ -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))
|
||||
{
|
||||
for (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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1724,7 +1718,7 @@ void CConnman::ThreadOpenConnections()
|
||||
if (!done) {
|
||||
LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n");
|
||||
CNetAddr local;
|
||||
LookupHost("127.0.0.1", local, false);
|
||||
local.SetInternal("fixedseeds");
|
||||
addrman.Add(convertSeed6(Params().FixedSeeds()), local);
|
||||
done = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user