mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
SSU timeout
This commit is contained in:
parent
3c6793745b
commit
c30dd2639a
@ -519,7 +519,7 @@ namespace ntcp
|
|||||||
void NTCPSession::ScheduleTermination ()
|
void NTCPSession::ScheduleTermination ()
|
||||||
{
|
{
|
||||||
m_TerminationTimer.cancel ();
|
m_TerminationTimer.cancel ();
|
||||||
m_TerminationTimer.expires_from_now (boost::posix_time::seconds(TERMINATION_TIMEOUT));
|
m_TerminationTimer.expires_from_now (boost::posix_time::seconds(NTCP_TERMINATION_TIMEOUT));
|
||||||
m_TerminationTimer.async_wait (boost::bind (&NTCPSession::HandleTerminationTimer,
|
m_TerminationTimer.async_wait (boost::bind (&NTCPSession::HandleTerminationTimer,
|
||||||
this, boost::asio::placeholders::error));
|
this, boost::asio::placeholders::error));
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ namespace ntcp
|
|||||||
{
|
{
|
||||||
if (ecode != boost::asio::error::operation_aborted)
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
{
|
{
|
||||||
LogPrint ("No activity fo ", TERMINATION_TIMEOUT, " seconds");
|
LogPrint ("No activity fo ", NTCP_TERMINATION_TIMEOUT, " seconds");
|
||||||
m_Socket.close ();
|
m_Socket.close ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ namespace ntcp
|
|||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
const int TERMINATION_TIMEOUT = 120; // 2 minutes
|
const int NTCP_TERMINATION_TIMEOUT = 120; // 2 minutes
|
||||||
class NTCPSession
|
class NTCPSession
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
21
SSU.cpp
21
SSU.cpp
@ -546,6 +546,7 @@ namespace ssu
|
|||||||
}
|
}
|
||||||
if (m_PeerTest)
|
if (m_PeerTest)
|
||||||
SendPeerTest ();
|
SendPeerTest ();
|
||||||
|
ScheduleTermination ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::Failed ()
|
void SSUSession::Failed ()
|
||||||
@ -557,7 +558,24 @@ namespace ssu
|
|||||||
m_Server.DeleteSession (this); // delete this
|
m_Server.DeleteSession (this); // delete this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SSUSession::ScheduleTermination ()
|
||||||
|
{
|
||||||
|
m_Timer.cancel ();
|
||||||
|
m_Timer.expires_from_now (boost::posix_time::seconds(SSU_TERMINATION_TIMEOUT));
|
||||||
|
m_Timer.async_wait (boost::bind (&SSUSession::HandleTerminationTimer,
|
||||||
|
this, boost::asio::placeholders::error));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSUSession::HandleTerminationTimer (const boost::system::error_code& ecode)
|
||||||
|
{
|
||||||
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
|
{
|
||||||
|
LogPrint ("SSU no activity fo ", SSU_TERMINATION_TIMEOUT, " seconds");
|
||||||
|
Close ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const uint8_t * SSUSession::GetIntroKey () const
|
const uint8_t * SSUSession::GetIntroKey () const
|
||||||
{
|
{
|
||||||
if (m_RemoteRouter)
|
if (m_RemoteRouter)
|
||||||
@ -587,6 +605,7 @@ namespace ssu
|
|||||||
|
|
||||||
void SSUSession::ProcessData (uint8_t * buf, size_t len)
|
void SSUSession::ProcessData (uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
|
ScheduleTermination ();
|
||||||
//uint8_t * start = buf;
|
//uint8_t * start = buf;
|
||||||
uint8_t flag = *buf;
|
uint8_t flag = *buf;
|
||||||
buf++;
|
buf++;
|
||||||
|
4
SSU.h
4
SSU.h
@ -30,6 +30,7 @@ namespace ssu
|
|||||||
|
|
||||||
const size_t SSU_MTU = 1484;
|
const size_t SSU_MTU = 1484;
|
||||||
const int SSU_CONNECT_TIMEOUT = 5; // 5 seconds
|
const int SSU_CONNECT_TIMEOUT = 5; // 5 seconds
|
||||||
|
const int SSU_TERMINATION_TIMEOUT = 270; // 4.5 minutes
|
||||||
|
|
||||||
// payload types (4 bits)
|
// payload types (4 bits)
|
||||||
const uint8_t PAYLOAD_TYPE_SESSION_REQUEST = 0;
|
const uint8_t PAYLOAD_TYPE_SESSION_REQUEST = 0;
|
||||||
@ -115,6 +116,9 @@ namespace ssu
|
|||||||
bool Validate (uint8_t * buf, size_t len, const uint8_t * macKey);
|
bool Validate (uint8_t * buf, size_t len, const uint8_t * macKey);
|
||||||
const uint8_t * GetIntroKey () const;
|
const uint8_t * GetIntroKey () const;
|
||||||
|
|
||||||
|
void ScheduleTermination ();
|
||||||
|
void HandleTerminationTimer (const boost::system::error_code& ecode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
SSUServer& m_Server;
|
SSUServer& m_Server;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user