mirror of
https://github.com/monero-project/monero.git
synced 2025-08-08 13:52:20 -04:00
Set response limits on http server connections
This commit is contained in:
parent
915c5dc1d9
commit
ec74ff4a3d
13 changed files with 423 additions and 27 deletions
|
@ -129,6 +129,10 @@ namespace
|
|||
const command_line::arg_descriptor<std::string> arg_wallet_dir = {"wallet-dir", "Directory for newly created wallets"};
|
||||
const command_line::arg_descriptor<bool> arg_prompt_for_password = {"prompt-for-password", "Prompts for password when not provided", false};
|
||||
const command_line::arg_descriptor<bool> arg_no_initial_sync = {"no-initial-sync", "Skips the initial sync before listening for connections", false};
|
||||
const command_line::arg_descriptor<std::size_t> arg_rpc_max_connections_per_public_ip = {"rpc-max-connections-per-public-ip", "Max RPC connections per public IP permitted", DEFAULT_RPC_MAX_CONNECTIONS_PER_PUBLIC_IP};
|
||||
const command_line::arg_descriptor<std::size_t> arg_rpc_max_connections_per_private_ip = {"rpc-max-connections-per-private-ip", "Max RPC connections per private and localhost IP permitted", DEFAULT_RPC_MAX_CONNECTIONS_PER_PRIVATE_IP};
|
||||
const command_line::arg_descriptor<std::size_t> arg_rpc_max_connections = {"rpc-max-connections", "Max RPC connections permitted", DEFAULT_RPC_MAX_CONNECTIONS};
|
||||
const command_line::arg_descriptor<std::size_t> arg_rpc_response_soft_limit = {"rpc-response-soft-limit", "Max response bytes that can be queued, enforced at next response attempt", DEFAULT_RPC_SOFT_LIMIT_SIZE};
|
||||
|
||||
constexpr const char default_rpc_username[] = "monero";
|
||||
|
||||
|
@ -325,13 +329,30 @@ namespace tools
|
|||
|
||||
check_background_mining();
|
||||
|
||||
const auto max_connections_public = command_line::get_arg(vm, arg_rpc_max_connections_per_public_ip);
|
||||
const auto max_connections_private = command_line::get_arg(vm, arg_rpc_max_connections_per_private_ip);
|
||||
const auto max_connections = command_line::get_arg(vm, arg_rpc_max_connections);
|
||||
|
||||
if (max_connections < max_connections_public)
|
||||
{
|
||||
MFATAL(arg_rpc_max_connections_per_public_ip.name << " is bigger than " << arg_rpc_max_connections.name);
|
||||
return false;
|
||||
}
|
||||
if (max_connections < max_connections_private)
|
||||
{
|
||||
MFATAL(arg_rpc_max_connections_per_private_ip.name << " is bigger than " << arg_rpc_max_connections.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_net_server.set_threads_prefix("RPC");
|
||||
auto rng = [](size_t len, uint8_t *ptr) { return crypto::rand(len, ptr); };
|
||||
return epee::http_server_impl_base<wallet_rpc_server, connection_context>::init(
|
||||
rng, std::move(bind_port), std::move(rpc_config->bind_ip),
|
||||
std::move(rpc_config->bind_ipv6_address), std::move(rpc_config->use_ipv6), std::move(rpc_config->require_ipv4),
|
||||
std::move(rpc_config->access_control_origins), std::move(http_login),
|
||||
std::move(rpc_config->ssl_options)
|
||||
std::move(rpc_config->ssl_options),
|
||||
max_connections_public, max_connections_private, max_connections,
|
||||
command_line::get_arg(vm, arg_rpc_response_soft_limit)
|
||||
);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -4974,6 +4995,10 @@ int main(int argc, char** argv) {
|
|||
command_line::add_arg(desc_params, arg_wallet_dir);
|
||||
command_line::add_arg(desc_params, arg_prompt_for_password);
|
||||
command_line::add_arg(desc_params, arg_no_initial_sync);
|
||||
command_line::add_arg(desc_params, arg_rpc_max_connections_per_public_ip);
|
||||
command_line::add_arg(desc_params, arg_rpc_max_connections_per_private_ip);
|
||||
command_line::add_arg(desc_params, arg_rpc_max_connections);
|
||||
command_line::add_arg(desc_params, arg_rpc_response_soft_limit);
|
||||
command_line::add_arg(hidden_options, daemonizer::arg_non_interactive);
|
||||
|
||||
daemonizer::init_options(hidden_options, desc_params);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue