R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
rtype::DropReport Class Reference

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>

Public Types

using Clock = std::chrono::steady_clock
 Clock of the reports.
 

Public Member Functions

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 Public Attributes

static constexpr std::chrono::seconds report_period {10}
 Shortest time between two summaries of one address.
 

Detailed Description

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.

Member Typedef Documentation

◆ Clock

using rtype::DropReport::Clock = std::chrono::steady_clock

Clock of the reports.

Member Function Documentation

◆ count()

bool rtype::DropReport::count ( const aegis2d::net::Endpoint &  source,
std::string_view  reason,
Clock::time_point  now 
)

Counts a dropped datagram.

Parameters
sourceSource of the datagram; only its address counts.
reasonWhy it was dropped; must outlive the report (a literal).
nowCurrent 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
nowCurrent time.
Returns
Lines such as "203.0.113.7: 1200 dropped in 10 s (1150 rate limit, 50 endpoint not bound)", by address.

Member Data Documentation

◆ 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: