Skip to content

Commit

Permalink
[refactor] rpc: boost 1.87 fixes for server
Browse files Browse the repository at this point in the history
  • Loading branch information
div72 committed Dec 16, 2024
1 parent 72af3ca commit 94747c5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,19 @@ bool ClientAllowed(const boost::asio::ip::address& address)
{
// Make sure that IPv4-compatible and IPv4-mapped IPv6 addresses are treated as IPv4 addresses
if (address.is_v6()
&& (address.to_v6().is_v4_compatible()
|| address.to_v6().is_v4_mapped()))
return ClientAllowed(address.to_v6().to_v4());
&& (address.to_v6() <= boost::asio::ip::make_address_v6("::ffff:ffff")
|| address.to_v6().is_v4_mapped())) {
auto address6 = address.to_v6();
auto bytes = address6.to_bytes();

return ClientAllowed(boost::asio::ip::address_v4({bytes[12], bytes[13], bytes[14], bytes[15]}));
}

if (address == asio::ip::address_v4::loopback()
|| address == asio::ip::address_v6::loopback()
|| (address.is_v4()
// Check whether IPv4 addresses match 127.0.0.0/8 (loopback subnet)
&& (address.to_v4().to_ulong() & 0xff000000) == 0x7f000000))
&& (address.to_v4().to_bytes()[0] == 127)))
return true;

const string strAddress = address.to_string();
Expand Down Expand Up @@ -661,7 +665,7 @@ void StartRPCThreads()
acceptor->set_option(boost::asio::ip::v6_only(loopback), v6_only_error);

acceptor->bind(endpoint);
acceptor->listen(socket_base::max_connections);
acceptor->listen(socket_base::max_listen_connections);

RPCListen(acceptor, *rpc_ssl_context, fUseSSL);

Expand All @@ -684,7 +688,7 @@ void StartRPCThreads()
acceptor->open(endpoint.protocol());
acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
acceptor->bind(endpoint);
acceptor->listen(socket_base::max_connections);
acceptor->listen(socket_base::max_listen_connections);

RPCListen(acceptor, *rpc_ssl_context, fUseSSL);

Expand Down

0 comments on commit 94747c5

Please sign in to comment.