|
|
@ -1,5 +1,5 @@ |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, The PurpleI2P Project |
|
|
|
* Copyright (c) 2022-2023, The PurpleI2P Project |
|
|
|
* |
|
|
|
* |
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3 |
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3 |
|
|
|
* |
|
|
|
* |
|
|
@ -22,7 +22,7 @@ namespace transport |
|
|
|
RunnableServiceWithWork ("SSU2"), m_ReceiveService ("SSU2r"), |
|
|
|
RunnableServiceWithWork ("SSU2"), m_ReceiveService ("SSU2r"), |
|
|
|
m_SocketV4 (m_ReceiveService.GetService ()), m_SocketV6 (m_ReceiveService.GetService ()), |
|
|
|
m_SocketV4 (m_ReceiveService.GetService ()), m_SocketV6 (m_ReceiveService.GetService ()), |
|
|
|
m_AddressV4 (boost::asio::ip::address_v4()), m_AddressV6 (boost::asio::ip::address_v6()), |
|
|
|
m_AddressV4 (boost::asio::ip::address_v4()), m_AddressV6 (boost::asio::ip::address_v6()), |
|
|
|
m_TerminationTimer (GetService ()), m_ResendTimer (GetService ()), |
|
|
|
m_TerminationTimer (GetService ()), m_CleanupTimer (GetService ()), m_ResendTimer (GetService ()), |
|
|
|
m_IntroducersUpdateTimer (GetService ()), m_IntroducersUpdateTimerV6 (GetService ()), |
|
|
|
m_IntroducersUpdateTimer (GetService ()), m_IntroducersUpdateTimerV6 (GetService ()), |
|
|
|
m_IsPublished (true), m_IsSyncClockFromPeers (true), m_IsThroughProxy (false) |
|
|
|
m_IsPublished (true), m_IsSyncClockFromPeers (true), m_IsThroughProxy (false) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -109,6 +109,7 @@ namespace transport |
|
|
|
m_ReceiveService.Start (); |
|
|
|
m_ReceiveService.Start (); |
|
|
|
} |
|
|
|
} |
|
|
|
ScheduleTermination (); |
|
|
|
ScheduleTermination (); |
|
|
|
|
|
|
|
ScheduleCleanup (); |
|
|
|
ScheduleResend (false); |
|
|
|
ScheduleResend (false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -118,6 +119,7 @@ namespace transport |
|
|
|
if (IsRunning ()) |
|
|
|
if (IsRunning ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_TerminationTimer.cancel (); |
|
|
|
m_TerminationTimer.cancel (); |
|
|
|
|
|
|
|
m_CleanupTimer.cancel (); |
|
|
|
m_ResendTimer.cancel (); |
|
|
|
m_ResendTimer.cancel (); |
|
|
|
m_IntroducersUpdateTimer.cancel (); |
|
|
|
m_IntroducersUpdateTimer.cancel (); |
|
|
|
m_IntroducersUpdateTimerV6.cancel (); |
|
|
|
m_IntroducersUpdateTimerV6.cancel (); |
|
|
@ -807,6 +809,22 @@ namespace transport |
|
|
|
it++; |
|
|
|
it++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ScheduleTermination (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SSU2Server::ScheduleCleanup () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_CleanupTimer.expires_from_now (boost::posix_time::seconds(SSU2_CLEANUP_INTERVAL)); |
|
|
|
|
|
|
|
m_CleanupTimer.async_wait (std::bind (&SSU2Server::HandleCleanupTimer, |
|
|
|
|
|
|
|
this, std::placeholders::_1)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SSU2Server::HandleCleanupTimer (const boost::system::error_code& ecode) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (ecode != boost::asio::error::operation_aborted) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
for (auto it = m_Relays.begin (); it != m_Relays.begin ();) |
|
|
|
for (auto it = m_Relays.begin (); it != m_Relays.begin ();) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (it->second && it->second->GetState () == eSSU2SessionStateTerminated) |
|
|
|
if (it->second && it->second->GetState () == eSSU2SessionStateTerminated) |
|
|
@ -830,13 +848,14 @@ namespace transport |
|
|
|
else |
|
|
|
else |
|
|
|
it++; |
|
|
|
it++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_PacketsPool.CleanUpMt (); |
|
|
|
m_PacketsPool.CleanUpMt (); |
|
|
|
m_SentPacketsPool.CleanUp (); |
|
|
|
m_SentPacketsPool.CleanUp (); |
|
|
|
ScheduleTermination (); |
|
|
|
m_FragmentsPool.CleanUp (); |
|
|
|
} |
|
|
|
ScheduleCleanup (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSU2Server::ScheduleResend (bool more) |
|
|
|
void SSU2Server::ScheduleResend (bool more) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_ResendTimer.expires_from_now (boost::posix_time::milliseconds (more ? SSU2_RESEND_CHECK_MORE_TIMEOUT : |
|
|
|
m_ResendTimer.expires_from_now (boost::posix_time::milliseconds (more ? SSU2_RESEND_CHECK_MORE_TIMEOUT : |
|
|
|