Browse Source

detach session from destination upon termination

pull/1583/head
orignal 4 years ago
parent
commit
ad36738f57
  1. 12
      libi2pd_client/I2CP.cpp
  2. 2
      libi2pd_client/I2CP.h

12
libi2pd_client/I2CP.cpp

@ -30,6 +30,12 @@ namespace client
{ {
} }
void I2CPDestination::Stop ()
{
LeaseSetDestination::Stop ();
m_Owner = nullptr;
}
void I2CPDestination::SetEncryptionPrivateKey (const uint8_t * key) void I2CPDestination::SetEncryptionPrivateKey (const uint8_t * key)
{ {
m_Decryptor = i2p::data::PrivateKeys::CreateDecryptor (m_Identity->GetCryptoKeyType (), key); m_Decryptor = i2p::data::PrivateKeys::CreateDecryptor (m_Identity->GetCryptoKeyType (), key);
@ -72,6 +78,7 @@ namespace client
{ {
uint32_t length = bufbe32toh (buf); uint32_t length = bufbe32toh (buf);
if (length > len - 4) length = len - 4; if (length > len - 4) length = len - 4;
if (m_Owner)
m_Owner->SendMessagePayloadMessage (buf + 4, length); m_Owner->SendMessagePayloadMessage (buf + 4, length);
} }
@ -84,6 +91,7 @@ namespace client
leases[-1] = tunnels.size (); leases[-1] = tunnels.size ();
htobe16buf (leases - 3, m_Owner->GetSessionID ()); htobe16buf (leases - 3, m_Owner->GetSessionID ());
size_t l = 2/*sessionID*/ + 1/*num leases*/ + i2p::data::LEASE_SIZE*tunnels.size (); size_t l = 2/*sessionID*/ + 1/*num leases*/ + i2p::data::LEASE_SIZE*tunnels.size ();
if (m_Owner)
m_Owner->SendI2CPMessage (I2CP_REQUEST_VARIABLE_LEASESET_MESSAGE, leases - 3, l); m_Owner->SendI2CPMessage (I2CP_REQUEST_VARIABLE_LEASESET_MESSAGE, leases - 3, l);
} }
@ -119,6 +127,7 @@ namespace client
[s, msg, remote, nonce]() [s, msg, remote, nonce]()
{ {
bool sent = s->SendMsg (msg, remote); bool sent = s->SendMsg (msg, remote);
if (s->m_Owner)
s->m_Owner->SendMessageStatusMessage (nonce, sent ? eI2CPMessageStatusGuaranteedSuccess : eI2CPMessageStatusGuaranteedFailure); s->m_Owner->SendMessageStatusMessage (nonce, sent ? eI2CPMessageStatusGuaranteedSuccess : eI2CPMessageStatusGuaranteedFailure);
}); });
} }
@ -130,9 +139,10 @@ namespace client
if (ls) if (ls)
{ {
bool sent = s->SendMsg (msg, ls); bool sent = s->SendMsg (msg, ls);
if (s->m_Owner)
s->m_Owner->SendMessageStatusMessage (nonce, sent ? eI2CPMessageStatusGuaranteedSuccess : eI2CPMessageStatusGuaranteedFailure); s->m_Owner->SendMessageStatusMessage (nonce, sent ? eI2CPMessageStatusGuaranteedSuccess : eI2CPMessageStatusGuaranteedFailure);
} }
else else if (s->m_Owner)
s->m_Owner->SendMessageStatusMessage (nonce, eI2CPMessageStatusNoLeaseSet); s->m_Owner->SendMessageStatusMessage (nonce, eI2CPMessageStatusNoLeaseSet);
}); });
} }

2
libi2pd_client/I2CP.h

@ -72,6 +72,8 @@ namespace client
std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, const std::map<std::string, std::string>& params); std::shared_ptr<const i2p::data::IdentityEx> identity, bool isPublic, const std::map<std::string, std::string>& params);
~I2CPDestination () {}; ~I2CPDestination () {};
void Stop ();
void SetEncryptionPrivateKey (const uint8_t * key); void SetEncryptionPrivateKey (const uint8_t * key);
void SetEncryptionType (i2p::data::CryptoKeyType keyType) { m_EncryptionKeyType = keyType; }; void SetEncryptionType (i2p::data::CryptoKeyType keyType) { m_EncryptionKeyType = keyType; };
void SetECIESx25519EncryptionPrivateKey (const uint8_t * key); void SetECIESx25519EncryptionPrivateKey (const uint8_t * key);

Loading…
Cancel
Save