mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
moved garlic decryption to streaming thread
This commit is contained in:
parent
911ad52989
commit
375fceb530
@ -187,8 +187,7 @@ namespace stream
|
||||
if (uncompressed->len <= MAX_PACKET_SIZE)
|
||||
{
|
||||
decompressor.Get (uncompressed->buf, uncompressed->len);
|
||||
// then forward to streaming thread
|
||||
m_Service.post (boost::bind (&StreamingDestination::HandleNextPacket, this, uncompressed));
|
||||
HandleNextPacket (uncompressed);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -232,6 +231,16 @@ namespace stream
|
||||
i2p::data::netdb.PublishLeaseSet (m_LeaseSet, m_Pool);
|
||||
}
|
||||
|
||||
void StreamingDestination::ProcessGarlicMessage (I2NPMessage * msg)
|
||||
{
|
||||
m_Service.post (boost::bind (&StreamingDestination::HandleGarlicMessage, this, msg));
|
||||
}
|
||||
|
||||
void StreamingDestination::ProcessDeliveryStatusMessage (I2NPMessage * msg)
|
||||
{
|
||||
m_Service.post (boost::bind (&StreamingDestination::HandleDeliveryStatusMessage, this, msg));
|
||||
}
|
||||
|
||||
StreamingDestinations destinations;
|
||||
void StreamingDestinations::Start ()
|
||||
{
|
||||
|
@ -41,11 +41,15 @@ namespace stream
|
||||
const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };
|
||||
const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; };
|
||||
const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionPublicKey; };
|
||||
void SetLeaseSetUpdated ();
|
||||
|
||||
// implements GarlicDestination
|
||||
const i2p::data::LeaseSet * GetLeaseSet ();
|
||||
|
||||
// override GarlicDestination
|
||||
void ProcessGarlicMessage (I2NPMessage * msg);
|
||||
void ProcessDeliveryStatusMessage (I2NPMessage * msg);
|
||||
void SetLeaseSetUpdated ();
|
||||
|
||||
private:
|
||||
|
||||
Stream * CreateNewIncomingStream ();
|
||||
|
15
Garlic.cpp
15
Garlic.cpp
@ -454,7 +454,6 @@ namespace garlic
|
||||
|
||||
void GarlicDestination::DeliveryStatusSent (GarlicRoutingSession * session, uint32_t msgID)
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_CreatedSessionsMutex);
|
||||
m_CreatedSessions[msgID] = session;
|
||||
}
|
||||
|
||||
@ -463,7 +462,6 @@ namespace garlic
|
||||
I2NPDeliveryStatusMsg * deliveryStatus = (I2NPDeliveryStatusMsg *)msg->GetPayload ();
|
||||
uint32_t msgID = be32toh (deliveryStatus->msgID);
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_CreatedSessionsMutex);
|
||||
auto it = m_CreatedSessions.find (msgID);
|
||||
if (it != m_CreatedSessions.end ())
|
||||
{
|
||||
@ -477,9 +475,20 @@ namespace garlic
|
||||
|
||||
void GarlicDestination::SetLeaseSetUpdated ()
|
||||
{
|
||||
std::unique_lock<std::mutex> l(m_CreatedSessionsMutex);
|
||||
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||
for (auto it: m_Sessions)
|
||||
it.second->SetLeaseSetUpdated ();
|
||||
}
|
||||
|
||||
void GarlicDestination::ProcessGarlicMessage (I2NPMessage * msg)
|
||||
{
|
||||
HandleGarlicMessage (msg);
|
||||
}
|
||||
|
||||
void GarlicDestination::ProcessDeliveryStatusMessage (I2NPMessage * msg)
|
||||
{
|
||||
HandleDeliveryStatusMessage (msg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
14
Garlic.h
14
Garlic.h
@ -92,14 +92,19 @@ namespace garlic
|
||||
I2NPMessage * msg, bool attachLeaseSet = false);
|
||||
|
||||
void AddSessionKey (const uint8_t * key, const uint8_t * tag); // one tag
|
||||
void HandleGarlicMessage (I2NPMessage * msg);
|
||||
|
||||
void DeliveryStatusSent (GarlicRoutingSession * session, uint32_t msgID);
|
||||
void HandleDeliveryStatusMessage (I2NPMessage * msg);
|
||||
|
||||
virtual void ProcessGarlicMessage (I2NPMessage * msg);
|
||||
virtual void ProcessDeliveryStatusMessage (I2NPMessage * msg);
|
||||
virtual void SetLeaseSetUpdated ();
|
||||
|
||||
virtual const i2p::data::LeaseSet * GetLeaseSet () = 0; // TODO
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void HandleGarlicMessage (I2NPMessage * msg);
|
||||
void HandleDeliveryStatusMessage (I2NPMessage * msg);
|
||||
|
||||
private:
|
||||
|
||||
void HandleAESBlock (uint8_t * buf, size_t len, std::shared_ptr<i2p::crypto::CBCDecryption> decryption,
|
||||
@ -114,7 +119,6 @@ namespace garlic
|
||||
// incoming
|
||||
std::map<SessionTag, std::shared_ptr<i2p::crypto::CBCDecryption>> m_Tags;
|
||||
// DeliveryStatus
|
||||
std::mutex m_CreatedSessionsMutex;
|
||||
std::map<uint32_t, GarlicRoutingSession *> m_CreatedSessions; // msgID -> session
|
||||
};
|
||||
}
|
||||
|
@ -562,9 +562,9 @@ namespace i2p
|
||||
case eI2NPGarlic:
|
||||
LogPrint ("Garlic");
|
||||
if (msg->from && msg->from->GetTunnelPool ())
|
||||
msg->from->GetTunnelPool ()->GetGarlicDestination ().HandleGarlicMessage (msg);
|
||||
msg->from->GetTunnelPool ()->GetGarlicDestination ().ProcessGarlicMessage (msg);
|
||||
else
|
||||
i2p::context.HandleGarlicMessage (msg);
|
||||
i2p::context.ProcessGarlicMessage (msg);
|
||||
break;
|
||||
case eI2NPDatabaseStore:
|
||||
case eI2NPDatabaseSearchReply:
|
||||
@ -577,7 +577,7 @@ namespace i2p
|
||||
if (msg->from && msg->from->GetTunnelPool ())
|
||||
msg->from->GetTunnelPool ()->ProcessDeliveryStatus (msg);
|
||||
else
|
||||
i2p::context.HandleDeliveryStatusMessage (msg);
|
||||
i2p::context.ProcessDeliveryStatusMessage (msg);
|
||||
break;
|
||||
default:
|
||||
HandleI2NPMessage (msg->GetBuffer (), msg->GetLength ());
|
||||
|
@ -221,7 +221,7 @@ namespace tunnel
|
||||
DeleteI2NPMessage (msg);
|
||||
}
|
||||
else
|
||||
m_LocalDestination.HandleDeliveryStatusMessage (msg);
|
||||
m_LocalDestination.ProcessDeliveryStatusMessage (msg);
|
||||
}
|
||||
|
||||
const i2p::data::RouterInfo * TunnelPool::SelectNextHop (const i2p::data::RouterInfo * prevHop) const
|
||||
|
Loading…
Reference in New Issue
Block a user