Browse Source

add single tag from destination's tread

pull/115/head
orignal 10 years ago
parent
commit
b7d1b74ffa
  1. 20
      Destination.cpp
  2. 1
      Destination.h
  3. 10
      Garlic.cpp
  4. 1
      Garlic.h
  5. 2
      I2NPProtocol.cpp

20
Destination.cpp

@ -163,6 +163,26 @@ namespace client
} }
} }
bool ClientDestination::SubmitSessionKey (const uint8_t * key, const uint8_t * tag)
{
if (m_Service)
{
uint8_t k[32], t[32];
memcpy (k, key, 32);
memcpy (t, tag, 32);
m_Service->post ([this,k,t](void)
{
this->AddSessionKey (k, t);
});
return true;
}
else
{
LogPrint (eLogWarning, "Destination's thread is not running");
return false;
}
}
void ClientDestination::ProcessGarlicMessage (I2NPMessage * msg) void ClientDestination::ProcessGarlicMessage (I2NPMessage * msg)
{ {
if (m_Service) if (m_Service)

1
Destination.h

@ -65,6 +65,7 @@ namespace client
void HandleI2NPMessage (const uint8_t * buf, size_t len, i2p::tunnel::InboundTunnel * from); void HandleI2NPMessage (const uint8_t * buf, size_t len, i2p::tunnel::InboundTunnel * from);
// override GarlicDestination // override GarlicDestination
bool SubmitSessionKey (const uint8_t * key, const uint8_t * tag);
void ProcessGarlicMessage (I2NPMessage * msg); void ProcessGarlicMessage (I2NPMessage * msg);
void ProcessDeliveryStatusMessage (I2NPMessage * msg); void ProcessDeliveryStatusMessage (I2NPMessage * msg);
void SetLeaseSetUpdated (); void SetLeaseSetUpdated ();

10
Garlic.cpp

@ -322,6 +322,12 @@ namespace garlic
} }
} }
bool GarlicDestination::SubmitSessionKey (const uint8_t * key, const uint8_t * tag)
{
AddSessionKey (key, tag);
return true;
}
void GarlicDestination::HandleGarlicMessage (I2NPMessage * msg) void GarlicDestination::HandleGarlicMessage (I2NPMessage * msg)
{ {
uint8_t * buf = msg->GetPayload (); uint8_t * buf = msg->GetPayload ();
@ -389,8 +395,8 @@ namespace garlic
{ {
if (tagCount*32 > len) if (tagCount*32 > len)
{ {
LogPrint (eLogWarning, "Tag count ", tagCount, " exceeds length ", len); LogPrint (eLogError, "Tag count ", tagCount, " exceeds length ", len);
tagCount = len/32; return ;
} }
uint32_t ts = i2p::util::GetSecondsSinceEpoch (); uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
for (int i = 0; i < tagCount; i++) for (int i = 0; i < tagCount; i++)

1
Garlic.h

@ -110,6 +110,7 @@ namespace garlic
I2NPMessage * msg, bool attachLeaseSet = false); I2NPMessage * msg, bool attachLeaseSet = false);
void AddSessionKey (const uint8_t * key, const uint8_t * tag); // one tag void AddSessionKey (const uint8_t * key, const uint8_t * tag); // one tag
virtual bool SubmitSessionKey (const uint8_t * key, const uint8_t * tag); // from different thread
void DeliveryStatusSent (GarlicRoutingSession * session, uint32_t msgID); void DeliveryStatusSent (GarlicRoutingSession * session, uint32_t msgID);
virtual void ProcessGarlicMessage (I2NPMessage * msg); virtual void ProcessGarlicMessage (I2NPMessage * msg);

2
I2NPProtocol.cpp

@ -161,7 +161,7 @@ namespace i2p
buf[32] = 1; // 1 tag buf[32] = 1; // 1 tag
rnd.GenerateBlock (buf + 33, 32); // tag rnd.GenerateBlock (buf + 33, 32); // tag
if (pool) if (pool)
pool->GetGarlicDestination ().AddSessionKey (buf, buf + 33); // introduce new key-tag to garlic engine pool->GetGarlicDestination ().SubmitSessionKey (buf, buf + 33); // introduce new key-tag to garlic engine
else else
LogPrint ("Destination for encrypteed reply not specified"); LogPrint ("Destination for encrypteed reply not specified");
buf += 65; buf += 65;

Loading…
Cancel
Save