mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
CreateLeaseSetClove
This commit is contained in:
parent
86782f3479
commit
23be4c01df
|
@ -684,10 +684,10 @@ namespace garlic
|
||||||
if (first) payloadLen += 7;// datatime
|
if (first) payloadLen += 7;// datatime
|
||||||
if (msg && m_Destination)
|
if (msg && m_Destination)
|
||||||
payloadLen += msg->GetPayloadLength () + 13 + 32;
|
payloadLen += msg->GetPayloadLength () + 13 + 32;
|
||||||
auto leaseSet = (GetLeaseSetUpdateStatus () == eLeaseSetUpdated) ? CreateDatabaseStoreMsg (GetOwner ()->GetLeaseSet ()) : nullptr;
|
auto leaseSet = (GetLeaseSetUpdateStatus () == eLeaseSetUpdated) ? GetOwner ()->GetLeaseSet () : nullptr;
|
||||||
if (leaseSet)
|
if (leaseSet)
|
||||||
{
|
{
|
||||||
payloadLen += leaseSet->GetPayloadLength () + 13;
|
payloadLen += leaseSet->GetBufferLen () + DATABASE_STORE_HEADER_SIZE + 13;
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
// ack request
|
// ack request
|
||||||
|
@ -725,7 +725,7 @@ namespace garlic
|
||||||
// LeaseSet
|
// LeaseSet
|
||||||
if (leaseSet)
|
if (leaseSet)
|
||||||
{
|
{
|
||||||
offset += CreateGarlicClove (leaseSet, v.data () + offset, payloadLen - offset);
|
offset += CreateLeaseSetClove (leaseSet, ts, v.data () + offset, payloadLen - offset);
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
// ack request
|
// ack request
|
||||||
|
@ -815,36 +815,29 @@ namespace garlic
|
||||||
return cloveSize + 3;
|
return cloveSize + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ECIESX25519AEADRatchetSession::CreateDeliveryStatusClove (std::shared_ptr<const I2NPMessage> msg, uint8_t * buf, size_t len)
|
size_t ECIESX25519AEADRatchetSession::CreateLeaseSetClove (std::shared_ptr<const i2p::data::LocalLeaseSet> ls, uint64_t ts, uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
uint16_t cloveSize = msg->GetPayloadLength () + 9 + 37 /* delivery instruction */;
|
if (!ls || ls->GetStoreType () != i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2)
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "Garlic: Incorrect LeasetSet type to send");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
uint16_t cloveSize = 1 + 9 + DATABASE_STORE_HEADER_SIZE + ls->GetBufferLen (); // to local
|
||||||
if ((int)len < cloveSize + 3) return 0;
|
if ((int)len < cloveSize + 3) return 0;
|
||||||
buf[0] = eECIESx25519BlkGalicClove; // clove type
|
buf[0] = eECIESx25519BlkGalicClove; // clove type
|
||||||
htobe16buf (buf + 1, cloveSize); // size
|
htobe16buf (buf + 1, cloveSize); // size
|
||||||
buf += 3;
|
buf += 3;
|
||||||
if (GetOwner ())
|
*buf = 0; buf++; // flag and delivery instructions
|
||||||
{
|
*buf = eI2NPDatabaseStore; buf++; // I2NP msg type
|
||||||
auto inboundTunnel = GetOwner ()->GetTunnelPool ()->GetNextInboundTunnel ();
|
RAND_bytes (buf, 4); buf += 4; // msgID
|
||||||
if (inboundTunnel)
|
htobe32buf (buf, (ts + I2NP_MESSAGE_EXPIRATION_TIMEOUT)/1000); buf += 4; // expiration
|
||||||
{
|
// payload
|
||||||
// delivery instructions
|
memcpy (buf + DATABASE_STORE_KEY_OFFSET, ls->GetStoreHash (), 32);
|
||||||
*buf = eGarlicDeliveryTypeTunnel << 5; buf++; // delivery instructions flag tunnel
|
buf[DATABASE_STORE_TYPE_OFFSET] = i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2;
|
||||||
// hash and tunnelID sequence is reversed for Garlic
|
memset (buf + DATABASE_STORE_REPLY_TOKEN_OFFSET, 0, 4); // replyToken = 0
|
||||||
memcpy (buf, inboundTunnel->GetNextIdentHash (), 32); buf += 32;// To Hash
|
buf += DATABASE_STORE_HEADER_SIZE;
|
||||||
htobe32buf (buf, inboundTunnel->GetNextTunnelID ()); buf += 4;// tunnelID
|
memcpy (buf, ls->GetBuffer (), ls->GetBufferLen ());
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogPrint (eLogError, "Garlic: No inbound tunnels in the pool for DeliveryStatus");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*buf = msg->GetTypeID (); // I2NP msg type
|
|
||||||
htobe32buf (buf + 1, msg->GetMsgID ()); // msgID
|
|
||||||
htobe32buf (buf + 5, msg->GetExpiration ()/1000); // expiration in seconds
|
|
||||||
memcpy (buf + 9, msg->GetPayload (), msg->GetPayloadLength ());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
return cloveSize + 3;
|
return cloveSize + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace garlic
|
||||||
|
|
||||||
std::vector<uint8_t> CreatePayload (std::shared_ptr<const I2NPMessage> msg, bool first);
|
std::vector<uint8_t> CreatePayload (std::shared_ptr<const I2NPMessage> msg, bool first);
|
||||||
size_t CreateGarlicClove (std::shared_ptr<const I2NPMessage> msg, uint8_t * buf, size_t len, bool isDestination = false);
|
size_t CreateGarlicClove (std::shared_ptr<const I2NPMessage> msg, uint8_t * buf, size_t len, bool isDestination = false);
|
||||||
size_t CreateDeliveryStatusClove (std::shared_ptr<const I2NPMessage> msg, uint8_t * buf, size_t len);
|
size_t CreateLeaseSetClove (std::shared_ptr<const i2p::data::LocalLeaseSet> ls, uint64_t ts, uint8_t * buf, size_t len);
|
||||||
|
|
||||||
void GenerateMoreReceiveTags (std::shared_ptr<RatchetTagSet> receiveTagset, int numTags);
|
void GenerateMoreReceiveTags (std::shared_ptr<RatchetTagSet> receiveTagset, int numTags);
|
||||||
void NewNextSendRatchet ();
|
void NewNextSendRatchet ();
|
||||||
|
|
Loading…
Reference in a new issue