mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-26 20:34:15 +00:00
more fixes
This commit is contained in:
parent
a2e01f8a53
commit
3b66bba92e
@ -436,9 +436,10 @@ namespace client
|
||||
std::make_pair (localDestination->GetIdentHash (), inPort),
|
||||
std::unique_ptr<I2PServerTunnel>(serverTunnel))).second)
|
||||
{
|
||||
serverTunnel->Start ();
|
||||
auto maxConns = section.second.get<uint32_t>(i2p::stream::I2CP_PARAM_STREAMING_MAX_CONNS_PER_MIN, i2p::stream::DEFAULT_MAX_CONNS_PER_MIN);
|
||||
LogPrint(eLogInfo, "Clients: Set Max Conns To ", maxConns);
|
||||
serverTunnel->SetMaxConnsPerMinute(maxConns);
|
||||
serverTunnel->Start ();
|
||||
numServerTunnels++;
|
||||
}
|
||||
else
|
||||
|
@ -1042,25 +1042,27 @@ namespace stream
|
||||
void StreamingDestination::SetMaxConnsPerMinute(const uint32_t conns)
|
||||
{
|
||||
m_ConnsPerMinute = conns;
|
||||
LogPrint(eLogDebug, "Streaming: Set max conns per minute per destination to ", conns);
|
||||
}
|
||||
|
||||
bool StreamingDestination::DropNewStream(const i2p::data::IdentHash & ih)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ConnsMutex);
|
||||
if (m_Banned.size() > MAX_BANNED_CONNS) return true; // overload
|
||||
auto end = m_Banned.end();
|
||||
if ( std::find(m_Banned.begin(), end, ih) != end) return true; // already banned
|
||||
auto end = std::end(m_Banned);
|
||||
if ( std::find(std::begin(m_Banned), end, ih) != end) return true; // already banned
|
||||
auto itr = m_Conns.find(ih);
|
||||
if (itr == m_Conns.end())
|
||||
m_Conns[ih] = 0;
|
||||
|
||||
m_Conns[ih] = m_Conns[ih] + 1;
|
||||
m_Conns[ih] += 1;
|
||||
|
||||
bool ban = m_Conns[ih] >= m_ConnsPerMinute;
|
||||
if (ban)
|
||||
{
|
||||
m_Banned.push_back(ih);
|
||||
m_Conns.erase(ih);
|
||||
LogPrint(eLogWarning, "Streaming: ban ", ih.ToBase32());
|
||||
}
|
||||
return ban;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user