mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
don't populate buffer of unreachable router
This commit is contained in:
parent
77142e59ee
commit
02a36a9fa8
@ -1043,8 +1043,7 @@ namespace data
|
|||||||
if (router && !router->IsUnreachable ())
|
if (router && !router->IsUnreachable ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: Requested RouterInfo ", key, " found");
|
LogPrint (eLogDebug, "NetDb: Requested RouterInfo ", key, " found");
|
||||||
PopulateRouterInfoBuffer (router);
|
if (PopulateRouterInfoBuffer (router))
|
||||||
if (router->GetBuffer ())
|
|
||||||
replyMsg = CreateDatabaseStoreMsg (router);
|
replyMsg = CreateDatabaseStoreMsg (router);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1481,10 +1480,11 @@ namespace data
|
|||||||
m_LeasesPool.CleanUpMt ();
|
m_LeasesPool.CleanUpMt ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDb::PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r)
|
bool NetDb::PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r)
|
||||||
{
|
{
|
||||||
if (!r || r->GetBuffer ()) return;
|
if (!r) return false;
|
||||||
r->LoadBuffer (m_Storage.Path (r->GetIdentHashBase64 ()));
|
if (r->GetBuffer ()) return true;
|
||||||
|
return r->LoadBuffer (m_Storage.Path (r->GetIdentHashBase64 ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ namespace data
|
|||||||
|
|
||||||
void ClearRouterInfos () { m_RouterInfos.clear (); };
|
void ClearRouterInfos () { m_RouterInfos.clear (); };
|
||||||
std::shared_ptr<RouterInfo::Buffer> NewRouterInfoBuffer () { return m_RouterInfoBuffersPool.AcquireSharedMt (); };
|
std::shared_ptr<RouterInfo::Buffer> NewRouterInfoBuffer () { return m_RouterInfoBuffersPool.AcquireSharedMt (); };
|
||||||
void PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r);
|
bool PopulateRouterInfoBuffer (std::shared_ptr<RouterInfo> r);
|
||||||
std::shared_ptr<RouterInfo::Address> NewRouterInfoAddress () { return m_RouterInfoAddressesPool.AcquireSharedMt (); };
|
std::shared_ptr<RouterInfo::Address> NewRouterInfoAddress () { return m_RouterInfoAddressesPool.AcquireSharedMt (); };
|
||||||
boost::shared_ptr<RouterInfo::Addresses> NewRouterInfoAddresses ()
|
boost::shared_ptr<RouterInfo::Addresses> NewRouterInfoAddresses ()
|
||||||
{
|
{
|
||||||
|
@ -589,6 +589,8 @@ namespace data
|
|||||||
{
|
{
|
||||||
if (LoadFile (fullPath))
|
if (LoadFile (fullPath))
|
||||||
LogPrint (eLogDebug, "RouterInfo: Buffer for ", GetIdentHashAbbreviation (GetIdentHash ()), " loaded from file");
|
LogPrint (eLogDebug, "RouterInfo: Buffer for ", GetIdentHashAbbreviation (GetIdentHash ()), " loaded from file");
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
return m_Buffer->data ();
|
return m_Buffer->data ();
|
||||||
}
|
}
|
||||||
|
@ -1872,10 +1872,9 @@ namespace transport
|
|||||||
|
|
||||||
// send relay intro to Charlie
|
// send relay intro to Charlie
|
||||||
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ()); // Alice's RI
|
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ()); // Alice's RI
|
||||||
if (r)
|
if (r && (r->IsUnreachable () || !i2p::data::netdb.PopulateRouterInfoBuffer (r))) r = nullptr;
|
||||||
i2p::data::netdb.PopulateRouterInfoBuffer (r);
|
if (!r) LogPrint (eLogWarning, "SSU2: RelayRequest Alice's router info not found");
|
||||||
else
|
|
||||||
LogPrint (eLogWarning, "SSU2: RelayRequest Alice's router info not found");
|
|
||||||
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
||||||
size_t payloadSize = r ? CreateRouterInfoBlock (payload, m_MaxPayloadSize - len - 32, r) : 0;
|
size_t payloadSize = r ? CreateRouterInfoBlock (payload, m_MaxPayloadSize - len - 32, r) : 0;
|
||||||
if (!payloadSize && r)
|
if (!payloadSize && r)
|
||||||
@ -2069,7 +2068,7 @@ namespace transport
|
|||||||
auto packet = m_Server.GetSentPacketsPool ().AcquireShared ();
|
auto packet = m_Server.GetSentPacketsPool ().AcquireShared ();
|
||||||
// Alice's RouterInfo
|
// Alice's RouterInfo
|
||||||
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ());
|
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ());
|
||||||
if (r) i2p::data::netdb.PopulateRouterInfoBuffer (r);
|
if (r && (r->IsUnreachable () || !i2p::data::netdb.PopulateRouterInfoBuffer (r))) r = nullptr;
|
||||||
packet->payloadSize = r ? CreateRouterInfoBlock (packet->payload, m_MaxPayloadSize - len - 32, r) : 0;
|
packet->payloadSize = r ? CreateRouterInfoBlock (packet->payload, m_MaxPayloadSize - len - 32, r) : 0;
|
||||||
if (!packet->payloadSize && r)
|
if (!packet->payloadSize && r)
|
||||||
session->SendFragmentedMessage (CreateDatabaseStoreMsg (r));
|
session->SendFragmentedMessage (CreateDatabaseStoreMsg (r));
|
||||||
@ -2173,7 +2172,7 @@ namespace transport
|
|||||||
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
||||||
// Charlie's RouterInfo
|
// Charlie's RouterInfo
|
||||||
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ());
|
auto r = i2p::data::netdb.FindRouter (GetRemoteIdentity ()->GetIdentHash ());
|
||||||
if (r) i2p::data::netdb.PopulateRouterInfoBuffer (r);
|
if (r && (r->IsUnreachable () || !i2p::data::netdb.PopulateRouterInfoBuffer (r))) r = nullptr;
|
||||||
size_t payloadSize = r ? CreateRouterInfoBlock (payload, m_MaxPayloadSize - len - 32, r) : 0;
|
size_t payloadSize = r ? CreateRouterInfoBlock (payload, m_MaxPayloadSize - len - 32, r) : 0;
|
||||||
if (!payloadSize && r)
|
if (!payloadSize && r)
|
||||||
it->second.first->SendFragmentedMessage (CreateDatabaseStoreMsg (r));
|
it->second.first->SendFragmentedMessage (CreateDatabaseStoreMsg (r));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user