mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
don't recreate tunnels of different size
This commit is contained in:
parent
ab80def94b
commit
1967dee50c
|
@ -670,10 +670,12 @@ namespace tunnel
|
||||||
{
|
{
|
||||||
if (!tunnel->IsRecreated () && ts + TUNNEL_RECREATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
if (!tunnel->IsRecreated () && ts + TUNNEL_RECREATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||||
{
|
{
|
||||||
tunnel->SetIsRecreated ();
|
|
||||||
auto pool = tunnel->GetTunnelPool ();
|
auto pool = tunnel->GetTunnelPool ();
|
||||||
if (pool)
|
if (pool && tunnel->GetPeers().size() == pool->GetNumOutboundHops())
|
||||||
|
{
|
||||||
|
tunnel->SetIsRecreated ();
|
||||||
pool->RecreateOutboundTunnel (tunnel);
|
pool->RecreateOutboundTunnel (tunnel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
if (ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||||
tunnel->SetState (eTunnelStateExpiring);
|
tunnel->SetState (eTunnelStateExpiring);
|
||||||
|
@ -723,8 +725,11 @@ namespace tunnel
|
||||||
{
|
{
|
||||||
tunnel->SetIsRecreated ();
|
tunnel->SetIsRecreated ();
|
||||||
auto pool = tunnel->GetTunnelPool ();
|
auto pool = tunnel->GetTunnelPool ();
|
||||||
if (pool)
|
if (pool && tunnel->GetPeers().size() == pool->GetNumInboundHops())
|
||||||
|
{
|
||||||
|
tunnel->SetIsRecreated ();
|
||||||
pool->RecreateInboundTunnel (tunnel);
|
pool->RecreateInboundTunnel (tunnel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
if (ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
|
||||||
|
|
|
@ -491,11 +491,14 @@ namespace tunnel
|
||||||
outboundTunnel = tunnels.GetNextOutboundTunnel ();
|
outboundTunnel = tunnels.GetNextOutboundTunnel ();
|
||||||
LogPrint (eLogDebug, "Tunnels: Re-creating destination inbound tunnel...");
|
LogPrint (eLogDebug, "Tunnels: Re-creating destination inbound tunnel...");
|
||||||
std::shared_ptr<TunnelConfig> config;
|
std::shared_ptr<TunnelConfig> config;
|
||||||
if (m_NumInboundHops > 0) config = std::make_shared<TunnelConfig>(tunnel->GetPeers ());
|
if (m_NumInboundHops > 0 && tunnel->GetPeers().size() > 0) config = std::make_shared<TunnelConfig>(tunnel->GetPeers ());
|
||||||
auto newTunnel = tunnels.CreateInboundTunnel (config, outboundTunnel);
|
if (m_NumInboundHops == 0 || config)
|
||||||
newTunnel->SetTunnelPool (shared_from_this());
|
{
|
||||||
if (newTunnel->IsEstablished ()) // zero hops
|
auto newTunnel = tunnels.CreateInboundTunnel (config, outboundTunnel);
|
||||||
TunnelCreated (newTunnel);
|
newTunnel->SetTunnelPool (shared_from_this());
|
||||||
|
if (newTunnel->IsEstablished ()) // zero hops
|
||||||
|
TunnelCreated (newTunnel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TunnelPool::CreateOutboundTunnel ()
|
void TunnelPool::CreateOutboundTunnel ()
|
||||||
|
@ -533,12 +536,17 @@ namespace tunnel
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "Tunnels: Re-creating destination outbound tunnel...");
|
LogPrint (eLogDebug, "Tunnels: Re-creating destination outbound tunnel...");
|
||||||
std::shared_ptr<TunnelConfig> config;
|
std::shared_ptr<TunnelConfig> config;
|
||||||
if (m_NumOutboundHops > 0)
|
if (tunnel->GetPeers().size() > 0 && m_NumOutboundHops > 0)
|
||||||
|
{
|
||||||
config = std::make_shared<TunnelConfig>(tunnel->GetPeers (), inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ());
|
config = std::make_shared<TunnelConfig>(tunnel->GetPeers (), inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ());
|
||||||
auto newTunnel = tunnels.CreateOutboundTunnel (config);
|
}
|
||||||
newTunnel->SetTunnelPool (shared_from_this ());
|
if(m_NumOutboundHops == 0 || config)
|
||||||
if (newTunnel->IsEstablished ()) // zero hops
|
{
|
||||||
TunnelCreated (newTunnel);
|
auto newTunnel = tunnels.CreateOutboundTunnel (config);
|
||||||
|
newTunnel->SetTunnelPool (shared_from_this ());
|
||||||
|
if (newTunnel->IsEstablished ()) // zero hops
|
||||||
|
TunnelCreated (newTunnel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogDebug, "Tunnels: Can't re-create outbound tunnel, no inbound tunnels found");
|
LogPrint (eLogDebug, "Tunnels: Can't re-create outbound tunnel, no inbound tunnels found");
|
||||||
|
|
Loading…
Reference in a new issue