Skip to content

Commit

Permalink
create I2NP depending on type in I2NP block
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Oct 17, 2021
1 parent d310efc commit 197882a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions libi2pd/NTCP2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,13 +875,16 @@ namespace transport
LogPrint (eLogError, "NTCP2: I2NP block is too long ", size);
break;
}
auto nextMsg = NewI2NPMessage (size);
nextMsg->Align (6); // for possible tunnel msg
nextMsg->offset += TUNNEL_GATEWAY_HEADER_SIZE; // reserve room for TunnelGateway header
auto nextMsg = (frame[offset] == eI2NPTunnelData) ? NewI2NPTunnelMessage (true) : NewI2NPMessage (size);
nextMsg->len = nextMsg->offset + size + 7; // 7 more bytes for full I2NP header
memcpy (nextMsg->GetNTCP2Header (), frame + offset, size);
nextMsg->FromNTCP2 ();
m_Handler.PutNextMessage (std::move (nextMsg));
if (nextMsg->len <= nextMsg->maxLen)
{
memcpy (nextMsg->GetNTCP2Header (), frame + offset, size);
nextMsg->FromNTCP2 ();
m_Handler.PutNextMessage (std::move (nextMsg));
}
else
LogPrint (eLogError, "NTCP2: I2NP block is too long for I2NP message");
break;
}
case eNTCP2BlkTermination:
Expand Down

0 comments on commit 197882a

Please sign in to comment.