mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
streaming limiting tweaks
This commit is contained in:
parent
df8d73ae43
commit
34da9a9655
|
@ -853,6 +853,23 @@ namespace stream
|
||||||
if (packet->IsSYN () && !packet->GetSeqn ()) // new incoming stream
|
if (packet->IsSYN () && !packet->GetSeqn ()) // new incoming stream
|
||||||
{
|
{
|
||||||
auto incomingStream = CreateNewIncomingStream ();
|
auto incomingStream = CreateNewIncomingStream ();
|
||||||
|
auto ident = incomingStream->GetRemoteIdentity();
|
||||||
|
if(ident)
|
||||||
|
{
|
||||||
|
auto ih = ident->GetIdentHash();
|
||||||
|
if(DropNewStream(ih))
|
||||||
|
{
|
||||||
|
// drop
|
||||||
|
LogPrint(eLogWarning, "Streaming: Too many inbound streams from ", ih.ToBase32());
|
||||||
|
incomingStream->Close();
|
||||||
|
DeleteStream(incomingStream);
|
||||||
|
incomingStream = nullptr;
|
||||||
|
delete packet;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
LogPrint(eLogWarning, "Streaming: Inbound stream has no identity");
|
||||||
|
|
||||||
uint32_t receiveStreamID = packet->GetReceiveStreamID ();
|
uint32_t receiveStreamID = packet->GetReceiveStreamID ();
|
||||||
incomingStream->HandleNextPacket (packet); // SYN
|
incomingStream->HandleNextPacket (packet); // SYN
|
||||||
// handle saved packets if any
|
// handle saved packets if any
|
||||||
|
@ -866,21 +883,6 @@ namespace stream
|
||||||
m_SavedPackets.erase (it);
|
m_SavedPackets.erase (it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto ident = incomingStream->GetRemoteIdentity();
|
|
||||||
if(ident)
|
|
||||||
{
|
|
||||||
auto ih = ident->GetIdentHash();
|
|
||||||
if(DropNewStream(ih))
|
|
||||||
{
|
|
||||||
// drop
|
|
||||||
LogPrint(eLogWarning, "Streaming: Too many inbound streams from ", ih.ToBase32());
|
|
||||||
DeleteStream(incomingStream);
|
|
||||||
incomingStream = nullptr;
|
|
||||||
delete packet;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
LogPrint(eLogWarning, "Streaming: Inbound stream has no identity");
|
|
||||||
// accept
|
// accept
|
||||||
if (m_Acceptor != nullptr)
|
if (m_Acceptor != nullptr)
|
||||||
m_Acceptor (incomingStream);
|
m_Acceptor (incomingStream);
|
||||||
|
|
Loading…
Reference in a new issue