mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 16:34:13 +00:00
re-create tunnel before expiration
This commit is contained in:
parent
c56ddce2f6
commit
27bd193708
26
Tunnel.cpp
26
Tunnel.cpp
@ -535,17 +535,20 @@ namespace tunnel
|
|||||||
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||||
{
|
{
|
||||||
LogPrint ("Tunnel ", tunnel->GetTunnelID (), " expired");
|
LogPrint ("Tunnel ", tunnel->GetTunnelID (), " expired");
|
||||||
{
|
auto pool = tunnel->GetTunnelPool ();
|
||||||
auto pool = tunnel->GetTunnelPool ();
|
if (pool)
|
||||||
if (pool)
|
pool->TunnelExpired (tunnel);
|
||||||
pool->TunnelExpired (tunnel);
|
|
||||||
}
|
|
||||||
it = m_OutboundTunnels.erase (it);
|
it = m_OutboundTunnels.erase (it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tunnel->IsEstablished () && ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
if (tunnel->IsEstablished () && ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||||
|
{
|
||||||
tunnel->SetState (eTunnelStateExpiring);
|
tunnel->SetState (eTunnelStateExpiring);
|
||||||
|
auto pool = tunnel->GetTunnelPool ();
|
||||||
|
if (pool)
|
||||||
|
pool->RecreateOutboundTunnel (tunnel);
|
||||||
|
}
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -575,17 +578,20 @@ namespace tunnel
|
|||||||
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||||
{
|
{
|
||||||
LogPrint ("Tunnel ", tunnel->GetTunnelID (), " expired");
|
LogPrint ("Tunnel ", tunnel->GetTunnelID (), " expired");
|
||||||
{
|
auto pool = tunnel->GetTunnelPool ();
|
||||||
auto pool = tunnel->GetTunnelPool ();
|
if (pool)
|
||||||
if (pool)
|
pool->TunnelExpired (tunnel);
|
||||||
pool->TunnelExpired (tunnel);
|
|
||||||
}
|
|
||||||
it = m_InboundTunnels.erase (it);
|
it = m_InboundTunnels.erase (it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tunnel->IsEstablished () && ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
if (tunnel->IsEstablished () && ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||||
|
{
|
||||||
tunnel->SetState (eTunnelStateExpiring);
|
tunnel->SetState (eTunnelStateExpiring);
|
||||||
|
auto pool = tunnel->GetTunnelPool ();
|
||||||
|
if (pool)
|
||||||
|
pool->RecreateInboundTunnel (tunnel);
|
||||||
|
}
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ namespace tunnel
|
|||||||
expiredTunnel->SetTunnelPool (nullptr);
|
expiredTunnel->SetTunnelPool (nullptr);
|
||||||
for (auto it: m_Tests)
|
for (auto it: m_Tests)
|
||||||
if (it.second.second == expiredTunnel) it.second.second = nullptr;
|
if (it.second.second == expiredTunnel) it.second.second = nullptr;
|
||||||
RecreateInboundTunnel (expiredTunnel);
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
|
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
|
||||||
m_InboundTunnels.erase (expiredTunnel);
|
m_InboundTunnels.erase (expiredTunnel);
|
||||||
@ -77,7 +76,6 @@ namespace tunnel
|
|||||||
expiredTunnel->SetTunnelPool (nullptr);
|
expiredTunnel->SetTunnelPool (nullptr);
|
||||||
for (auto it: m_Tests)
|
for (auto it: m_Tests)
|
||||||
if (it.second.first == expiredTunnel) it.second.first = nullptr;
|
if (it.second.first == expiredTunnel) it.second.first = nullptr;
|
||||||
RecreateOutboundTunnel (expiredTunnel);
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
|
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
|
||||||
m_OutboundTunnels.erase (expiredTunnel);
|
m_OutboundTunnels.erase (expiredTunnel);
|
||||||
|
@ -38,6 +38,8 @@ namespace tunnel
|
|||||||
void TunnelExpired (std::shared_ptr<InboundTunnel> expiredTunnel);
|
void TunnelExpired (std::shared_ptr<InboundTunnel> expiredTunnel);
|
||||||
void TunnelCreated (std::shared_ptr<OutboundTunnel> createdTunnel);
|
void TunnelCreated (std::shared_ptr<OutboundTunnel> createdTunnel);
|
||||||
void TunnelExpired (std::shared_ptr<OutboundTunnel> expiredTunnel);
|
void TunnelExpired (std::shared_ptr<OutboundTunnel> expiredTunnel);
|
||||||
|
void RecreateInboundTunnel (std::shared_ptr<InboundTunnel> tunnel);
|
||||||
|
void RecreateOutboundTunnel (std::shared_ptr<OutboundTunnel> tunnel);
|
||||||
std::vector<std::shared_ptr<InboundTunnel> > GetInboundTunnels (int num) const;
|
std::vector<std::shared_ptr<InboundTunnel> > GetInboundTunnels (int num) const;
|
||||||
std::shared_ptr<OutboundTunnel> GetNextOutboundTunnel (std::shared_ptr<OutboundTunnel> excluded = nullptr) const;
|
std::shared_ptr<OutboundTunnel> GetNextOutboundTunnel (std::shared_ptr<OutboundTunnel> excluded = nullptr) const;
|
||||||
std::shared_ptr<InboundTunnel> GetNextInboundTunnel (std::shared_ptr<InboundTunnel> excluded = nullptr) const;
|
std::shared_ptr<InboundTunnel> GetNextInboundTunnel (std::shared_ptr<InboundTunnel> excluded = nullptr) const;
|
||||||
@ -54,8 +56,6 @@ namespace tunnel
|
|||||||
|
|
||||||
void CreateInboundTunnel ();
|
void CreateInboundTunnel ();
|
||||||
void CreateOutboundTunnel ();
|
void CreateOutboundTunnel ();
|
||||||
void RecreateInboundTunnel (std::shared_ptr<InboundTunnel> tunnel);
|
|
||||||
void RecreateOutboundTunnel (std::shared_ptr<OutboundTunnel> tunnel);
|
|
||||||
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user