mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-04-26 02:12:29 +00:00
close all session and regenerate static keys for new dest
This commit is contained in:
@@ -1136,6 +1136,23 @@ namespace client
|
||||
LogPrint(eLogDebug, "Destination: -> Stopping done");
|
||||
}
|
||||
|
||||
void ClientDestination::SetPrivateKeys (const i2p::data::PrivateKeys& keys)
|
||||
{
|
||||
if (m_StreamingDestination) m_StreamingDestination->Stop (); // close all streams
|
||||
CleanUp (); // delete sessions and tags
|
||||
auto pool = GetTunnelPool ();
|
||||
if (pool) pool->DetachTunnels ();
|
||||
m_Keys = keys;
|
||||
// update static keys
|
||||
for (auto it: m_EncryptionKeys)
|
||||
if (it.second)
|
||||
{
|
||||
it.second->GenerateKeys ();
|
||||
it.second->CreateDecryptor ();
|
||||
}
|
||||
if (m_StreamingDestination) m_StreamingDestination->Start ();
|
||||
}
|
||||
|
||||
void ClientDestination::HandleDataMessage (const uint8_t * buf, size_t len,
|
||||
i2p::garlic::ECIESX25519AEADRatchetSession * from)
|
||||
{
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace client
|
||||
void Stop () override;
|
||||
|
||||
const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };
|
||||
void SetPrivateKeys (const i2p::data::PrivateKeys& keys) { m_Keys = keys; };
|
||||
void SetPrivateKeys (const i2p::data::PrivateKeys& keys);
|
||||
void Sign (const uint8_t * buf, int len, uint8_t * signature) const { m_Keys.Sign (buf, len, signature); };
|
||||
|
||||
// ref counter
|
||||
|
||||
@@ -84,14 +84,9 @@ namespace client
|
||||
auto ident = m_LocalDestination->GetPrivateKeys ().GetPublic ();
|
||||
if (ident)
|
||||
{
|
||||
auto streamingDest = m_LocalDestination->GetStreamingDestination ();
|
||||
if (streamingDest) streamingDest->Stop ();
|
||||
auto pool = m_LocalDestination->GetTunnelPool ();
|
||||
if (pool) pool->DetachTunnels ();
|
||||
m_LocalDestination->SetPrivateKeys (i2p::data::PrivateKeys::CreateRandomKeys (
|
||||
ident->GetSigningKeyType (), ident->GetCryptoKeyType (), true));
|
||||
i2p::client::context.ReplaceLocalDestinationHash (ident->GetIdentHash (), m_LocalDestination->GetIdentHash ());
|
||||
if (streamingDest) streamingDest->Start ();
|
||||
}
|
||||
}
|
||||
ScheduleIdleCheckTimer ();
|
||||
|
||||
Reference in New Issue
Block a user