|
|
@ -396,6 +396,8 @@ namespace tunnel |
|
|
|
void Tunnels::ManageOutboundTunnels () |
|
|
|
void Tunnels::ManageOutboundTunnels () |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex); |
|
|
|
for (auto it = m_OutboundTunnels.begin (); it != m_OutboundTunnels.end ();) |
|
|
|
for (auto it = m_OutboundTunnels.begin (); it != m_OutboundTunnels.end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ts > (*it)->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) |
|
|
|
if (ts > (*it)->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) |
|
|
@ -414,6 +416,7 @@ namespace tunnel |
|
|
|
it++; |
|
|
|
it++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (m_OutboundTunnels.size () < 5) |
|
|
|
if (m_OutboundTunnels.size () < 5) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -433,6 +436,8 @@ namespace tunnel |
|
|
|
void Tunnels::ManageInboundTunnels () |
|
|
|
void Tunnels::ManageInboundTunnels () |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex); |
|
|
|
for (auto it = m_InboundTunnels.begin (); it != m_InboundTunnels.end ();) |
|
|
|
for (auto it = m_InboundTunnels.begin (); it != m_InboundTunnels.end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ts > it->second->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) |
|
|
|
if (ts > it->second->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) |
|
|
@ -451,6 +456,7 @@ namespace tunnel |
|
|
|
it++; |
|
|
|
it++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (m_InboundTunnels.empty ()) |
|
|
|
if (m_InboundTunnels.empty ()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -516,6 +522,7 @@ namespace tunnel |
|
|
|
|
|
|
|
|
|
|
|
void Tunnels::AddOutboundTunnel (OutboundTunnel * newTunnel) |
|
|
|
void Tunnels::AddOutboundTunnel (OutboundTunnel * newTunnel) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex); |
|
|
|
m_OutboundTunnels.push_back (newTunnel); |
|
|
|
m_OutboundTunnels.push_back (newTunnel); |
|
|
|
auto pool = newTunnel->GetTunnelPool (); |
|
|
|
auto pool = newTunnel->GetTunnelPool (); |
|
|
|
if (pool) |
|
|
|
if (pool) |
|
|
@ -524,6 +531,7 @@ namespace tunnel |
|
|
|
|
|
|
|
|
|
|
|
void Tunnels::AddInboundTunnel (InboundTunnel * newTunnel) |
|
|
|
void Tunnels::AddInboundTunnel (InboundTunnel * newTunnel) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex); |
|
|
|
m_InboundTunnels[newTunnel->GetTunnelID ()] = newTunnel; |
|
|
|
m_InboundTunnels[newTunnel->GetTunnelID ()] = newTunnel; |
|
|
|
auto pool = newTunnel->GetTunnelPool (); |
|
|
|
auto pool = newTunnel->GetTunnelPool (); |
|
|
|
if (!pool) |
|
|
|
if (!pool) |
|
|
|