mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
specify reply token for RIs DatabaseStore
This commit is contained in:
parent
7e45233c7d
commit
679faf5149
@ -205,7 +205,7 @@ namespace i2p
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::RouterInfo * router)
|
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::RouterInfo * router, uint32_t replyToken)
|
||||||
{
|
{
|
||||||
if (!router) // we send own RouterInfo
|
if (!router) // we send own RouterInfo
|
||||||
router = &context.GetRouterInfo ();
|
router = &context.GetRouterInfo ();
|
||||||
@ -214,19 +214,27 @@ namespace i2p
|
|||||||
uint8_t * payload = m->GetPayload ();
|
uint8_t * payload = m->GetPayload ();
|
||||||
|
|
||||||
memcpy (payload + DATABASE_STORE_KEY_OFFSET, router->GetIdentHash (), 32);
|
memcpy (payload + DATABASE_STORE_KEY_OFFSET, router->GetIdentHash (), 32);
|
||||||
payload[DATABASE_STORE_TYPE_OFFSET] = 0;
|
payload[DATABASE_STORE_TYPE_OFFSET] = 0; // RouterInfo
|
||||||
htobe32buf (payload + DATABASE_STORE_REPLY_TOKEN_OFFSET, 0);
|
htobe32buf (payload + DATABASE_STORE_REPLY_TOKEN_OFFSET, replyToken);
|
||||||
|
uint8_t * buf = payload + DATABASE_STORE_HEADER_SIZE;
|
||||||
|
if (replyToken)
|
||||||
|
{
|
||||||
|
memset (buf, 0, 4); // zero tunnelID means direct reply
|
||||||
|
buf += 4;
|
||||||
|
memcpy (buf, router->GetIdentHash (), 32);
|
||||||
|
buf += 32;
|
||||||
|
}
|
||||||
|
|
||||||
CryptoPP::Gzip compressor;
|
CryptoPP::Gzip compressor;
|
||||||
compressor.Put (router->GetBuffer (), router->GetBufferLen ());
|
compressor.Put (router->GetBuffer (), router->GetBufferLen ());
|
||||||
compressor.MessageEnd();
|
compressor.MessageEnd();
|
||||||
auto size = compressor.MaxRetrievable ();
|
auto size = compressor.MaxRetrievable ();
|
||||||
uint8_t * buf = payload + DATABASE_STORE_HEADER_SIZE;
|
|
||||||
htobe16buf (buf, size); // size
|
htobe16buf (buf, size); // size
|
||||||
buf += 2;
|
buf += 2;
|
||||||
// TODO: check if size doesn't exceed buffer
|
// TODO: check if size doesn't exceed buffer
|
||||||
compressor.Get (buf, size);
|
compressor.Get (buf, size);
|
||||||
m->len += DATABASE_STORE_HEADER_SIZE + 2 + size; // payload size
|
buf += size;
|
||||||
|
m->len += (buf - payload); // payload size
|
||||||
FillI2NPMessageHeader (m, eI2NPDatabaseStore);
|
FillI2NPMessageHeader (m, eI2NPDatabaseStore);
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
@ -196,7 +196,7 @@ namespace tunnel
|
|||||||
const i2p::tunnel::InboundTunnel * replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag);
|
const i2p::tunnel::InboundTunnel * replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag);
|
||||||
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, const i2p::data::RouterInfo * floodfill);
|
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, const i2p::data::RouterInfo * floodfill);
|
||||||
|
|
||||||
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::RouterInfo * router = nullptr);
|
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::RouterInfo * router = nullptr, uint32_t replyToken = 0);
|
||||||
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::LeaseSet * leaseSet, uint32_t replyToken = 0);
|
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::LeaseSet * leaseSet, uint32_t replyToken = 0);
|
||||||
|
|
||||||
bool HandleBuildRequestRecords (int num, uint8_t * records, uint8_t * clearText);
|
bool HandleBuildRequestRecords (int num, uint8_t * records, uint8_t * clearText);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user