From 3b66bba92e25e68d0999f5777ba2186ca6c7157f Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 28 Jul 2016 12:17:24 -0400 Subject: [PATCH] more fixes --- ClientContext.cpp | 3 ++- Streaming.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index 623abab8..8fb8d927 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -436,9 +436,10 @@ namespace client std::make_pair (localDestination->GetIdentHash (), inPort), std::unique_ptr(serverTunnel))).second) { - serverTunnel->Start (); auto maxConns = section.second.get(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 diff --git a/Streaming.cpp b/Streaming.cpp index 5138498d..a8d9bb71 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -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 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; }