|
|
@ -141,8 +141,8 @@ bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
|
|
|
|
return nBestScore >= 0;
|
|
|
|
return nBestScore >= 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! Convert the pnSeed6 array into usable address objects.
|
|
|
|
//! Convert the serialized seeds into usable address objects.
|
|
|
|
static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn)
|
|
|
|
static std::vector<CAddress> ConvertSeeds(const std::vector<uint8_t> &vSeedsIn)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// It'll only connect to one or two seed nodes because once it connects,
|
|
|
|
// It'll only connect to one or two seed nodes because once it connects,
|
|
|
|
// it'll get a pile of addresses with newer timestamps.
|
|
|
|
// it'll get a pile of addresses with newer timestamps.
|
|
|
@ -150,13 +150,14 @@ static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn
|
|
|
|
// weeks ago.
|
|
|
|
// weeks ago.
|
|
|
|
const int64_t nOneWeek = 7*24*60*60;
|
|
|
|
const int64_t nOneWeek = 7*24*60*60;
|
|
|
|
std::vector<CAddress> vSeedsOut;
|
|
|
|
std::vector<CAddress> vSeedsOut;
|
|
|
|
vSeedsOut.reserve(vSeedsIn.size());
|
|
|
|
|
|
|
|
FastRandomContext rng;
|
|
|
|
FastRandomContext rng;
|
|
|
|
for (const auto& seed_in : vSeedsIn) {
|
|
|
|
CDataStream s(vSeedsIn, SER_NETWORK, PROTOCOL_VERSION | ADDRV2_FORMAT);
|
|
|
|
struct in6_addr ip;
|
|
|
|
while (!s.eof()) {
|
|
|
|
memcpy(&ip, seed_in.addr, sizeof(ip));
|
|
|
|
CService endpoint;
|
|
|
|
CAddress addr(CService(ip, seed_in.port), GetDesirableServiceFlags(NODE_NONE));
|
|
|
|
s >> endpoint;
|
|
|
|
|
|
|
|
CAddress addr{endpoint, GetDesirableServiceFlags(NODE_NONE)};
|
|
|
|
addr.nTime = GetTime() - rng.randrange(nOneWeek) - nOneWeek;
|
|
|
|
addr.nTime = GetTime() - rng.randrange(nOneWeek) - nOneWeek;
|
|
|
|
|
|
|
|
LogPrint(BCLog::NET, "Added hardcoded seed: %s\n", addr.ToString());
|
|
|
|
vSeedsOut.push_back(addr);
|
|
|
|
vSeedsOut.push_back(addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return vSeedsOut;
|
|
|
|
return vSeedsOut;
|
|
|
@ -1840,7 +1841,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
|
|
|
if (add_fixed_seeds_now) {
|
|
|
|
if (add_fixed_seeds_now) {
|
|
|
|
CNetAddr local;
|
|
|
|
CNetAddr local;
|
|
|
|
local.SetInternal("fixedseeds");
|
|
|
|
local.SetInternal("fixedseeds");
|
|
|
|
addrman.Add(convertSeed6(Params().FixedSeeds()), local);
|
|
|
|
addrman.Add(ConvertSeeds(Params().FixedSeeds()), local);
|
|
|
|
add_fixed_seeds = false;
|
|
|
|
add_fixed_seeds = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|