|
|
|
@ -709,17 +709,31 @@ namespace i2p
|
|
|
|
|
}
|
|
|
|
|
// send reply
|
|
|
|
|
if (isEndpoint)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
auto replyMsg = NewI2NPShortMessage ();
|
|
|
|
|
replyMsg->Concat (buf, len);
|
|
|
|
|
replyMsg->FillI2NPMessageHeader (eI2NPShortTunnelBuildReply, bufbe32toh (clearText + SHORT_REQUEST_RECORD_SEND_MSG_ID_OFFSET));
|
|
|
|
|
i2p::crypto::HKDF (noiseState.m_CK, nullptr, 0, "RGarlicKeyAndTag", noiseState.m_CK);
|
|
|
|
|
uint64_t tag;
|
|
|
|
|
memcpy (&tag, noiseState.m_CK, 8);
|
|
|
|
|
// we send it to reply tunnel
|
|
|
|
|
transports.SendMessage (clearText + SHORT_REQUEST_RECORD_NEXT_IDENT_OFFSET,
|
|
|
|
|
CreateTunnelGatewayMsg (bufbe32toh (clearText + SHORT_REQUEST_RECORD_NEXT_TUNNEL_OFFSET),
|
|
|
|
|
i2p::garlic::WrapECIESX25519Message (replyMsg, noiseState.m_CK + 32, tag)));
|
|
|
|
|
if (memcmp ((const uint8_t *)i2p::context.GetIdentHash (),
|
|
|
|
|
clearText + SHORT_REQUEST_RECORD_NEXT_IDENT_OFFSET, 32)) // reply IBGW is not local?
|
|
|
|
|
{
|
|
|
|
|
i2p::crypto::HKDF (noiseState.m_CK, nullptr, 0, "RGarlicKeyAndTag", noiseState.m_CK);
|
|
|
|
|
uint64_t tag;
|
|
|
|
|
memcpy (&tag, noiseState.m_CK, 8);
|
|
|
|
|
// we send it to reply tunnel
|
|
|
|
|
transports.SendMessage (clearText + SHORT_REQUEST_RECORD_NEXT_IDENT_OFFSET,
|
|
|
|
|
CreateTunnelGatewayMsg (bufbe32toh (clearText + SHORT_REQUEST_RECORD_NEXT_TUNNEL_OFFSET),
|
|
|
|
|
i2p::garlic::WrapECIESX25519Message (replyMsg, noiseState.m_CK + 32, tag)));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// IBGW is local
|
|
|
|
|
uint32_t tunnelID = bufbe32toh (clearText + SHORT_REQUEST_RECORD_NEXT_TUNNEL_OFFSET);
|
|
|
|
|
auto tunnel = i2p::tunnel::tunnels.GetTunnel (tunnelID);
|
|
|
|
|
if (tunnel)
|
|
|
|
|
tunnel->SendTunnelDataMsg (replyMsg);
|
|
|
|
|
else
|
|
|
|
|
LogPrint (eLogWarning, "I2NP: Tunnel ", tunnelID, " not found for short tunnel build reply");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
transports.SendMessage (clearText + SHORT_REQUEST_RECORD_NEXT_IDENT_OFFSET,
|
|
|
|
|