Skip to content

Commit

Permalink
Do not set extra flags for unfiltered DNS seed results
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa authored and Fuzzbawls committed May 13, 2020
1 parent f295ee4 commit 9107379
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 1 addition & 9 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2009-2015 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2020 The PIVX developers
// Distributed under the MIT software license, see the accompanying
Expand All @@ -16,14 +16,6 @@

#include <assert.h>

std::string CDNSSeedData::getHost(uint64_t requiredServiceBits) const {
//use default host for non-filter-capable seeds or if we use the default service bits (NODE_NETWORK)
if (!supportsServiceBitsFiltering || requiredServiceBits == NODE_NETWORK)
return host;

return strprintf("x%x.%s", requiredServiceBits, host);
}

static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
CMutableTransaction txNew;
Expand Down
6 changes: 2 additions & 4 deletions src/chainparams.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2009-2015 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2020 The PIVX developers
// Distributed under the MIT software license, see the accompanying
Expand All @@ -19,11 +19,9 @@

typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];

class CDNSSeedData {
public:
struct CDNSSeedData {
std::string name, host;
bool supportsServiceBitsFiltering;
std::string getHost(uint64_t requiredServiceBits) const;
CDNSSeedData(const std::string& strName, const std::string& strHost, bool supportsServiceBitsFilteringIn = false) : name(strName), host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
};

Expand Down
12 changes: 11 additions & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,16 @@ void MapPort(bool)
}
#endif

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;
}

return strprintf("x%x.%s", *requiredServiceBits, data.host);
}

void ThreadDNSAddressSeed()
{
Expand Down Expand Up @@ -1302,7 +1312,7 @@ void ThreadDNSAddressSeed()
std::vector<CNetAddr> vIPs;
std::vector<CAddress> vAdd;
ServiceFlags requiredServiceBits = nRelevantServices;
if (LookupHost(seed.getHost(requiredServiceBits).c_str(), vIPs, 0, true)) {
if (LookupHost(GetDNSHost(seed, &requiredServiceBits).c_str(), vIPs, 0, true)) {
for (CNetAddr& ip : vIPs) {
int nOneDay = 24 * 3600;
CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()), requiredServiceBits);
Expand Down

0 comments on commit 9107379

Please sign in to comment.