Counts the datagrams dropped from each address, by reason, for a summary in the log at most every report_period per address (RFC section 6.7): a flood never becomes one log line per datagram.
More...
#include </__w/project-rtype/project-rtype/server/include/rtype/rate_limit.hpp>
|
| using | Clock = std::chrono::steady_clock |
| | Clock of the reports.
|
| |
|
| bool | count (const aegis2d::net::Endpoint &source, std::string_view reason, Clock::time_point now) |
| | Counts a dropped datagram.
|
| |
| std::vector< std::string > | take_due (Clock::time_point now) |
| | Takes the summaries due: one line per address whose first drop since its last summary is at least report_period old, its counts then forgotten.
|
| |
|
| static constexpr std::chrono::seconds | report_period {10} |
| | Shortest time between two summaries of one address.
|
| |
Counts the datagrams dropped from each address, by reason, for a summary in the log at most every report_period per address (RFC section 6.7): a flood never becomes one log line per datagram.
◆ Clock
◆ count()
| bool rtype::DropReport::count |
( |
const aegis2d::net::Endpoint & |
source, |
|
|
std::string_view |
reason, |
|
|
Clock::time_point |
now |
|
) |
| |
Counts a dropped datagram.
- Parameters
-
| source | Source of the datagram; only its address counts. |
| reason | Why it was dropped; must outlive the report (a literal). |
| now | Current time. |
- Returns
true the first time this reason is counted for the address since its last summary, to log an offender once.
◆ take_due()
| std::vector< std::string > rtype::DropReport::take_due |
( |
Clock::time_point |
now | ) |
|
Takes the summaries due: one line per address whose first drop since its last summary is at least report_period old, its counts then forgotten.
- Parameters
-
- Returns
- Lines such as
"203.0.113.7: 1200 dropped in 10 s (1150 rate limit, 50
endpoint not bound)", by address.
◆ report_period
| constexpr std::chrono::seconds rtype::DropReport::report_period {10} |
|
staticconstexpr |
Shortest time between two summaries of one address.
The documentation for this class was generated from the following file: