Browse Source

eliminate extra parsing of RouterInfo coming as RouterInfo block

pull/2101/head
orignal 2 months ago
parent
commit
855fd4d471
  1. 3
      libi2pd/NTCP2.cpp
  2. 14
      libi2pd/SSU2Session.cpp

3
libi2pd/NTCP2.cpp

@ -956,8 +956,7 @@ namespace transport @@ -956,8 +956,7 @@ namespace transport
case eNTCP2BlkRouterInfo:
{
LogPrint (eLogDebug, "NTCP2: RouterInfo flag=", (int)frame[offset]);
i2p::data::RouterInfo ri (frame + offset + 1, size - 1);
auto newRi = i2p::data::netdb.AddRouterInfo (ri.GetBuffer (), ri.GetBufferLen ());
auto newRi = i2p::data::netdb.AddRouterInfo (frame + offset + 1, size - 1);
if (newRi)
{
auto remoteIdentity = GetRemoteIdentity ();

14
libi2pd/SSU2Session.cpp

@ -1749,12 +1749,19 @@ namespace transport @@ -1749,12 +1749,19 @@ namespace transport
}
void SSU2Session::HandleRouterInfo (const uint8_t * buf, size_t len)
{
if (len < 2) return;
// not from SessionConfirmed, we must add it instantly to use in next block
std::shared_ptr<const i2p::data::RouterInfo> newRi;
if (buf[0] & SSU2_ROUTER_INFO_FLAG_GZIP) // compressed?
{
auto ri = ExtractRouterInfo (buf, len);
if (ri)
{
// not from SessionConfirmed, we must add it instantly to use in next block
auto newRi = i2p::data::netdb.AddRouterInfo (ri->GetBuffer (), ri->GetBufferLen ()); // TODO: add ri
newRi = i2p::data::netdb.AddRouterInfo (ri->GetBuffer (), ri->GetBufferLen ());
}
else // use buffer directly. TODO: handle frag
newRi = i2p::data::netdb.AddRouterInfo (buf + 2, len - 2);
if (newRi)
{
auto remoteIdentity = GetRemoteIdentity ();
@ -1772,7 +1779,6 @@ namespace transport @@ -1772,7 +1779,6 @@ namespace transport
}
}
}
}
void SSU2Session::HandleAck (const uint8_t * buf, size_t len)
{

Loading…
Cancel
Save