Browse Source

request and process encrypted LeaseSet

pull/81/head
orignal 11 years ago
parent
commit
3e25759ada
  1. 2
      Garlic.cpp
  2. 16
      I2NPProtocol.cpp
  3. 2
      I2NPProtocol.h
  4. 2
      NetDb.cpp
  5. 4
      RouterContext.cpp

2
Garlic.cpp

@ -398,7 +398,7 @@ namespace garlic @@ -398,7 +398,7 @@ namespace garlic
{
case eGarlicDeliveryTypeLocal:
LogPrint ("Garlic type local");
i2p::HandleI2NPMessage (buf, len);
i2p::HandleI2NPMessage (CreateI2NPMessage (buf, len));
break;
case eGarlicDeliveryTypeDestination:
{

16
I2NPProtocol.cpp

@ -95,7 +95,8 @@ namespace i2p @@ -95,7 +95,8 @@ namespace i2p
}
I2NPMessage * CreateDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
uint32_t replyTunnelID, bool exploratory, std::set<i2p::data::IdentHash> * excludedPeers)
uint32_t replyTunnelID, bool exploratory, std::set<i2p::data::IdentHash> * excludedPeers,
bool encryption)
{
I2NPMessage * m = NewI2NPMessage ();
uint8_t * buf = m->GetPayload ();
@ -105,12 +106,13 @@ namespace i2p @@ -105,12 +106,13 @@ namespace i2p
buf += 32;
if (replyTunnelID)
{
*buf = 0x01; // set delivery flag
*buf = encryption ? 0x03: 0x01; // set delivery flag
*(uint32_t *)(buf+1) = htobe32 (replyTunnelID);
buf += 5;
}
else
{
encryption = false; // encryption can we set for tunnels only
*buf = 0; // flag
buf++;
}
@ -143,6 +145,16 @@ namespace i2p @@ -143,6 +145,16 @@ namespace i2p
buf += 2;
}
}
if (encryption)
{
// session key and tag for reply
auto& rnd = i2p::context.GetRandomNumberGenerator ();
rnd.GenerateBlock (buf, 32); // key
buf[32] = 1; // 1 tag
rnd.GenerateBlock (buf + 33, 32); // tag
i2p::garlic::routing.AddSessionKey (buf, buf + 33); // introduce new key-tag to garlic engine
buf += 65;
}
m->len += (buf - m->GetPayload ());
FillI2NPMessageHeader (m, eI2NPDatabaseLookup);
return m;

2
I2NPProtocol.h

@ -153,7 +153,7 @@ namespace tunnel @@ -153,7 +153,7 @@ namespace tunnel
I2NPMessage * CreateDeliveryStatusMsg (uint32_t msgID);
I2NPMessage * CreateDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
uint32_t replyTunnelID, bool exploratory = false,
std::set<i2p::data::IdentHash> * excludedPeers = nullptr);
std::set<i2p::data::IdentHash> * excludedPeers = nullptr, bool encryption = false);
void HandleDatabaseLookupMsg (uint8_t * buf, size_t len);
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident);

2
NetDb.cpp

@ -23,7 +23,7 @@ namespace data @@ -23,7 +23,7 @@ namespace data
const i2p::tunnel::InboundTunnel * replyTunnel)
{
I2NPMessage * msg = i2p::CreateDatabaseLookupMsg (m_Destination,
replyTunnel->GetNextIdentHash (), replyTunnel->GetNextTunnelID (), m_IsExploratory, &m_ExcludedPeers);
replyTunnel->GetNextIdentHash (), replyTunnel->GetNextTunnelID (), m_IsExploratory, &m_ExcludedPeers, m_IsLeaseSet);
if (m_IsLeaseSet) // wrap lookup message into garlic
msg = i2p::garlic::routing.WrapSingleMessage (*router, msg);
m_ExcludedPeers.insert (router->GetIdentHash ());

4
RouterContext.cpp

@ -34,9 +34,9 @@ namespace i2p @@ -34,9 +34,9 @@ namespace i2p
routerInfo.AddSSUAddress ("127.0.0.1", 17007, routerInfo.GetIdentHash ());
routerInfo.AddNTCPAddress ("127.0.0.1", 17007); // TODO:
routerInfo.SetProperty ("caps", "LR");
routerInfo.SetProperty ("coreVersion", "0.9.8.1");
routerInfo.SetProperty ("coreVersion", "0.9.11");
routerInfo.SetProperty ("netId", "2");
routerInfo.SetProperty ("router.version", "0.9.8.1");
routerInfo.SetProperty ("router.version", "0.9.11");
routerInfo.SetProperty ("start_uptime", "90m");
routerInfo.CreateBuffer ();

Loading…
Cancel
Save