mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 12:24:19 +00:00
terminate I2CP session if destroyed explicitly
This commit is contained in:
parent
ad36738f57
commit
242fb7db14
@ -89,10 +89,16 @@ namespace client
|
|||||||
m_LeaseSetExpirationTime = ls.GetExpirationTime ();
|
m_LeaseSetExpirationTime = ls.GetExpirationTime ();
|
||||||
uint8_t * leases = ls.GetLeases ();
|
uint8_t * leases = ls.GetLeases ();
|
||||||
leases[-1] = tunnels.size ();
|
leases[-1] = tunnels.size ();
|
||||||
htobe16buf (leases - 3, m_Owner->GetSessionID ());
|
|
||||||
size_t l = 2/*sessionID*/ + 1/*num leases*/ + i2p::data::LEASE_SIZE*tunnels.size ();
|
|
||||||
if (m_Owner)
|
if (m_Owner)
|
||||||
m_Owner->SendI2CPMessage (I2CP_REQUEST_VARIABLE_LEASESET_MESSAGE, leases - 3, l);
|
{
|
||||||
|
uint16_t sessionID = m_Owner->GetSessionID ();
|
||||||
|
if (sessionID != 0xFFFF)
|
||||||
|
{
|
||||||
|
htobe16buf (leases - 3, sessionID);
|
||||||
|
size_t l = 2/*sessionID*/ + 1/*num leases*/ + i2p::data::LEASE_SIZE*tunnels.size ();
|
||||||
|
m_Owner->SendI2CPMessage (I2CP_REQUEST_VARIABLE_LEASESET_MESSAGE, leases - 3, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2CPDestination::LeaseSetCreated (const uint8_t * buf, size_t len)
|
void I2CPDestination::LeaseSetCreated (const uint8_t * buf, size_t len)
|
||||||
@ -243,11 +249,7 @@ namespace client
|
|||||||
|
|
||||||
I2CPSession::~I2CPSession ()
|
I2CPSession::~I2CPSession ()
|
||||||
{
|
{
|
||||||
if (m_SendQueue)
|
Terminate ();
|
||||||
{
|
|
||||||
for (auto& it: *m_SendQueue)
|
|
||||||
delete[] boost::asio::buffer_cast<const uint8_t *>(it);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2CPSession::Start ()
|
void I2CPSession::Start ()
|
||||||
@ -358,8 +360,18 @@ namespace client
|
|||||||
m_Socket->close ();
|
m_Socket->close ();
|
||||||
m_Socket = nullptr;
|
m_Socket = nullptr;
|
||||||
}
|
}
|
||||||
m_Owner.RemoveSession (GetSessionID ());
|
if (m_SendQueue)
|
||||||
LogPrint (eLogDebug, "I2CP: session ", m_SessionID, " terminated");
|
{
|
||||||
|
for (auto& it: *m_SendQueue)
|
||||||
|
delete[] boost::asio::buffer_cast<const uint8_t *>(it);
|
||||||
|
m_SendQueue = nullptr;
|
||||||
|
}
|
||||||
|
if (m_SessionID != 0xFFFF)
|
||||||
|
{
|
||||||
|
m_Owner.RemoveSession (GetSessionID ());
|
||||||
|
LogPrint (eLogDebug, "I2CP: session ", m_SessionID, " terminated");
|
||||||
|
m_SessionID = 0xFFFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2CPSession::SendI2CPMessage (uint8_t type, const uint8_t * payload, size_t len)
|
void I2CPSession::SendI2CPMessage (uint8_t type, const uint8_t * payload, size_t len)
|
||||||
@ -555,11 +567,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
SendSessionStatusMessage (0); // destroy
|
SendSessionStatusMessage (0); // destroy
|
||||||
LogPrint (eLogDebug, "I2CP: session ", m_SessionID, " destroyed");
|
LogPrint (eLogDebug, "I2CP: session ", m_SessionID, " destroyed");
|
||||||
if (m_Destination)
|
Terminate ();
|
||||||
{
|
|
||||||
m_Destination->Stop ();
|
|
||||||
m_Destination = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2CPSession::ReconfigureSessionMessageHandler (const uint8_t * buf, size_t len)
|
void I2CPSession::ReconfigureSessionMessageHandler (const uint8_t * buf, size_t len)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user