mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
request and process encrypted LeaseSet
This commit is contained in:
parent
38115b7dda
commit
3e25759ada
@ -398,7 +398,7 @@ namespace garlic
|
|||||||
{
|
{
|
||||||
case eGarlicDeliveryTypeLocal:
|
case eGarlicDeliveryTypeLocal:
|
||||||
LogPrint ("Garlic type local");
|
LogPrint ("Garlic type local");
|
||||||
i2p::HandleI2NPMessage (buf, len);
|
i2p::HandleI2NPMessage (CreateI2NPMessage (buf, len));
|
||||||
break;
|
break;
|
||||||
case eGarlicDeliveryTypeDestination:
|
case eGarlicDeliveryTypeDestination:
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,8 @@ namespace i2p
|
|||||||
}
|
}
|
||||||
|
|
||||||
I2NPMessage * CreateDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
|
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 ();
|
I2NPMessage * m = NewI2NPMessage ();
|
||||||
uint8_t * buf = m->GetPayload ();
|
uint8_t * buf = m->GetPayload ();
|
||||||
@ -105,12 +106,13 @@ namespace i2p
|
|||||||
buf += 32;
|
buf += 32;
|
||||||
if (replyTunnelID)
|
if (replyTunnelID)
|
||||||
{
|
{
|
||||||
*buf = 0x01; // set delivery flag
|
*buf = encryption ? 0x03: 0x01; // set delivery flag
|
||||||
*(uint32_t *)(buf+1) = htobe32 (replyTunnelID);
|
*(uint32_t *)(buf+1) = htobe32 (replyTunnelID);
|
||||||
buf += 5;
|
buf += 5;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
encryption = false; // encryption can we set for tunnels only
|
||||||
*buf = 0; // flag
|
*buf = 0; // flag
|
||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
@ -143,6 +145,16 @@ namespace i2p
|
|||||||
buf += 2;
|
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 ());
|
m->len += (buf - m->GetPayload ());
|
||||||
FillI2NPMessageHeader (m, eI2NPDatabaseLookup);
|
FillI2NPMessageHeader (m, eI2NPDatabaseLookup);
|
||||||
return m;
|
return m;
|
||||||
|
@ -153,7 +153,7 @@ namespace tunnel
|
|||||||
I2NPMessage * CreateDeliveryStatusMsg (uint32_t msgID);
|
I2NPMessage * CreateDeliveryStatusMsg (uint32_t msgID);
|
||||||
I2NPMessage * CreateDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
|
I2NPMessage * CreateDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
|
||||||
uint32_t replyTunnelID, bool exploratory = false,
|
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);
|
void HandleDatabaseLookupMsg (uint8_t * buf, size_t len);
|
||||||
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident);
|
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace data
|
|||||||
const i2p::tunnel::InboundTunnel * replyTunnel)
|
const i2p::tunnel::InboundTunnel * replyTunnel)
|
||||||
{
|
{
|
||||||
I2NPMessage * msg = i2p::CreateDatabaseLookupMsg (m_Destination,
|
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
|
if (m_IsLeaseSet) // wrap lookup message into garlic
|
||||||
msg = i2p::garlic::routing.WrapSingleMessage (*router, msg);
|
msg = i2p::garlic::routing.WrapSingleMessage (*router, msg);
|
||||||
m_ExcludedPeers.insert (router->GetIdentHash ());
|
m_ExcludedPeers.insert (router->GetIdentHash ());
|
||||||
|
@ -34,9 +34,9 @@ namespace i2p
|
|||||||
routerInfo.AddSSUAddress ("127.0.0.1", 17007, routerInfo.GetIdentHash ());
|
routerInfo.AddSSUAddress ("127.0.0.1", 17007, routerInfo.GetIdentHash ());
|
||||||
routerInfo.AddNTCPAddress ("127.0.0.1", 17007); // TODO:
|
routerInfo.AddNTCPAddress ("127.0.0.1", 17007); // TODO:
|
||||||
routerInfo.SetProperty ("caps", "LR");
|
routerInfo.SetProperty ("caps", "LR");
|
||||||
routerInfo.SetProperty ("coreVersion", "0.9.8.1");
|
routerInfo.SetProperty ("coreVersion", "0.9.11");
|
||||||
routerInfo.SetProperty ("netId", "2");
|
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.SetProperty ("start_uptime", "90m");
|
||||||
routerInfo.CreateBuffer ();
|
routerInfo.CreateBuffer ();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user