mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-27 13:14: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::make_pair (localDestination->GetIdentHash (), inPort),
|
||||||
std::unique_ptr<I2PServerTunnel>(serverTunnel))).second)
|
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);
|
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->SetMaxConnsPerMinute(maxConns);
|
||||||
|
serverTunnel->Start ();
|
||||||
numServerTunnels++;
|
numServerTunnels++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1042,25 +1042,27 @@ namespace stream
|
|||||||
void StreamingDestination::SetMaxConnsPerMinute(const uint32_t conns)
|
void StreamingDestination::SetMaxConnsPerMinute(const uint32_t conns)
|
||||||
{
|
{
|
||||||
m_ConnsPerMinute = conns;
|
m_ConnsPerMinute = conns;
|
||||||
|
LogPrint(eLogDebug, "Streaming: Set max conns per minute per destination to ", conns);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StreamingDestination::DropNewStream(const i2p::data::IdentHash & ih)
|
bool StreamingDestination::DropNewStream(const i2p::data::IdentHash & ih)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_ConnsMutex);
|
std::lock_guard<std::mutex> lock(m_ConnsMutex);
|
||||||
if (m_Banned.size() > MAX_BANNED_CONNS) return true; // overload
|
if (m_Banned.size() > MAX_BANNED_CONNS) return true; // overload
|
||||||
auto end = m_Banned.end();
|
auto end = std::end(m_Banned);
|
||||||
if ( std::find(m_Banned.begin(), end, ih) != end) return true; // already banned
|
if ( std::find(std::begin(m_Banned), end, ih) != end) return true; // already banned
|
||||||
auto itr = m_Conns.find(ih);
|
auto itr = m_Conns.find(ih);
|
||||||
if (itr == m_Conns.end())
|
if (itr == m_Conns.end())
|
||||||
m_Conns[ih] = 0;
|
m_Conns[ih] = 0;
|
||||||
|
|
||||||
m_Conns[ih] = m_Conns[ih] + 1;
|
m_Conns[ih] += 1;
|
||||||
|
|
||||||
bool ban = m_Conns[ih] >= m_ConnsPerMinute;
|
bool ban = m_Conns[ih] >= m_ConnsPerMinute;
|
||||||
if (ban)
|
if (ban)
|
||||||
{
|
{
|
||||||
m_Banned.push_back(ih);
|
m_Banned.push_back(ih);
|
||||||
m_Conns.erase(ih);
|
m_Conns.erase(ih);
|
||||||
|
LogPrint(eLogWarning, "Streaming: ban ", ih.ToBase32());
|
||||||
}
|
}
|
||||||
return ban;
|
return ban;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user