mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
Populate router's buffer before sending RouterInfo block
This commit is contained in:
parent
0c64f278d7
commit
e8c58270c4
|
@ -977,8 +977,7 @@ namespace data
|
|||
if (router)
|
||||
{
|
||||
LogPrint (eLogDebug, "NetDb: Requested RouterInfo ", key, " found");
|
||||
if (!router->GetBuffer ())
|
||||
router->LoadBuffer (m_Storage.Path (router->GetIdentHashBase64 ()));
|
||||
PopulateRouterInfoBuffer (router);
|
||||
if (router->GetBuffer ())
|
||||
replyMsg = CreateDatabaseStoreMsg (router);
|
||||
}
|
||||
|
@ -1433,5 +1432,11 @@ namespace data
|
|||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void NetDb::PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r)
|
||||
{
|
||||
if (!r || r->GetBuffer ()) return;
|
||||
r->LoadBuffer (m_Storage.Path (r->GetIdentHashBase64 ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ namespace data
|
|||
|
||||
void ClearRouterInfos () { m_RouterInfos.clear (); };
|
||||
std::shared_ptr<RouterInfo::Buffer> NewRouterInfoBuffer () { return m_RouterInfoBuffersPool.AcquireSharedMt (); };
|
||||
void PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r);
|
||||
|
||||
uint32_t GetPublishReplyToken () const { return m_PublishReplyToken; };
|
||||
|
||||
|
|
|
@ -1262,6 +1262,7 @@ namespace transport
|
|||
|
||||
// send relay intro to Charlie
|
||||
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ()); // Alice's RI
|
||||
if (r) i2p::data::netdb.PopulateRouterInfoBuffer (r);
|
||||
uint8_t payload[SSU2_MAX_PAYLOAD_SIZE];
|
||||
size_t payloadSize = r ? CreateRouterInfoBlock (payload, SSU2_MAX_PAYLOAD_SIZE - len - 32, r) : 0;
|
||||
if (!payloadSize && r)
|
||||
|
@ -1370,6 +1371,7 @@ namespace transport
|
|||
uint8_t payload[SSU2_MAX_PAYLOAD_SIZE];
|
||||
// Alice's RouterInfo
|
||||
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ());
|
||||
if (r) i2p::data::netdb.PopulateRouterInfoBuffer (r);
|
||||
size_t payloadSize = r ? CreateRouterInfoBlock (payload, SSU2_MAX_PAYLOAD_SIZE - len - 32, r) : 0;
|
||||
if (!payloadSize && r)
|
||||
session->SendFragmentedMessage (CreateDatabaseStoreMsg (r));
|
||||
|
@ -1458,6 +1460,7 @@ namespace transport
|
|||
uint8_t payload[SSU2_MAX_PAYLOAD_SIZE];
|
||||
// Charlie's RouterInfo
|
||||
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ());
|
||||
if (r) i2p::data::netdb.PopulateRouterInfoBuffer (r);
|
||||
size_t payloadSize = r ? CreateRouterInfoBlock (payload, SSU2_MAX_PAYLOAD_SIZE - len - 32, r) : 0;
|
||||
if (!payloadSize && r)
|
||||
it->second.first->SendFragmentedMessage (CreateDatabaseStoreMsg (r));
|
||||
|
@ -1592,7 +1595,7 @@ namespace transport
|
|||
|
||||
size_t SSU2Session::CreateRouterInfoBlock (uint8_t * buf, size_t len, std::shared_ptr<const i2p::data::RouterInfo> r)
|
||||
{
|
||||
if (!r || len < 5) return 0;
|
||||
if (!r || !r->GetBuffer () || len < 5) return 0;
|
||||
buf[0] = eSSU2BlkRouterInfo;
|
||||
size_t size = r->GetBufferLen ();
|
||||
if (size + 5 < len)
|
||||
|
|
Loading…
Reference in a new issue