Browse Source

Merge pull request #996 from majestrate/stream-limits

Stream limits
pull/997/head
orignal 7 years ago committed by GitHub
parent
commit
34d6eb52d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      libi2pd/Streaming.cpp
  2. 1
      libi2pd/Streaming.h

6
libi2pd/Streaming.cpp

@ -882,7 +882,8 @@ namespace stream @@ -882,7 +882,8 @@ namespace stream
m_PendingIncomingTimer (m_Owner->GetService ()),
m_ConnTrackTimer(m_Owner->GetService()),
m_ConnsPerMinute(DEFAULT_MAX_CONNS_PER_MIN),
m_LastBanClear(i2p::util::GetMillisecondsSinceEpoch())
m_LastBanClear(i2p::util::GetMillisecondsSinceEpoch()),
m_EnableDrop(false)
{
}
@ -946,7 +947,7 @@ namespace stream @@ -946,7 +947,7 @@ namespace stream
auto incomingStream = CreateNewIncomingStream ();
incomingStream->HandleNextPacket (packet); // SYN
auto ident = incomingStream->GetRemoteIdentity();
if(ident)
if(ident && m_EnableDrop)
{
auto ih = ident->GetIdentHash();
if(DropNewStream(ih))
@ -1153,6 +1154,7 @@ namespace stream @@ -1153,6 +1154,7 @@ namespace stream
void StreamingDestination::SetMaxConnsPerMinute(const uint32_t conns)
{
m_EnableDrop = conns > 0;
m_ConnsPerMinute = conns;
LogPrint(eLogDebug, "Streaming: Set max conns per minute per destination to ", conns);
}

1
libi2pd/Streaming.h

@ -317,6 +317,7 @@ namespace stream @@ -317,6 +317,7 @@ namespace stream
uint64_t m_LastBanClear;
i2p::util::MemoryPool<Packet> m_PacketsPool;
bool m_EnableDrop;
public:

Loading…
Cancel
Save