Browse Source

create I2NP depending on type in I2NP block

pull/1698/head
orignal 3 years ago
parent
commit
197882a4c9
  1. 15
      libi2pd/NTCP2.cpp

15
libi2pd/NTCP2.cpp

@ -875,13 +875,16 @@ namespace transport
LogPrint (eLogError, "NTCP2: I2NP block is too long ", size); LogPrint (eLogError, "NTCP2: I2NP block is too long ", size);
break; break;
} }
auto nextMsg = NewI2NPMessage (size); auto nextMsg = (frame[offset] == eI2NPTunnelData) ? NewI2NPTunnelMessage (true) : NewI2NPMessage (size);
nextMsg->Align (6); // for possible tunnel msg
nextMsg->offset += TUNNEL_GATEWAY_HEADER_SIZE; // reserve room for TunnelGateway header
nextMsg->len = nextMsg->offset + size + 7; // 7 more bytes for full I2NP header nextMsg->len = nextMsg->offset + size + 7; // 7 more bytes for full I2NP header
memcpy (nextMsg->GetNTCP2Header (), frame + offset, size); if (nextMsg->len <= nextMsg->maxLen)
nextMsg->FromNTCP2 (); {
m_Handler.PutNextMessage (std::move (nextMsg)); 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; break;
} }
case eNTCP2BlkTermination: case eNTCP2BlkTermination:

Loading…
Cancel
Save