streaming limiting tweaks

This commit is contained in:
Jeff Becker 2016-07-28 11:37:33 -04:00
parent df8d73ae43
commit 34da9a9655
No known key found for this signature in database
GPG key ID: AB950234D6EA286B

View file

@ -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);