diff --git a/Garlic.cpp b/Garlic.cpp index 17e5e5ec..df7bb1dc 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -398,7 +398,7 @@ namespace garlic { case eGarlicDeliveryTypeLocal: LogPrint ("Garlic type local"); - i2p::HandleI2NPMessage (buf, len); + i2p::HandleI2NPMessage (CreateI2NPMessage (buf, len)); break; case eGarlicDeliveryTypeDestination: { diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index aeedfea8..9367220a 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -95,7 +95,8 @@ namespace i2p } I2NPMessage * CreateDatabaseLookupMsg (const uint8_t * key, const uint8_t * from, - uint32_t replyTunnelID, bool exploratory, std::set * excludedPeers) + uint32_t replyTunnelID, bool exploratory, std::set * excludedPeers, + bool encryption) { I2NPMessage * m = NewI2NPMessage (); uint8_t * buf = m->GetPayload (); @@ -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 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; diff --git a/I2NPProtocol.h b/I2NPProtocol.h index 42eb85f6..7fa09d0f 100644 --- a/I2NPProtocol.h +++ b/I2NPProtocol.h @@ -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 * excludedPeers = nullptr); + std::set * excludedPeers = nullptr, bool encryption = false); void HandleDatabaseLookupMsg (uint8_t * buf, size_t len); I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident); diff --git a/NetDb.cpp b/NetDb.cpp index 3c240522..dd795577 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -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 ()); diff --git a/RouterContext.cpp b/RouterContext.cpp index bde075ad..727781f5 100644 --- a/RouterContext.cpp +++ b/RouterContext.cpp @@ -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 ();