mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-07 06:09:42 +00:00
initial ntcp soft/hard limits
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user