|
|
@ -148,7 +148,7 @@ namespace garlic
|
|
|
|
size_t GarlicRoutingSession::CreateAESBlock (uint8_t * buf, const I2NPMessage * msg)
|
|
|
|
size_t GarlicRoutingSession::CreateAESBlock (uint8_t * buf, const I2NPMessage * msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t blockSize = 0;
|
|
|
|
size_t blockSize = 0;
|
|
|
|
bool createNewTags = m_Owner && ((int)m_SessionTags.size () <= m_NumTags/2);
|
|
|
|
bool createNewTags = m_Owner && m_NumTags && ((int)m_SessionTags.size () <= m_NumTags/2);
|
|
|
|
UnconfirmedTags * newTags = createNewTags ? GenerateSessionTags () : nullptr;
|
|
|
|
UnconfirmedTags * newTags = createNewTags ? GenerateSessionTags () : nullptr;
|
|
|
|
*(uint16_t *)buf = newTags ? htobe16 (newTags->numTags) : 0; // tag count
|
|
|
|
*(uint16_t *)buf = newTags ? htobe16 (newTags->numTags) : 0; // tag count
|
|
|
|
blockSize += 2;
|
|
|
|
blockSize += 2;
|
|
|
@ -469,8 +469,16 @@ namespace garlic
|
|
|
|
I2NPMessage * GarlicDestination::WrapMessage (const i2p::data::RoutingDestination& destination,
|
|
|
|
I2NPMessage * GarlicDestination::WrapMessage (const i2p::data::RoutingDestination& destination,
|
|
|
|
I2NPMessage * msg, bool attachLeaseSet)
|
|
|
|
I2NPMessage * msg, bool attachLeaseSet)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto session = GetRoutingSession (destination, attachLeaseSet ? 32 : 0); // don't use tag if no LeaseSet
|
|
|
|
if (attachLeaseSet) // we should maintain this session
|
|
|
|
return session->WrapSingleMessage (msg);
|
|
|
|
{
|
|
|
|
|
|
|
|
auto session = GetRoutingSession (destination, 32); // 32 tags by default
|
|
|
|
|
|
|
|
return session->WrapSingleMessage (msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else // one time session
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
GarlicRoutingSession session (this, &destination, 0); // don't use tag if no LeaseSet
|
|
|
|
|
|
|
|
return session.WrapSingleMessage (msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GarlicRoutingSession * GarlicDestination::GetRoutingSession (
|
|
|
|
GarlicRoutingSession * GarlicDestination::GetRoutingSession (
|
|
|
@ -488,7 +496,7 @@ namespace garlic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return session;
|
|
|
|
return session;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GarlicDestination::DeliveryStatusSent (GarlicRoutingSession * session, uint32_t msgID)
|
|
|
|
void GarlicDestination::DeliveryStatusSent (GarlicRoutingSession * session, uint32_t msgID)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_CreatedSessions[msgID] = session;
|
|
|
|
m_CreatedSessions[msgID] = session;
|
|
|
|