created paired inbound tunnel after outbound

This commit is contained in:
orignal 2015-05-07 16:03:12 -04:00
parent 490e829083
commit 39c346df10
2 changed files with 14 additions and 3 deletions

View File

@ -66,8 +66,11 @@ namespace tunnel
void TunnelPool::TunnelCreated (std::shared_ptr<OutboundTunnel> createdTunnel) void TunnelPool::TunnelCreated (std::shared_ptr<OutboundTunnel> createdTunnel)
{ {
if (!m_IsActive) return; if (!m_IsActive) return;
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex); {
m_OutboundTunnels.insert (createdTunnel); std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
m_OutboundTunnels.insert (createdTunnel);
}
CreatePairedInboundTunnel (createdTunnel);
} }
void TunnelPool::TunnelExpired (std::shared_ptr<OutboundTunnel> expiredTunnel) void TunnelPool::TunnelExpired (std::shared_ptr<OutboundTunnel> expiredTunnel)
@ -389,6 +392,13 @@ namespace tunnel
} }
else else
LogPrint ("Can't re-create outbound tunnel. No inbound tunnels found"); LogPrint ("Can't re-create outbound tunnel. No inbound tunnels found");
} }
void TunnelPool::CreatePairedInboundTunnel (std::shared_ptr<OutboundTunnel> outboundTunnel)
{
LogPrint (eLogInfo, "Creating paired inbound tunnel...");
auto tunnel = tunnels.CreateTunnel<InboundTunnel> (outboundTunnel->GetTunnelConfig ()->Invert (), outboundTunnel);
tunnel->SetTunnelPool (shared_from_this ());
}
} }
} }

View File

@ -57,6 +57,7 @@ namespace tunnel
void CreateInboundTunnel (); void CreateInboundTunnel ();
void CreateOutboundTunnel (); void CreateOutboundTunnel ();
void CreatePairedInboundTunnel (std::shared_ptr<OutboundTunnel> outboundTunnel);
template<class TTunnels> template<class TTunnels>
typename TTunnels::value_type GetNextTunnel (TTunnels& tunnels, typename TTunnels::value_type excluded) const; typename TTunnels::value_type GetNextTunnel (TTunnels& tunnels, typename TTunnels::value_type excluded) const;
std::shared_ptr<const i2p::data::RouterInfo> SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop) const; std::shared_ptr<const i2p::data::RouterInfo> SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop) const;