Skip to content

Commit

Permalink
Merge pull request PurpleI2P#996 from majestrate/stream-limits
Browse files Browse the repository at this point in the history
Stream limits
  • Loading branch information
orignal authored Nov 13, 2017
2 parents 3dc5542 + 5820425 commit 34d6eb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libi2pd/Streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions libi2pd/Streaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ namespace stream
uint64_t m_LastBanClear;

i2p::util::MemoryPool<Packet> m_PacketsPool;
bool m_EnableDrop;

public:

Expand Down

0 comments on commit 34d6eb5

Please sign in to comment.