QcConnectionLimiter Class
Bounds new connections per network address (decision E-254): a token bucket per address against connection floods, and a cap of open connections per address and in all. More...
| Header: | #include <server/network/QcConnectionLimiter.h> |
Public Types
Public Functions
| bool | admit(const QString &address, qint64 nowMs) |
| void | closed(const QString &address) |
| int | open() const |
| int | openFrom(const QString &address) const |
Static Public Members
| const qsizetype | maxTracked |
| QString | sourceOf(const QHostAddress &address) |
Detailed Description
Pure bookkeeping in the thread of the listener; the times are given by the caller.
Member Type Documentation
[alias] QcConnectionLimiter::Limits
The limits: rate and burst per address, open connections per address and in all.
Member Function Documentation
bool QcConnectionLimiter::admit(const QString &address, qint64 nowMs)
Returns whether a new connection from address may open at nowMs; counts it when it may.
void QcConnectionLimiter::closed(const QString &address)
A connection from address admitted before has closed.
int QcConnectionLimiter::open() const
Returns the number of open connections in all.
int QcConnectionLimiter::openFrom(const QString &address) const
Returns the number of open connections from address.
[static] QString QcConnectionLimiter::sourceOf(const QHostAddress &address)
Returns the source the limits count for address: an IPv4 address (also mapped into IPv6) as it is, an IPv6 address by its /64 network, which one household or server typically gets whole (decision E-274).
Member Variable Documentation
const qsizetype QcConnectionLimiter::maxTracked
Addresses remembered at most; full buckets are forgotten first.