diff --git a/HTTPServer.cpp b/HTTPServer.cpp
index 2124ea87..3b92d4bc 100644
--- a/HTTPServer.cpp
+++ b/HTTPServer.cpp
@@ -610,13 +610,13 @@ namespace util
for (auto it: i2p::tunnel::tunnels.GetInboundTunnels ())
{
- it.second->Print (s);
- auto state = it.second->GetState ();
+ it->Print (s);
+ auto state = it->GetState ();
if (state == i2p::tunnel::eTunnelStateFailed)
s << " " << "Failed";
else if (state == i2p::tunnel::eTunnelStateExpiring)
s << " " << "Exp";
- s << " " << (int)it.second->GetNumReceivedBytes () << "
\r\n";
+ s << " " << (int)it->GetNumReceivedBytes () << "
\r\n";
s << std::endl;
}
}
diff --git a/Tunnel.cpp b/Tunnel.cpp
index 91b8d077..f2521217 100644
--- a/Tunnel.cpp
+++ b/Tunnel.cpp
@@ -258,14 +258,6 @@ namespace tunnel
Tunnels::~Tunnels ()
{
}
-
- std::shared_ptr Tunnels::GetInboundTunnel (uint32_t tunnelID)
- {
- auto it = m_InboundTunnels.find(tunnelID);
- if (it != m_InboundTunnels.end ())
- return it->second;
- return nullptr;
- }
std::shared_ptr Tunnels::GetTunnel (uint32_t tunnelID)
{
@@ -303,11 +295,11 @@ namespace tunnel
size_t minReceived = 0;
for (auto it : m_InboundTunnels)
{
- if (!it.second->IsEstablished ()) continue;
- if (!tunnel || it.second->GetNumReceivedBytes () < minReceived)
+ if (!it->IsEstablished ()) continue;
+ if (!tunnel || it->GetNumReceivedBytes () < minReceived)
{
- tunnel = it.second;
- minReceived = it.second->GetNumReceivedBytes ();
+ tunnel = it;
+ minReceived = it->GetNumReceivedBytes ();
}
}
return tunnel;
@@ -615,7 +607,7 @@ namespace tunnel
{
for (auto it = m_InboundTunnels.begin (); it != m_InboundTunnels.end ();)
{
- auto tunnel = it->second;
+ auto tunnel = *it;
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
{
LogPrint (eLogDebug, "Tunnel: tunnel with id ", tunnel->GetTunnelID (), " expired");
@@ -749,7 +741,7 @@ namespace tunnel
{
if (m_Tunnels.emplace (newTunnel->GetTunnelID (), newTunnel).second)
{
- m_InboundTunnels[newTunnel->GetTunnelID ()] = newTunnel;
+ m_InboundTunnels.push_back (newTunnel);
auto pool = newTunnel->GetTunnelPool ();
if (!pool)
{
@@ -793,17 +785,20 @@ namespace tunnel
return timeout;
}
- size_t Tunnels::CountTransitTunnels() {
+ size_t Tunnels::CountTransitTunnels() const
+ {
// TODO: locking
return m_TransitTunnels.size();
}
- size_t Tunnels::CountInboundTunnels() {
+ size_t Tunnels::CountInboundTunnels() const
+ {
// TODO: locking
return m_InboundTunnels.size();
}
- size_t Tunnels::CountOutboundTunnels() {
+ size_t Tunnels::CountOutboundTunnels() const
+ {
// TODO: locking
return m_OutboundTunnels.size();
}
diff --git a/Tunnel.h b/Tunnel.h
index 11b50eab..c02eb966 100644
--- a/Tunnel.h
+++ b/Tunnel.h
@@ -137,7 +137,6 @@ namespace tunnel
void Start ();
void Stop ();
- std::shared_ptr GetInboundTunnel (uint32_t tunnelID);
std::shared_ptr GetPendingInboundTunnel (uint32_t replyMsgID);
std::shared_ptr GetPendingOutboundTunnel (uint32_t replyMsgID);
std::shared_ptr GetNextInboundTunnel ();
@@ -184,7 +183,7 @@ namespace tunnel
std::thread * m_Thread;
std::map > m_PendingInboundTunnels; // by replyMsgID
std::map > m_PendingOutboundTunnels; // by replyMsgID
- std::map > m_InboundTunnels;
+ std::list > m_InboundTunnels;
std::list > m_OutboundTunnels;
std::list > m_TransitTunnels;
std::unordered_map > m_Tunnels; // tunnelID->tunnel known by this id
@@ -203,9 +202,9 @@ namespace tunnel
const decltype(m_InboundTunnels)& GetInboundTunnels () const { return m_InboundTunnels; };
const decltype(m_TransitTunnels)& GetTransitTunnels () const { return m_TransitTunnels; };
- size_t CountTransitTunnels();
- size_t CountInboundTunnels();
- size_t CountOutboundTunnels();
+ size_t CountTransitTunnels() const;
+ size_t CountInboundTunnels() const;
+ size_t CountOutboundTunnels() const;
int GetQueueSize () { return m_Queue.GetSize (); };
int GetTunnelCreationSuccessRate () const // in percents