diff --git a/HTTPServer.cpp b/HTTPServer.cpp
index e8620f09..b1f03e86 100644
--- a/HTTPServer.cpp
+++ b/HTTPServer.cpp
@@ -148,6 +148,17 @@ namespace util
s << " " << (int)it.second->GetNumReceivedBytes () << "
";
}
+ s << "
Tunnel pools
"; + for (auto it: i2p::tunnel::tunnels.GetTunnelPools ()) + { + for (auto it1: it->GetInboundTunnels ()) + { + it1->GetTunnelConfig ()->Print (s); + s << " " << (int)it1->GetNumReceivedBytes () << "Transit tunnels
"; for (auto it: i2p::tunnel::tunnels.GetTransitTunnels ()) { diff --git a/Streaming.cpp b/Streaming.cpp index cbe6575b..0bd88f66 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -300,7 +300,7 @@ namespace stream StreamingDestination * sharedLocalDestination = nullptr; - StreamingDestination::StreamingDestination (): m_TunnelPool (this), m_LeaseSet (nullptr) + StreamingDestination::StreamingDestination (): m_LeaseSet (nullptr) { // TODO: read from file later m_Keys = i2p::data::CreateRandomKeys (); @@ -308,6 +308,7 @@ namespace stream m_IdentHash = i2p::data::CalculateIdentHash (m_Identity); m_SigningPrivateKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag, CryptoPP::Integer (m_Keys.signingPrivateKey, 20)); + i2p::tunnel::tunnels.CreateTunnelPool (this); } StreamingDestination::~StreamingDestination () @@ -316,16 +317,6 @@ namespace stream DeleteI2NPMessage (m_LeaseSet); } - void StreamingDestination::Start () - { - m_TunnelPool.CreateTunnels (); - } - - void StreamingDestination::Stop () - { - // TODO: - } - void StreamingDestination::HandleNextPacket (Packet * packet) { uint32_t sendStreamID = packet->GetSendStreamID (); diff --git a/Streaming.h b/Streaming.h index 60044a6b..e4438e0c 100644 --- a/Streaming.h +++ b/Streaming.h @@ -11,7 +11,6 @@ #include "LeaseSet.h" #include "I2NPProtocol.h" #include "Tunnel.h" -#include "TunnelPool.h" namespace i2p { @@ -103,9 +102,7 @@ namespace stream public: StreamingDestination (); - ~StreamingDestination (); - void Start (); - void Stop (); + ~StreamingDestination (); const i2p::data::Keys& GetKeys () const { return m_Keys; }; const i2p::data::Identity& GetIdentity () const { return m_Identity; }; @@ -130,7 +127,6 @@ namespace stream i2p::data::Identity m_Identity; i2p::data::IdentHash m_IdentHash; - i2p::tunnel::TunnelPool m_TunnelPool; I2NPMessage * m_LeaseSet; CryptoPP::DSA::PrivateKey m_SigningPrivateKey; diff --git a/Tunnel.cpp b/Tunnel.cpp index 1c03405e..8c58f8ae 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -186,6 +186,10 @@ namespace tunnel for (auto& it : m_PendingTunnels) delete it.second; m_PendingTunnels.clear (); + + for (auto& it: m_Pools) + delete it; + m_Pools.clear (); } InboundTunnel * Tunnels::GetInboundTunnel (uint32_t tunnelID) @@ -268,6 +272,11 @@ namespace tunnel } return tunnel;*/ } + + void Tunnels::CreateTunnelPool (i2p::data::LocalDestination * localDestination) + { + m_Pools.push_back (new TunnelPool (localDestination)); + } void Tunnels::AddTransitTunnel (TransitTunnel * tunnel) { @@ -343,9 +352,6 @@ namespace tunnel for (auto& it : m_PendingTunnels) { LogPrint ("Pending tunnel build request ", it.first, " has not been responded. Deleted"); - auto pool = it.second->GetTunnelPool (); - if (pool) - pool->TunnelCreationFailed (it.second); delete it.second; } m_PendingTunnels.clear (); @@ -353,6 +359,7 @@ namespace tunnel ManageInboundTunnels (); ManageOutboundTunnels (); ManageTransitTunnels (); + ManageTunnelPools (); /* if (!m_IsTunnelCreated) { @@ -421,9 +428,6 @@ namespace tunnel if (ts > it->second->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) { LogPrint ("Tunnel ", it->second->GetTunnelID (), " expired"); - auto pool = it->second->GetTunnelPool (); - if (pool) - pool->TunnelExpired (it->second); it = m_InboundTunnels.erase (it); } else @@ -480,6 +484,12 @@ namespace tunnel it++; } } + + void Tunnels::ManageTunnelPools () + { + for (auto& it: m_Pools) + it->ManageTunnels (); + } void Tunnels::PostTunnelData (I2NPMessage * msg) { @@ -503,15 +513,15 @@ namespace tunnel void Tunnels::AddInboundTunnel (InboundTunnel * newTunnel) { - m_InboundTunnels[newTunnel->GetTunnelID ()] = newTunnel; auto pool = newTunnel->GetTunnelPool (); - if (pool) - pool->TunnelCreated (newTunnel); - else + if (!pool) { + m_InboundTunnels[newTunnel->GetTunnelID ()] = newTunnel; // build symmetric outbound tunnel CreateTunnel