diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 0befdcda..f7f15cc1 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -245,7 +245,7 @@ namespace util for (auto it: i2p::tunnel::tunnels.GetOutboundTunnels ()) { it->GetTunnelConfig ()->Print (s); - if (it->GetTunnelPool ()) + if (it->GetTunnelPool () && !it->GetTunnelPool ()->IsExploratory ()) s << " " << "Pool"; if (it->IsFailed ()) s << " " << "Failed"; diff --git a/Tunnel.cpp b/Tunnel.cpp index b85f05aa..9ccf4219 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -384,35 +384,18 @@ namespace tunnel it++; } - if (m_OutboundTunnels.size () < 15) // TODO: store exploratory tunnels explicitly + if (m_OutboundTunnels.size () < 5) { // trying to create one more oubound tunnel - if (m_InboundTunnels.empty ()) return; - InboundTunnel * inboundTunnel = GetNextInboundTunnel (); - if (m_OutboundTunnels.empty () || m_OutboundTunnels.size () < 3) - { - LogPrint ("Creating one hop outbound tunnel..."); - CreateTunnel ( - new TunnelConfig (std::vector - { - i2p::data::netdb.GetRandomRouter () - }, - inboundTunnel->GetTunnelConfig ())); - } - else - { - - LogPrint ("Creating two hops outbound tunnel..."); - auto firstHop = i2p::data::netdb.GetRandomRouter (); - CreateTunnel ( - new TunnelConfig (std::vector - { - firstHop, - i2p::data::netdb.GetRandomRouter (firstHop) - }, - inboundTunnel->GetTunnelConfig ())); - } + if (!inboundTunnel) return; + LogPrint ("Creating one hop outbound tunnel..."); + CreateTunnel ( + new TunnelConfig (std::vector + { + i2p::data::netdb.GetRandomRouter () + }, + inboundTunnel->GetTunnelConfig ())); } } @@ -437,35 +420,20 @@ namespace tunnel { LogPrint ("Creating zero hops inbound tunnel..."); CreateZeroHopsInboundTunnel (); + if (!m_ExploratoryPool) + m_ExploratoryPool = CreateTunnelPool (i2p::context); return; } - if (m_InboundTunnels.size () < 15) // TODO: store exploratory tunnels explicitly + if (m_OutboundTunnels.empty () || m_InboundTunnels.size () < 5) { - // trying to create one more inbound tunnel - if (m_OutboundTunnels.empty () || m_InboundTunnels.size () < 3) - { - LogPrint ("Creating one hop inbound tunnel..."); - CreateTunnel ( - new TunnelConfig (std::vector - { - i2p::data::netdb.GetRandomRouter () - })); - } - else - { - OutboundTunnel * outboundTunnel = GetNextOutboundTunnel (); - LogPrint ("Creating two hops inbound tunnel..."); - auto router = outboundTunnel->GetTunnelConfig ()->GetFirstHop ()->router; - auto firstHop = i2p::data::netdb.GetRandomRouter (outboundTunnel->GetEndpointRouter ()); - CreateTunnel ( - new TunnelConfig (std::vector - { - firstHop, - router != &i2p::context.GetRouterInfo () ? router : i2p::data::netdb.GetRandomRouter (firstHop) - }), - outboundTunnel); - } + // trying to create one more inbound tunnel + LogPrint ("Creating one hop inbound tunnel..."); + CreateTunnel ( + new TunnelConfig (std::vector + { + i2p::data::netdb.GetRandomRouter () + })); } } diff --git a/TunnelPool.h b/TunnelPool.h index bc71ae24..0e18bcd4 100644 --- a/TunnelPool.h +++ b/TunnelPool.h @@ -28,7 +28,7 @@ namespace tunnel const uint8_t * GetEncryptionPrivateKey () const { return m_LocalDestination.GetEncryptionPrivateKey (); }; const uint8_t * GetEncryptionPublicKey () const { return m_LocalDestination.GetEncryptionPublicKey (); }; - bool IsExploratory () const { return &m_LocalDestination == &i2p::context; }; + bool IsExploratory () const { return m_LocalDestination.GetIdentHash () == i2p::context.GetIdentHash (); }; void CreateTunnels (); void TunnelCreated (InboundTunnel * createdTunnel);