mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Fall back to oneshot for DNS Seeds which don't support filtering.
This allows us to not have to update the chainparams whenever a
DNS Seed changes its filtering support, as well fixes a bug
introduced in 44407100f
where returned nodes will never be
attempted.
This commit is contained in:
parent
51ae7660b8
commit
62e764219b
@ -125,12 +125,12 @@ public:
|
||||
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
|
||||
|
||||
// Note that of those with the service bits flag, most only support a subset of possible options
|
||||
vSeeds.emplace_back("seed.bitcoin.sipa.be", true); // Pieter Wuille, only supports x1, x5, x9, and xd
|
||||
vSeeds.emplace_back("dnsseed.bluematt.me", true); // Matt Corallo, only supports x9
|
||||
vSeeds.emplace_back("dnsseed.bitcoin.dashjr.org", false); // Luke Dashjr
|
||||
vSeeds.emplace_back("seed.bitcoinstats.com", true); // Christian Decker, supports x1 - xf
|
||||
vSeeds.emplace_back("seed.bitcoin.jonasschnelli.ch", true); // Jonas Schnelli, only supports x1, x5, x9, and xd
|
||||
vSeeds.emplace_back("seed.btc.petertodd.org", true); // Peter Todd, only supports x1, x5, x9, and xd
|
||||
vSeeds.emplace_back("seed.bitcoin.sipa.be"); // Pieter Wuille, only supports x1, x5, x9, and xd
|
||||
vSeeds.emplace_back("dnsseed.bluematt.me"); // Matt Corallo, only supports x9
|
||||
vSeeds.emplace_back("dnsseed.bitcoin.dashjr.org"); // Luke Dashjr
|
||||
vSeeds.emplace_back("seed.bitcoinstats.com"); // Christian Decker, supports x1 - xf
|
||||
vSeeds.emplace_back("seed.bitcoin.jonasschnelli.ch"); // Jonas Schnelli, only supports x1, x5, x9, and xd
|
||||
vSeeds.emplace_back("seed.btc.petertodd.org"); // Peter Todd, only supports x1, x5, x9, and xd
|
||||
|
||||
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
|
||||
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
|
||||
@ -229,10 +229,10 @@ public:
|
||||
vFixedSeeds.clear();
|
||||
vSeeds.clear();
|
||||
// nodes with support for servicebits filtering should be at the top
|
||||
vSeeds.emplace_back("testnet-seed.bitcoin.jonasschnelli.ch", true);
|
||||
vSeeds.emplace_back("seed.tbtc.petertodd.org", true);
|
||||
vSeeds.emplace_back("seed.testnet.bitcoin.sprovoost.nl", true);
|
||||
vSeeds.emplace_back("testnet-seed.bluematt.me", true); // Just a static list of stable node(s), only supports x9
|
||||
vSeeds.emplace_back("testnet-seed.bitcoin.jonasschnelli.ch");
|
||||
vSeeds.emplace_back("seed.tbtc.petertodd.org");
|
||||
vSeeds.emplace_back("seed.testnet.bitcoin.sprovoost.nl");
|
||||
vSeeds.emplace_back("testnet-seed.bluematt.me"); // Just a static list of stable node(s), only supports x9
|
||||
|
||||
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
|
||||
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
|
||||
|
@ -14,12 +14,6 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
struct CDNSSeedData {
|
||||
std::string host;
|
||||
bool supportsServiceBitsFiltering;
|
||||
CDNSSeedData(const std::string &strHost, bool supportsServiceBitsFilteringIn) : host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
|
||||
};
|
||||
|
||||
struct SeedSpec6 {
|
||||
uint8_t addr[16];
|
||||
uint16_t port;
|
||||
@ -71,7 +65,8 @@ public:
|
||||
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
|
||||
/** Return the BIP70 network string (main, test or regtest) */
|
||||
std::string NetworkIDString() const { return strNetworkID; }
|
||||
const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
|
||||
/** Return the list of hostnames to look up for DNS seeds */
|
||||
const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
|
||||
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
|
||||
const std::string& Bech32HRP() const { return bech32_hrp; }
|
||||
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
|
||||
@ -85,7 +80,7 @@ protected:
|
||||
CMessageHeader::MessageStartChars pchMessageStart;
|
||||
int nDefaultPort;
|
||||
uint64_t nPruneAfterHeight;
|
||||
std::vector<CDNSSeedData> vSeeds;
|
||||
std::vector<std::string> vSeeds;
|
||||
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
||||
std::string bech32_hrp;
|
||||
std::string strNetworkID;
|
||||
|
25
src/net.cpp
25
src/net.cpp
@ -1577,19 +1577,6 @@ void MapPort(bool)
|
||||
|
||||
|
||||
|
||||
static std::string GetDNSHost(const CDNSSeedData& data, ServiceFlags* requiredServiceBits)
|
||||
{
|
||||
//use default host for non-filter-capable seeds or if we use the default service bits (NODE_NETWORK)
|
||||
if (!data.supportsServiceBitsFiltering || *requiredServiceBits == NODE_NETWORK) {
|
||||
*requiredServiceBits = NODE_NETWORK;
|
||||
return data.host;
|
||||
}
|
||||
|
||||
// See chainparams.cpp, most dnsseeds only support one or two possible servicebits hostnames
|
||||
return strprintf("x%x.%s", *requiredServiceBits, data.host);
|
||||
}
|
||||
|
||||
|
||||
void CConnman::ThreadDNSAddressSeed()
|
||||
{
|
||||
// goal: only query DNS seeds if address need is acute
|
||||
@ -1612,22 +1599,22 @@ void CConnman::ThreadDNSAddressSeed()
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<CDNSSeedData> &vSeeds = Params().DNSSeeds();
|
||||
const std::vector<std::string> &vSeeds = Params().DNSSeeds();
|
||||
int found = 0;
|
||||
|
||||
LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
|
||||
|
||||
for (const CDNSSeedData &seed : vSeeds) {
|
||||
for (const std::string &seed : vSeeds) {
|
||||
if (interruptNet) {
|
||||
return;
|
||||
}
|
||||
if (HaveNameProxy()) {
|
||||
AddOneShot(seed.host);
|
||||
AddOneShot(seed);
|
||||
} else {
|
||||
std::vector<CNetAddr> vIPs;
|
||||
std::vector<CAddress> vAdd;
|
||||
ServiceFlags requiredServiceBits = GetDesirableServiceFlags(NODE_NONE);
|
||||
std::string host = GetDNSHost(seed, &requiredServiceBits);
|
||||
std::string host = strprintf("x%x.%s", requiredServiceBits, seed);
|
||||
CNetAddr resolveSource;
|
||||
if (!resolveSource.SetInternal(host)) {
|
||||
continue;
|
||||
@ -1643,6 +1630,10 @@ void CConnman::ThreadDNSAddressSeed()
|
||||
found++;
|
||||
}
|
||||
addrman.Add(vAdd, resolveSource);
|
||||
} else {
|
||||
// We now avoid directly using results from DNS Seeds which do not support service bit filtering,
|
||||
// instead using them as a oneshot to get nodes with our desired service bits.
|
||||
AddOneShot(seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user