mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-07 11:54:16 +00:00
wait for 10 seconds before delete a pending tunnel
This commit is contained in:
parent
9655891e4b
commit
fb15c72be2
@ -310,13 +310,11 @@ namespace i2p
|
|||||||
if (tunnel->HandleTunnelBuildResponse (buf, len))
|
if (tunnel->HandleTunnelBuildResponse (buf, len))
|
||||||
{
|
{
|
||||||
LogPrint ("Inbound tunnel ", tunnel->GetTunnelID (), " has been created");
|
LogPrint ("Inbound tunnel ", tunnel->GetTunnelID (), " has been created");
|
||||||
|
tunnel->SetState (i2p::tunnel::eTunnelStateEstablished);
|
||||||
i2p::tunnel::tunnels.AddInboundTunnel (static_cast<i2p::tunnel::InboundTunnel *>(tunnel));
|
i2p::tunnel::tunnels.AddInboundTunnel (static_cast<i2p::tunnel::InboundTunnel *>(tunnel));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
LogPrint ("Inbound tunnel ", tunnel->GetTunnelID (), " has been declined");
|
LogPrint ("Inbound tunnel ", tunnel->GetTunnelID (), " has been declined");
|
||||||
delete tunnel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -368,14 +366,11 @@ namespace i2p
|
|||||||
if (tunnel->HandleTunnelBuildResponse (buf, len))
|
if (tunnel->HandleTunnelBuildResponse (buf, len))
|
||||||
{
|
{
|
||||||
LogPrint ("Outbound tunnel ", tunnel->GetTunnelID (), " has been created");
|
LogPrint ("Outbound tunnel ", tunnel->GetTunnelID (), " has been created");
|
||||||
|
tunnel->SetState (i2p::tunnel::eTunnelStateEstablished);
|
||||||
i2p::tunnel::tunnels.AddOutboundTunnel (static_cast<i2p::tunnel::OutboundTunnel *>(tunnel));
|
i2p::tunnel::tunnels.AddOutboundTunnel (static_cast<i2p::tunnel::OutboundTunnel *>(tunnel));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
LogPrint ("Outbound tunnel ", tunnel->GetTunnelID (), " has been declined");
|
LogPrint ("Outbound tunnel ", tunnel->GetTunnelID (), " has been declined");
|
||||||
i2p::transports.CloseSession (tunnel->GetTunnelConfig ()->GetFirstHop ()->router);
|
|
||||||
delete tunnel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint ("Pending tunnel for message ", replyMsgID, " not found");
|
LogPrint ("Pending tunnel for message ", replyMsgID, " not found");
|
||||||
|
46
Tunnel.cpp
46
Tunnel.cpp
@ -217,9 +217,9 @@ namespace tunnel
|
|||||||
delete it.second;
|
delete it.second;
|
||||||
m_TransitTunnels.clear ();
|
m_TransitTunnels.clear ();
|
||||||
|
|
||||||
for (auto& it : m_PendingTunnels)
|
/*for (auto& it : m_PendingTunnels)
|
||||||
delete it.second;
|
delete it.second;
|
||||||
m_PendingTunnels.clear ();
|
m_PendingTunnels.clear ();*/
|
||||||
|
|
||||||
for (auto& it: m_Pools)
|
for (auto& it: m_Pools)
|
||||||
delete it.second;
|
delete it.second;
|
||||||
@ -246,11 +246,7 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
auto it = m_PendingTunnels.find(replyMsgID);
|
auto it = m_PendingTunnels.find(replyMsgID);
|
||||||
if (it != m_PendingTunnels.end ())
|
if (it != m_PendingTunnels.end ())
|
||||||
{
|
return it->second;
|
||||||
Tunnel * t = it->second;
|
|
||||||
m_PendingTunnels.erase (it);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,33 +368,29 @@ namespace tunnel
|
|||||||
|
|
||||||
void Tunnels::ManageTunnels ()
|
void Tunnels::ManageTunnels ()
|
||||||
{
|
{
|
||||||
// check pending tunnel. if something is still there, wipe it out
|
// check pending tunnel. delete non-successive
|
||||||
// because it wouldn't be responded anyway
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
for (auto& it : m_PendingTunnels)
|
for (auto it = m_PendingTunnels.begin (); it != m_PendingTunnels.end ();)
|
||||||
{
|
{
|
||||||
LogPrint ("Pending tunnel build request ", it.first, " has not been responded. Deleted");
|
if (it->second->GetState () == eTunnelStatePending)
|
||||||
if (it.second->GetTunnelConfig ()->GetFirstHop ()->isGateway) // outbound
|
{
|
||||||
i2p::transports.CloseSession (it.second->GetTunnelConfig ()->GetFirstHop ()->router);
|
if (ts > it->second->GetCreationTime () + TUNNEL_CREATION_TIMEOUT)
|
||||||
delete it.second;
|
{
|
||||||
|
LogPrint ("Pending tunnel build request ", it->first, " was not successive. Deleted");
|
||||||
|
delete it->second;
|
||||||
|
it = m_PendingTunnels.erase (it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
it = m_PendingTunnels.erase (it);
|
||||||
}
|
}
|
||||||
m_PendingTunnels.clear ();
|
|
||||||
|
|
||||||
ManageInboundTunnels ();
|
ManageInboundTunnels ();
|
||||||
ManageOutboundTunnels ();
|
ManageOutboundTunnels ();
|
||||||
ManageTransitTunnels ();
|
ManageTransitTunnels ();
|
||||||
ManageTunnelPools ();
|
ManageTunnelPools ();
|
||||||
|
|
||||||
/* if (!m_IsTunnelCreated)
|
|
||||||
{
|
|
||||||
InboundTunnel * inboundTunnel = CreateOneHopInboundTestTunnel ();
|
|
||||||
if (inboundTunnel)
|
|
||||||
CreateOneHopOutboundTestTunnel (inboundTunnel);
|
|
||||||
inboundTunnel = CreateTwoHopsInboundTestTunnel ();
|
|
||||||
if (inboundTunnel)
|
|
||||||
CreateTwoHopsOutboundTestTunnel (inboundTunnel);
|
|
||||||
|
|
||||||
m_IsTunnelCreated = true;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tunnels::ManageOutboundTunnels ()
|
void Tunnels::ManageOutboundTunnels ()
|
||||||
|
1
Tunnel.h
1
Tunnel.h
@ -22,6 +22,7 @@ namespace i2p
|
|||||||
namespace tunnel
|
namespace tunnel
|
||||||
{
|
{
|
||||||
const int TUNNEL_EXPIRATION_TIMEOUT = 660; // 11 minutes
|
const int TUNNEL_EXPIRATION_TIMEOUT = 660; // 11 minutes
|
||||||
|
const int TUNNEL_CREATION_TIMEOUT = 10; // 10 seconds
|
||||||
const int STANDARD_NUM_RECORDS = 5; // in VariableTunnelBuild message
|
const int STANDARD_NUM_RECORDS = 5; // in VariableTunnelBuild message
|
||||||
|
|
||||||
enum TunnelState
|
enum TunnelState
|
||||||
|
Loading…
x
Reference in New Issue
Block a user