Browse Source

set pool for zero-hops tunnels

pull/1679/head
orignal 3 years ago
parent
commit
1e01c30e63
  1. 14
      libi2pd/Tunnel.cpp
  2. 4
      libi2pd/Tunnel.h

14
libi2pd/Tunnel.cpp

@ -763,8 +763,8 @@ namespace tunnel
if (m_InboundTunnels.empty ()) if (m_InboundTunnels.empty ())
{ {
LogPrint (eLogDebug, "Tunnel: Creating zero hops inbound tunnel"); LogPrint (eLogDebug, "Tunnel: Creating zero hops inbound tunnel");
CreateZeroHopsInboundTunnel (); CreateZeroHopsInboundTunnel (nullptr);
CreateZeroHopsOutboundTunnel (); CreateZeroHopsOutboundTunnel (nullptr);
if (!m_ExploratoryPool) if (!m_ExploratoryPool)
{ {
int ibLen; i2p::config::GetOption("exploratory.inbound.length", ibLen); int ibLen; i2p::config::GetOption("exploratory.inbound.length", ibLen);
@ -854,7 +854,7 @@ namespace tunnel
if (config) if (config)
return CreateTunnel<InboundTunnel>(config, pool, outboundTunnel); return CreateTunnel<InboundTunnel>(config, pool, outboundTunnel);
else else
return CreateZeroHopsInboundTunnel (); return CreateZeroHopsInboundTunnel (pool);
} }
std::shared_ptr<OutboundTunnel> Tunnels::CreateOutboundTunnel (std::shared_ptr<TunnelConfig> config, std::shared_ptr<TunnelPool> pool) std::shared_ptr<OutboundTunnel> Tunnels::CreateOutboundTunnel (std::shared_ptr<TunnelConfig> config, std::shared_ptr<TunnelPool> pool)
@ -862,7 +862,7 @@ namespace tunnel
if (config) if (config)
return CreateTunnel<OutboundTunnel>(config, pool); return CreateTunnel<OutboundTunnel>(config, pool);
else else
return CreateZeroHopsOutboundTunnel (); return CreateZeroHopsOutboundTunnel (pool);
} }
void Tunnels::AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr<InboundTunnel> tunnel) void Tunnels::AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr<InboundTunnel> tunnel)
@ -912,18 +912,20 @@ namespace tunnel
} }
std::shared_ptr<ZeroHopsInboundTunnel> Tunnels::CreateZeroHopsInboundTunnel () std::shared_ptr<ZeroHopsInboundTunnel> Tunnels::CreateZeroHopsInboundTunnel (std::shared_ptr<TunnelPool> pool)
{ {
auto inboundTunnel = std::make_shared<ZeroHopsInboundTunnel> (); auto inboundTunnel = std::make_shared<ZeroHopsInboundTunnel> ();
inboundTunnel->SetTunnelPool (pool);
inboundTunnel->SetState (eTunnelStateEstablished); inboundTunnel->SetState (eTunnelStateEstablished);
m_InboundTunnels.push_back (inboundTunnel); m_InboundTunnels.push_back (inboundTunnel);
m_Tunnels[inboundTunnel->GetTunnelID ()] = inboundTunnel; m_Tunnels[inboundTunnel->GetTunnelID ()] = inboundTunnel;
return inboundTunnel; return inboundTunnel;
} }
std::shared_ptr<ZeroHopsOutboundTunnel> Tunnels::CreateZeroHopsOutboundTunnel () std::shared_ptr<ZeroHopsOutboundTunnel> Tunnels::CreateZeroHopsOutboundTunnel (std::shared_ptr<TunnelPool> pool)
{ {
auto outboundTunnel = std::make_shared<ZeroHopsOutboundTunnel> (); auto outboundTunnel = std::make_shared<ZeroHopsOutboundTunnel> ();
outboundTunnel->SetTunnelPool (pool);
outboundTunnel->SetState (eTunnelStateEstablished); outboundTunnel->SetState (eTunnelStateEstablished);
m_OutboundTunnels.push_back (outboundTunnel); m_OutboundTunnels.push_back (outboundTunnel);
// we don't insert into m_Tunnels // we don't insert into m_Tunnels

4
libi2pd/Tunnel.h

@ -237,8 +237,8 @@ namespace tunnel
void ManagePendingTunnels (PendingTunnels& pendingTunnels); void ManagePendingTunnels (PendingTunnels& pendingTunnels);
void ManageTunnelPools (uint64_t ts); void ManageTunnelPools (uint64_t ts);
std::shared_ptr<ZeroHopsInboundTunnel> CreateZeroHopsInboundTunnel (); std::shared_ptr<ZeroHopsInboundTunnel> CreateZeroHopsInboundTunnel (std::shared_ptr<TunnelPool> pool);
std::shared_ptr<ZeroHopsOutboundTunnel> CreateZeroHopsOutboundTunnel (); std::shared_ptr<ZeroHopsOutboundTunnel> CreateZeroHopsOutboundTunnel (std::shared_ptr<TunnelPool> pool);
private: private:

Loading…
Cancel
Save