mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-23 12:35:50 +00:00
Add finer-grained control for incoming & outgoing peer limits:
This commit replaces the `peers_max` configuration element which had a predetermined split between incoming and outgoing connections with two new configuration options, `peers_in_max` and `peers_out_max`, which server operators can use to explicitly control the number of incoming and outgoing peer slots.
This commit is contained in:
committed by
Nik Bougalis
parent
7ddf856d58
commit
bec6c626d8
@@ -366,7 +366,45 @@ Config::loadFromString(std::string const& fileContents)
|
||||
PEER_PRIVATE = beast::lexicalCastThrow<bool>(strTemp);
|
||||
|
||||
if (getSingleSection(secConfig, SECTION_PEERS_MAX, strTemp, j_))
|
||||
{
|
||||
PEERS_MAX = beast::lexicalCastThrow<std::size_t>(strTemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::optional<std::size_t> peers_in_max{};
|
||||
if (getSingleSection(secConfig, SECTION_PEERS_IN_MAX, strTemp, j_))
|
||||
{
|
||||
peers_in_max = beast::lexicalCastThrow<std::size_t>(strTemp);
|
||||
if (*peers_in_max > 1000)
|
||||
Throw<std::runtime_error>(
|
||||
"Invalid value specified in [" SECTION_PEERS_IN_MAX
|
||||
"] section; the value must be less or equal than 1000");
|
||||
}
|
||||
|
||||
std::optional<std::size_t> peers_out_max{};
|
||||
if (getSingleSection(secConfig, SECTION_PEERS_OUT_MAX, strTemp, j_))
|
||||
{
|
||||
peers_out_max = beast::lexicalCastThrow<std::size_t>(strTemp);
|
||||
if (*peers_out_max < 10 || *peers_out_max > 1000)
|
||||
Throw<std::runtime_error>(
|
||||
"Invalid value specified in [" SECTION_PEERS_OUT_MAX
|
||||
"] section; the value must be in range 10-1000");
|
||||
}
|
||||
|
||||
// if one section is configured then the other must be configured too
|
||||
if ((peers_in_max && !peers_out_max) ||
|
||||
(peers_out_max && !peers_in_max))
|
||||
Throw<std::runtime_error>("Both sections [" SECTION_PEERS_IN_MAX
|
||||
"]"
|
||||
"and [" SECTION_PEERS_OUT_MAX
|
||||
"] must be configured");
|
||||
|
||||
if (peers_in_max && peers_out_max)
|
||||
{
|
||||
PEERS_IN_MAX = *peers_in_max;
|
||||
PEERS_OUT_MAX = *peers_out_max;
|
||||
}
|
||||
}
|
||||
|
||||
if (getSingleSection(secConfig, SECTION_NODE_SIZE, strTemp, j_))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user