mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
pass local LeaseSet as const
This commit is contained in:
parent
a34d1de10e
commit
25f2f932b0
10
Garlic.cpp
10
Garlic.cpp
@ -43,7 +43,7 @@ namespace garlic
|
||||
}
|
||||
}
|
||||
|
||||
I2NPMessage * GarlicRoutingSession::WrapSingleMessage (I2NPMessage * msg, I2NPMessage * leaseSet)
|
||||
I2NPMessage * GarlicRoutingSession::WrapSingleMessage (I2NPMessage * msg, const I2NPMessage * leaseSet)
|
||||
{
|
||||
I2NPMessage * m = NewI2NPMessage ();
|
||||
size_t len = 0;
|
||||
@ -89,7 +89,7 @@ namespace garlic
|
||||
return m;
|
||||
}
|
||||
|
||||
size_t GarlicRoutingSession::CreateAESBlock (uint8_t * buf, I2NPMessage * msg, I2NPMessage * leaseSet)
|
||||
size_t GarlicRoutingSession::CreateAESBlock (uint8_t * buf, const I2NPMessage * msg, const I2NPMessage * leaseSet)
|
||||
{
|
||||
size_t blockSize = 0;
|
||||
*(uint16_t *)buf = m_NextTag < 0 ? htobe16 (m_NumTags) : 0; // tag count
|
||||
@ -116,7 +116,7 @@ namespace garlic
|
||||
return blockSize;
|
||||
}
|
||||
|
||||
size_t GarlicRoutingSession::CreateGarlicPayload (uint8_t * payload, I2NPMessage * msg, I2NPMessage * leaseSet)
|
||||
size_t GarlicRoutingSession::CreateGarlicPayload (uint8_t * payload, const I2NPMessage * msg, const I2NPMessage * leaseSet)
|
||||
{
|
||||
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 5000; // 5 sec
|
||||
uint32_t msgID = m_Rnd.GenerateWord32 ();
|
||||
@ -153,7 +153,7 @@ namespace garlic
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t GarlicRoutingSession::CreateGarlicClove (uint8_t * buf, I2NPMessage * msg, bool isDestination)
|
||||
size_t GarlicRoutingSession::CreateGarlicClove (uint8_t * buf, const I2NPMessage * msg, bool isDestination)
|
||||
{
|
||||
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 5000; // 5 sec
|
||||
size_t size = 0;
|
||||
@ -245,7 +245,7 @@ namespace garlic
|
||||
}
|
||||
|
||||
I2NPMessage * GarlicRouting::WrapMessage (const i2p::data::RoutingDestination& destination,
|
||||
I2NPMessage * msg, I2NPMessage * leaseSet)
|
||||
I2NPMessage * msg, const I2NPMessage * leaseSet)
|
||||
{
|
||||
auto it = m_Sessions.find (destination.GetIdentHash ());
|
||||
GarlicRoutingSession * session = nullptr;
|
||||
|
10
Garlic.h
10
Garlic.h
@ -42,7 +42,7 @@ namespace garlic
|
||||
|
||||
GarlicRoutingSession (const i2p::data::RoutingDestination& destination, int numTags);
|
||||
~GarlicRoutingSession ();
|
||||
I2NPMessage * WrapSingleMessage (I2NPMessage * msg, I2NPMessage * leaseSet);
|
||||
I2NPMessage * WrapSingleMessage (I2NPMessage * msg, const I2NPMessage * leaseSet);
|
||||
int GetNextTag () const { return m_NextTag; };
|
||||
uint32_t GetFirstMsgID () const { return m_FirstMsgID; };
|
||||
|
||||
@ -51,9 +51,9 @@ namespace garlic
|
||||
|
||||
private:
|
||||
|
||||
size_t CreateAESBlock (uint8_t * buf, I2NPMessage * msg, I2NPMessage * leaseSet);
|
||||
size_t CreateGarlicPayload (uint8_t * payload, I2NPMessage * msg, I2NPMessage * leaseSet);
|
||||
size_t CreateGarlicClove (uint8_t * buf, I2NPMessage * msg, bool isDestination);
|
||||
size_t CreateAESBlock (uint8_t * buf, const I2NPMessage * msg, const I2NPMessage * leaseSet);
|
||||
size_t CreateGarlicPayload (uint8_t * payload, const I2NPMessage * msg, const I2NPMessage * leaseSet);
|
||||
size_t CreateGarlicClove (uint8_t * buf, const I2NPMessage * msg, bool isDestination);
|
||||
size_t CreateDeliveryStatusClove (uint8_t * buf, uint32_t msgID);
|
||||
|
||||
void GenerateSessionTags ();
|
||||
@ -86,7 +86,7 @@ namespace garlic
|
||||
|
||||
I2NPMessage * WrapSingleMessage (const i2p::data::RoutingDestination& destination, I2NPMessage * msg);
|
||||
I2NPMessage * WrapMessage (const i2p::data::RoutingDestination& destination,
|
||||
I2NPMessage * msg, I2NPMessage * leaseSet = nullptr);
|
||||
I2NPMessage * msg, const I2NPMessage * leaseSet = nullptr);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -103,9 +103,10 @@ namespace tunnel
|
||||
size_t len, offset;
|
||||
i2p::tunnel::InboundTunnel * from;
|
||||
|
||||
I2NPHeader * GetHeader () { return (I2NPHeader *)(buf + offset); };
|
||||
uint8_t * GetPayload () { return buf + offset + sizeof(I2NPHeader); };
|
||||
I2NPHeader * GetHeader () { return (I2NPHeader *)GetBuffer (); };
|
||||
uint8_t * GetPayload () { return GetBuffer () + sizeof(I2NPHeader); };
|
||||
uint8_t * GetBuffer () { return buf + offset; };
|
||||
const uint8_t * GetBuffer () const { return buf + offset; };
|
||||
size_t GetLength () const { return len - offset; };
|
||||
|
||||
I2NPMessage& operator=(const I2NPMessage& other)
|
||||
|
@ -264,7 +264,7 @@ namespace stream
|
||||
|
||||
bool Stream::SendPacket (uint8_t * packet, size_t size)
|
||||
{
|
||||
I2NPMessage * leaseSet = nullptr;
|
||||
const I2NPMessage * leaseSet = nullptr;
|
||||
if (m_LeaseSetUpdated)
|
||||
{
|
||||
leaseSet = m_LocalDestination->GetLeaseSet ();
|
||||
@ -367,7 +367,7 @@ namespace stream
|
||||
it.second->SetLeaseSetUpdated ();
|
||||
}
|
||||
|
||||
I2NPMessage * StreamingDestination::GetLeaseSet ()
|
||||
const I2NPMessage * StreamingDestination::GetLeaseSet ()
|
||||
{
|
||||
if (!m_LeaseSet)
|
||||
m_LeaseSet = CreateLeaseSet ();
|
||||
|
@ -112,7 +112,7 @@ namespace stream
|
||||
|
||||
const i2p::data::PrivateKeys& GetKeys () const { return m_Keys; };
|
||||
const i2p::data::Identity& GetIdentity () const { return m_Keys.pub; };
|
||||
I2NPMessage * GetLeaseSet ();
|
||||
const I2NPMessage * GetLeaseSet ();
|
||||
i2p::tunnel::TunnelPool * GetTunnelPool () const { return m_Pool; };
|
||||
void Sign (uint8_t * buf, int len, uint8_t * signature) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user