mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
net: put CJDNS prefix byte in a constant
This commit is contained in:
@@ -81,6 +81,10 @@ static const std::array<uint8_t, 6> INTERNAL_IN_IPV6_PREFIX{
|
|||||||
0xFD, 0x6B, 0x88, 0xC0, 0x87, 0x24 // 0xFD + sha256("bitcoin")[0:5].
|
0xFD, 0x6B, 0x88, 0xC0, 0x87, 0x24 // 0xFD + sha256("bitcoin")[0:5].
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// All CJDNS addresses start with 0xFC. See
|
||||||
|
/// https://github.com/cjdelisle/cjdns/blob/master/doc/Whitepaper.md#pulling-it-all-together
|
||||||
|
static constexpr uint8_t CJDNS_PREFIX{0xFC};
|
||||||
|
|
||||||
/// Size of IPv4 address (in bytes).
|
/// Size of IPv4 address (in bytes).
|
||||||
static constexpr size_t ADDR_IPV4_SIZE = 4;
|
static constexpr size_t ADDR_IPV4_SIZE = 4;
|
||||||
|
|
||||||
@@ -174,7 +178,7 @@ public:
|
|||||||
[[nodiscard]] bool IsTor() const { return m_net == NET_ONION; }
|
[[nodiscard]] bool IsTor() const { return m_net == NET_ONION; }
|
||||||
[[nodiscard]] bool IsI2P() const { return m_net == NET_I2P; }
|
[[nodiscard]] bool IsI2P() const { return m_net == NET_I2P; }
|
||||||
[[nodiscard]] bool IsCJDNS() const { return m_net == NET_CJDNS; }
|
[[nodiscard]] bool IsCJDNS() const { return m_net == NET_CJDNS; }
|
||||||
[[nodiscard]] bool HasCJDNSPrefix() const { return m_addr[0] == 0xfc; }
|
[[nodiscard]] bool HasCJDNSPrefix() const { return m_addr[0] == CJDNS_PREFIX; }
|
||||||
bool IsLocal() const;
|
bool IsLocal() const;
|
||||||
bool IsRoutable() const;
|
bool IsRoutable() const;
|
||||||
bool IsInternal() const;
|
bool IsInternal() const;
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ std::vector<unsigned char> NetGroupManager::GetGroup(const CNetAddr& address) co
|
|||||||
} else if (address.IsCJDNS()) {
|
} else if (address.IsCJDNS()) {
|
||||||
// Treat in the same way as Tor and I2P because the address in all of
|
// Treat in the same way as Tor and I2P because the address in all of
|
||||||
// them is "random" bytes (derived from a public key). However in CJDNS
|
// them is "random" bytes (derived from a public key). However in CJDNS
|
||||||
// the first byte is a constant 0xfc, so the random bytes come after it.
|
// the first byte is a constant (see CJDNS_PREFIX), so the random bytes
|
||||||
// Thus skip the constant 8 bits at the start.
|
// come after it. Thus skip the constant 8 bits at the start.
|
||||||
nBits = 12;
|
nBits = 12;
|
||||||
} else if (address.IsHeNet()) {
|
} else if (address.IsHeNet()) {
|
||||||
// for he.net, use /36 groups
|
// for he.net, use /36 groups
|
||||||
|
|||||||
Reference in New Issue
Block a user