Skip to content

Commit 36368c5

Browse files
theunifurszy
authored andcommitted
net: switch to dummy internal ip for dns seed source
This addresss the TODO to avoid resolving twice.
1 parent 8f31295 commit 36368c5

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

src/chainparams.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ class CMainParams : public CChainParams
227227
nDefaultPort = 51472;
228228

229229
// Note that of those with the service bits flag, most only support a subset of possible options
230-
vSeeds.emplace_back("fuzzbawls.pw", "pivx.seed.fuzzbawls.pw", true); // Primary DNS Seeder from Fuzzbawls
231-
vSeeds.emplace_back("fuzzbawls.pw", "pivx.seed2.fuzzbawls.pw", true); // Secondary DNS Seeder from Fuzzbawls
230+
vSeeds.emplace_back("pivx.seed.fuzzbawls.pw", true); // Primary DNS Seeder from Fuzzbawls
231+
vSeeds.emplace_back("pivx.seed2.fuzzbawls.pw", true); // Secondary DNS Seeder from Fuzzbawls
232232

233233
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 30);
234234
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 13);
@@ -351,8 +351,8 @@ class CTestNetParams : public CChainParams
351351
nDefaultPort = 51474;
352352

353353
// nodes with support for servicebits filtering should be at the top
354-
vSeeds.emplace_back("fuzzbawls.pw", "pivx-testnet.seed.fuzzbawls.pw", true);
355-
vSeeds.emplace_back("fuzzbawls.pw", "pivx-testnet.seed2.fuzzbawls.pw", true);
354+
vSeeds.emplace_back("pivx-testnet.seed.fuzzbawls.pw", true);
355+
vSeeds.emplace_back("pivx-testnet.seed2.fuzzbawls.pw", true);
356356

357357
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 139); // Testnet pivx addresses start with 'x' or 'y'
358358
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 19); // Testnet pivx script addresses start with '8' or '9'

src/chainparams.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#include <vector>
2020

2121
struct CDNSSeedData {
22-
std::string name, host;
22+
std::string host;
2323
bool supportsServiceBitsFiltering;
24-
CDNSSeedData(const std::string& strName, const std::string& strHost, bool supportsServiceBitsFilteringIn = false) : name(strName), host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
24+
CDNSSeedData(const std::string& strHost, bool supportsServiceBitsFilteringIn = false) : host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
2525
};
2626

2727
struct SeedSpec6 {

src/net.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,26 +1519,20 @@ void CConnman::ThreadDNSAddressSeed()
15191519
std::vector<CNetAddr> vIPs;
15201520
std::vector<CAddress> vAdd;
15211521
ServiceFlags requiredServiceBits = nRelevantServices;
1522-
if (LookupHost(GetDNSHost(seed, &requiredServiceBits).c_str(), vIPs, 0, true)) {
1522+
std::string host = GetDNSHost(seed, &requiredServiceBits);
1523+
CNetAddr resolveSource;
1524+
if (!resolveSource.SetInternal(host)) {
1525+
continue;
1526+
}
1527+
if (LookupHost(host.c_str(), vIPs, 0, true)) {
15231528
for (CNetAddr& ip : vIPs) {
1524-
int nOneDay = 24 * 3600;
1529+
int nOneDay = 24*3600;
15251530
CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()), requiredServiceBits);
15261531
addr.nTime = GetTime() - 3 * nOneDay - GetRand(4 * nOneDay); // use a random age between 3 and 7 days old
15271532
vAdd.push_back(addr);
15281533
found++;
15291534
}
1530-
}
1531-
if (interruptNet) {
1532-
return;
1533-
}
1534-
// TODO: The seed name resolve may fail, yielding an IP of [::], which results in
1535-
// addrman assigning the same source to results from different seeds.
1536-
// This should switch to a hard-coded stable dummy IP for each seed name, so that the
1537-
// resolve is not required at all.
1538-
if (!vIPs.empty()) {
1539-
CService seedSource;
1540-
Lookup(seed.name.c_str(), seedSource, 0, true);
1541-
addrman.Add(vAdd, seedSource);
1535+
addrman.Add(vAdd, resolveSource);
15421536
}
15431537
}
15441538
}

0 commit comments

Comments
 (0)