mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Merge bitcoin/bitcoin#27071: Handle CJDNS from LookupSubNet()
0e6f6ebc06net: remove unused CConnman::FindNode(const CSubNet&) (Vasil Dimov)9482cb780fnetbase: possibly change the result of LookupSubNet() to CJDNS (Vasil Dimov)53afa68026net: move MaybeFlipIPv6toCJDNS() from net to netbase (Vasil Dimov)6e308651c4net: move IsReachable() code to netbase and encapsulate it (Vasil Dimov)c42ded3d9bfuzz: ConsumeNetAddr(): avoid IPv6 addresses that look like CJDNS (Vasil Dimov)64d6f77907net: put CJDNS prefix byte in a constant (Vasil Dimov) Pull request description: `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 IPv6 `fc...` subnet and the match will never succeed. * `BanMapFromJson()`: CJDNS bans are stored as just IPv6 addresses in `banlist.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 through `CSubNet::ToString()` and back via `LookupSubNet()`. Then it must match whatever is stored in `BanMan`, otherwise it is impossible to unban via the GUI. These were uncovered by https://github.com/bitcoin/bitcoin/pull/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. ACKs for top commit: jonatack: Code review ACK0e6f6ebc06achow101: ACK0e6f6ebc06mzumsande: re-ACK0e6f6ebc06Tree-SHA512: 4767a60dc882916de4c8b110ce8de208ff3f58daaa0b560e6547d72e604d07c4157e72cf98b237228310fc05c0a3922f446674492e2ba02e990a272d288bd566
This commit is contained in:
@@ -585,8 +585,8 @@ static UniValue GetNetworksInfo()
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
GetProxy(network, proxy);
|
||||
obj.pushKV("name", GetNetworkName(network));
|
||||
obj.pushKV("limited", !IsReachable(network));
|
||||
obj.pushKV("reachable", IsReachable(network));
|
||||
obj.pushKV("limited", !g_reachable_nets.Contains(network));
|
||||
obj.pushKV("reachable", g_reachable_nets.Contains(network));
|
||||
obj.pushKV("proxy", proxy.IsValid() ? proxy.proxy.ToStringAddrPort() : std::string());
|
||||
obj.pushKV("proxy_randomize_credentials", proxy.randomize_credentials);
|
||||
networks.push_back(obj);
|
||||
@@ -730,7 +730,7 @@ static RPCHelpMan setban()
|
||||
if (!isSubnet) {
|
||||
const std::optional<CNetAddr> addr{LookupHost(request.params[0].get_str(), false)};
|
||||
if (addr.has_value()) {
|
||||
netAddr = addr.value();
|
||||
netAddr = static_cast<CNetAddr>(MaybeFlipIPv6toCJDNS(CService{addr.value(), /*port=*/0}));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user