Skip to content

Commit f9c2833

Browse files
committed
net: take the first 4 random bits from CJDNS addresses in GetGroup()
CJDNS addresses start with constant 8 bits, so in order to account for the first 4 random ones, we must take the first 12. Otherwise the entire CJDNS network will belong to one group.
1 parent 29ff79c commit f9c2833

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/netaddress.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,14 @@ std::vector<unsigned char> CNetAddr::GetGroup(const std::vector<bool> &asmap) co
794794
vchRet.push_back((ipv4 >> 24) & 0xFF);
795795
vchRet.push_back((ipv4 >> 16) & 0xFF);
796796
return vchRet;
797-
} else if (IsTor() || IsI2P() || IsCJDNS()) {
797+
} else if (IsTor() || IsI2P()) {
798798
nBits = 4;
799+
} else if (IsCJDNS()) {
800+
// Treat in the same way as Tor and I2P because the address in all of
801+
// them is "random" bytes (derived from a public key). However in CJDNS
802+
// the first byte is a constant 0xfc, so the random bytes come after it.
803+
// Thus skip the constant 8 bits at the start.
804+
nBits = 12;
799805
} else if (IsHeNet()) {
800806
// for he.net, use /36 groups
801807
nBits = 36;

0 commit comments

Comments
 (0)