mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Merge #21560: net: Add Tor v3 hardcoded seeds
b2ee8b207dnet: Deserialize hardcoded seeds from BIP155 blob (W. J. van der Laan)9b29d5df7fcontrib: Add explicit port numbers for testnet seeds (W. J. van der Laan)2a257de113contrib: Add a few TorV3 seed nodes (W. J. van der Laan)06030f7a42contrib: generate-seeds.py generates output in BIP155 format (W. J. van der Laan) Pull request description: Closes #20239 and mitigates my node's problem in #21351. - Add a few hardcoded seeds for TorV3 - As the [bitcoin-seeder](https://github.com/sipa/bitcoin-seeder) doesn't collect TorV3 addresses yet, I have extracted these from my own node using [a script](https://gist.github.com/laanwj/b3d7b01ef61ce07c2eff0a72a6b90183) and added them manually. This is intended to be a temporary stop gap until 22.0's seeds update. - Change hardcoded seeds to variable length BIP155 binary format. - It is stored as a single serialized blob in a byte array, instead of pseudo-IPv6 address slots. This is more flexible and, assuming most of the list is IPv4, more compact. - Only the (networkID, addr, port) subset (CService). Services and time are construed on the fly as before. - Change input format for `nodes_*.txt`. - Drop legacy `0xAABBCCDD` format for IPv4. It is never generated by `makeseeds.py`. - Stop interpreting lack of port as default port, interpret it as 'no port', to accomodate I2P and other port-less protocols (not handled in this PR). An explicit port is always generated by `makeseeds.py` so in practice this makes no difference right now. A follow-up to this PR could do the same for I2P. ACKs for top commit: jonatack: ACKb2ee8b207dTree-SHA512: 11a6b54f9fb0192560f2bd7b218f798f86c1abe01d1bf37f734cb88b91848124beb2de801ca4e6f856e9946aea5dc3ee16b0dbb9863799e42eec1b239d40d59d
This commit is contained in:
17
src/net.cpp
17
src/net.cpp
@@ -145,8 +145,8 @@ bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
|
||||
return nBestScore >= 0;
|
||||
}
|
||||
|
||||
//! Convert the pnSeed6 array into usable address objects.
|
||||
static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn)
|
||||
//! Convert the serialized seeds into usable address objects.
|
||||
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 get a pile of addresses with newer timestamps.
|
||||
@@ -154,13 +154,14 @@ static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn
|
||||
// weeks ago.
|
||||
const int64_t nOneWeek = 7*24*60*60;
|
||||
std::vector<CAddress> vSeedsOut;
|
||||
vSeedsOut.reserve(vSeedsIn.size());
|
||||
FastRandomContext rng;
|
||||
for (const auto& seed_in : vSeedsIn) {
|
||||
struct in6_addr ip;
|
||||
memcpy(&ip, seed_in.addr, sizeof(ip));
|
||||
CAddress addr(CService(ip, seed_in.port), GetDesirableServiceFlags(NODE_NONE));
|
||||
CDataStream s(vSeedsIn, SER_NETWORK, PROTOCOL_VERSION | ADDRV2_FORMAT);
|
||||
while (!s.eof()) {
|
||||
CService endpoint;
|
||||
s >> endpoint;
|
||||
CAddress addr{endpoint, GetDesirableServiceFlags(NODE_NONE)};
|
||||
addr.nTime = GetTime() - rng.randrange(nOneWeek) - nOneWeek;
|
||||
LogPrint(BCLog::NET, "Added hardcoded seed: %s\n", addr.ToString());
|
||||
vSeedsOut.push_back(addr);
|
||||
}
|
||||
return vSeedsOut;
|
||||
@@ -1847,7 +1848,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
||||
if (add_fixed_seeds_now) {
|
||||
CNetAddr local;
|
||||
local.SetInternal("fixedseeds");
|
||||
addrman.Add(convertSeed6(Params().FixedSeeds()), local);
|
||||
addrman.Add(ConvertSeeds(Params().FixedSeeds()), local);
|
||||
add_fixed_seeds = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user