aboutsummaryrefslogtreecommitdiff
path: root/src/httpserver.cpp
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2023-02-07 15:16:57 +0100
committerVasil Dimov <vd@FreeBSD.org>2023-10-16 12:57:49 +0200
commit9482cb780fe04c1f1d9050edd1b8e549e52c86ce (patch)
tree8c537b1b3876b61fac0c462087f46f04ce9dd75d /src/httpserver.cpp
parent53afa68026ffa1313ae4aba3664de7791d23b1c8 (diff)
netbase: possibly change the result of LookupSubNet() to CJDNS
All callers of `LookupSubNet()` need the result to be of CJDNS type if `-cjdnsreachable` is set and the address begins with `fc`: * `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). * `setban()` (in `rpc/net.cpp`): otherwise `setban fc.../mask add` would add an IPv6 entry to BanMan. Subnetting does not make sense for CJDNS addresses, thus treat `fc.../mask` as invalid `CSubNet`. The result of `LookupHost()` has to be converted for the case of banning a single host. * `InitHTTPAllowList()`: not necessary since before this change `-rpcallowip=fc...` would match IPv6 subnets against IPv6 peers even if they started with `fc`. But because it is necessary for the above, `HTTPRequest::GetPeer()` also has to be adjusted to return CJDNS peer, so that now CJDNS peers are matched against CJDNS subnets.
Diffstat (limited to 'src/httpserver.cpp')
-rw-r--r--src/httpserver.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 069511563c..eb3f4a1c2b 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -682,7 +682,7 @@ CService HTTPRequest::GetPeer() const
evhttp_connection_get_peer(con, (char**)&address, &port);
#endif // HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
- peer = LookupNumeric(address, port);
+ peer = MaybeFlipIPv6toCJDNS(LookupNumeric(address, port));
}
return peer;
}