STTNet
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
Public Member Functions | List of all members
stt::security::ConnectionLimiter Class Reference

Restrict the classes that can be connected to the same IP address. More...

#include <sttnet_English.h>

Public Member Functions

 ConnectionLimiter (const int &connectionLimit=20, const int &connectionRateLimit=6)
 ConnectionLimiter constructor. More...
 
bool allow (const std::string &ip)
 Determines whether to allow connections to a particular IP address based on the number of connections and speed. More...
 
void clearIP (const std::string &ip)
 Clear the number of connections that record an IP address. More...
 

Detailed Description

Restrict the classes that can be connected to the same IP address.

Note
No locks, no synchronization and thread safety, their own on the upper layer to ensure it.
Limit the number and speed of connections to the same IP

Constructor & Destructor Documentation

stt::security::ConnectionLimiter::ConnectionLimiter ( const int &  connectionLimit = 20,
const int &  connectionRateLimit = 6 
)
inline

ConnectionLimiter constructor.

Parameters
connectionLimitThe maximum number of connections to the same IP address is 20 by default
connectionRateLimitThe maximum number of connections per second for the same IP address is 6 by default

Member Function Documentation

bool stt::security::ConnectionLimiter::allow ( const std::string &  ip)

Determines whether to allow connections to a particular IP address based on the number of connections and speed.

Parameters
ipIP address
Returns
true:Connections from a certain IP address should be allowed false: Connections from a certain IP address should be denied
void stt::security::ConnectionLimiter::clearIP ( const std::string &  ip)

Clear the number of connections that record an IP address.

Parameters
IPaddress

The documentation for this class was generated from the following file: