mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Merge #19954: Complete the BIP155 implementation and upgrade to TORv3
dcf0cb4776tor: make a TORv3 hidden service instead of TORv2 (Vasil Dimov)353a3fdaadnet: advertise support for ADDRv2 via new message (Vasil Dimov)201a4596d9net: CAddress & CAddrMan: (un)serialize as ADDRv2 (Vasil Dimov)1d3ec2a1fdSupport bypassing range check in ReadCompactSize (Pieter Wuille) Pull request description: This PR contains the two remaining commits from #19031 to complete the [BIP155](https://github.com/bitcoin/bips/blob/master/bip-0155.mediawiki) implementation: `net: CAddress & CAddrMan: (un)serialize as ADDRv2` `net: advertise support for ADDRv2 via new message` plus one more commit: `tor: make a TORv3 hidden service instead of TORv2` ACKs for top commit: jonatack: re-ACKdcf0cb4776per `git diff 9b56a68 dcf0cb4` only change since last review is an update to the release notes which partially picked up the suggested text. Running a node on this branch and addnode-ing to 6 other Tor v3 nodes, I see "addrv2" and "sendaddrv2" messages in getpeerinfo in both the "bytesrecv_per_msg" and "bytessent_per_msg" JSON objects. sipa: ACKdcf0cb4776hebasto: re-ACKdcf0cb4776, the node works flawlessly in all of the modes: Tor-only, clearnet-only, mixed. laanwj: Edit: I have to retract this ACK for now, I'm having some problems with this PR on a FreeBSD node. It drops all outgoing connections with thisdcf0cb4776merged on master (12a1c3ad1a). ariard: Code Review ACKdcf0cb4Tree-SHA512: 28d4d0d817b8664d2f4b18c0e0f31579b2f0f2d23310ed213f1f436a4242afea14dfbf99e07e15889bc5c5c71ad50056797e9307ff8a90e96704f588a6171308
This commit is contained in:
@@ -474,6 +474,26 @@ bool CNetAddr::IsInternal() const
|
||||
return m_net == NET_INTERNAL;
|
||||
}
|
||||
|
||||
bool CNetAddr::IsAddrV1Compatible() const
|
||||
{
|
||||
switch (m_net) {
|
||||
case NET_IPV4:
|
||||
case NET_IPV6:
|
||||
case NET_INTERNAL:
|
||||
return true;
|
||||
case NET_ONION:
|
||||
return m_addr.size() == ADDR_TORV2_SIZE;
|
||||
case NET_I2P:
|
||||
case NET_CJDNS:
|
||||
return false;
|
||||
case NET_UNROUTABLE: // m_net is never and should not be set to NET_UNROUTABLE
|
||||
case NET_MAX: // m_net is never and should not be set to NET_MAX
|
||||
assert(false);
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
|
||||
assert(false);
|
||||
}
|
||||
|
||||
enum Network CNetAddr::GetNetwork() const
|
||||
{
|
||||
if (IsInternal())
|
||||
@@ -744,9 +764,12 @@ std::vector<unsigned char> CNetAddr::GetGroup(const std::vector<bool> &asmap) co
|
||||
|
||||
std::vector<unsigned char> CNetAddr::GetAddrBytes() const
|
||||
{
|
||||
uint8_t serialized[V1_SERIALIZATION_SIZE];
|
||||
SerializeV1Array(serialized);
|
||||
return {std::begin(serialized), std::end(serialized)};
|
||||
if (IsAddrV1Compatible()) {
|
||||
uint8_t serialized[V1_SERIALIZATION_SIZE];
|
||||
SerializeV1Array(serialized);
|
||||
return {std::begin(serialized), std::end(serialized)};
|
||||
}
|
||||
return std::vector<unsigned char>(m_addr.begin(), m_addr.end());
|
||||
}
|
||||
|
||||
uint64_t CNetAddr::GetHash() const
|
||||
|
||||
Reference in New Issue
Block a user