aboutsummaryrefslogtreecommitdiff
path: root/src/netaddress.cpp
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2021-09-09 15:46:12 +0200
committerVasil Dimov <vd@FreeBSD.org>2021-11-03 14:58:54 +0100
commitf9c28330a0e77ed077f342e4669e855b3e6b20a1 (patch)
tree72d1abd2ff13bf28afa8bd3b4243de663254787e /src/netaddress.cpp
parent29ff79c0a2a95abf50b78dd2be6ead2abeeaec9f (diff)
downloadbitcoin-f9c28330a0e77ed077f342e4669e855b3e6b20a1.tar.xz
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.
Diffstat (limited to 'src/netaddress.cpp')
-rw-r--r--src/netaddress.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/netaddress.cpp b/src/netaddress.cpp
index e87a27979d..7f1dd698b0 100644
--- a/src/netaddress.cpp
+++ b/src/netaddress.cpp
@@ -794,8 +794,14 @@ std::vector<unsigned char> CNetAddr::GetGroup(const std::vector<bool> &asmap) co
vchRet.push_back((ipv4 >> 24) & 0xFF);
vchRet.push_back((ipv4 >> 16) & 0xFF);
return vchRet;
- } else if (IsTor() || IsI2P() || IsCJDNS()) {
+ } else if (IsTor() || IsI2P()) {
nBits = 4;
+ } else if (IsCJDNS()) {
+ // 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
+ // the first byte is a constant 0xfc, so the random bytes come after it.
+ // Thus skip the constant 8 bits at the start.
+ nBits = 12;
} else if (IsHeNet()) {
// for he.net, use /36 groups
nBits = 36;