mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
initial ntcp soft/hard limits
This commit is contained in:
parent
bc11181d5e
commit
6441c9d5d8
4 changed files with 59 additions and 14 deletions
|
@ -791,7 +791,8 @@ namespace transport
|
|||
NTCPServer::NTCPServer ():
|
||||
m_IsRunning (false), m_Thread (nullptr), m_Work (m_Service),
|
||||
m_TerminationTimer (m_Service), m_NTCPAcceptor (nullptr), m_NTCPV6Acceptor (nullptr),
|
||||
m_ProxyType(eNoProxy), m_Resolver(m_Service), m_ProxyEndpoint(nullptr)
|
||||
m_ProxyType(eNoProxy), m_Resolver(m_Service), m_ProxyEndpoint(nullptr),
|
||||
m_SoftLimit(0), m_HardLimit(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -965,6 +966,13 @@ namespace transport
|
|||
auto ep = conn->GetSocket ().remote_endpoint(ec);
|
||||
if (!ec)
|
||||
{
|
||||
if(ShouldLimit())
|
||||
{
|
||||
// hit limit, close premature
|
||||
LogPrint(eLogWarning, "NTCP: limiting with backoff session from ", ep);
|
||||
conn->GetSocket().close();
|
||||
return;
|
||||
}
|
||||
LogPrint (eLogDebug, "NTCP: Connected from ", ep);
|
||||
if (conn)
|
||||
{
|
||||
|
@ -993,6 +1001,14 @@ namespace transport
|
|||
auto ep = conn->GetSocket ().remote_endpoint(ec);
|
||||
if (!ec)
|
||||
{
|
||||
if(ShouldLimit())
|
||||
{
|
||||
// hit limit, close premature
|
||||
LogPrint(eLogWarning, "NTCP: limiting with backoff on session from ", ep);
|
||||
conn->GetSocket().close();
|
||||
return;
|
||||
}
|
||||
|
||||
LogPrint (eLogDebug, "NTCP: Connected from ", ep);
|
||||
if (conn)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue