LookupSubNet()
would treat addresses that start with fc
as IPv6 even if -cjdnsreachable
is set. This creates the following problems where it is called:
-
NetWhitelistPermissions::TryParse()
: otherwise-whitelist=
fails to white list CJDNS addresses: when a CJDNS peer connects to us, it will be matched against IPv6fc...
subnet and the match will never succeed. -
BanMapFromJson()
: CJDNS bans are stored as just IPv6 addresses inbanlist.json
. Upon reading from disk they have to be converted back to CJDNS, otherwise, after restart, a ban entry like (fc00::1
, IPv6) would not match a peer (fc00::1
, CJDNS). -
RPCConsole::unbanSelectedNode()
: in the GUI the ban entries go throughCSubNet::ToString()
and back viaLookupSubNet()
. Then it must match whatever is stored inBanMan
, otherwise it is impossible to unban via the GUI.
These were uncovered by #26859.
Thus, flip the result of LookupSubNet()
to CJDNS if the network base address starts with fc
and -cjdnsreachable
is set. Since subnetting/masking does not make sense for CJDNS (the address is “random” bytes, like Tor and I2P, there is no hierarchy) treat fc.../mask
as an invalid CSubNet
.
To achieve that, MaybeFlipIPv6toCJDNS()
has to be moved from net
to netbase
and thus also IsReachable()
. In the process of moving IsReachable()
, SetReachable()
and vfLimited[]
encapsulate those in a class.