|
|
|
@ -281,11 +281,11 @@ namespace stream
@@ -281,11 +281,11 @@ namespace stream
|
|
|
|
|
|
|
|
|
|
bool Stream::SendPacket (const uint8_t * buf, size_t len) |
|
|
|
|
{ |
|
|
|
|
const I2NPMessage * leaseSet = nullptr; |
|
|
|
|
I2NPMessage * leaseSet = nullptr; |
|
|
|
|
|
|
|
|
|
if (m_LeaseSetUpdated) |
|
|
|
|
{ |
|
|
|
|
leaseSet = m_LocalDestination->GetLeaseSet (); |
|
|
|
|
leaseSet = m_LocalDestination->GetLeaseSetMsg (); |
|
|
|
|
m_LeaseSetUpdated = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -359,10 +359,9 @@ namespace stream
@@ -359,10 +359,9 @@ namespace stream
|
|
|
|
|
|
|
|
|
|
StreamingDestination::~StreamingDestination () |
|
|
|
|
{ |
|
|
|
|
if (m_LeaseSet) |
|
|
|
|
DeleteI2NPMessage (m_LeaseSet); |
|
|
|
|
if (m_Pool) |
|
|
|
|
i2p::tunnel::tunnels.DeleteTunnelPool (m_Pool); |
|
|
|
|
delete m_LeaseSet; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void StreamingDestination::HandleNextPacket (Packet * packet) |
|
|
|
@ -403,33 +402,20 @@ namespace stream
@@ -403,33 +402,20 @@ namespace stream
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void StreamingDestination::UpdateLeaseSet () |
|
|
|
|
I2NPMessage * StreamingDestination::GetLeaseSetMsg () |
|
|
|
|
{ |
|
|
|
|
auto newLeaseSet = CreateLeaseSet (); |
|
|
|
|
if (!m_Pool) return nullptr; |
|
|
|
|
if (!m_LeaseSet || m_LeaseSet->HasExpiredLeases ()) |
|
|
|
|
{ |
|
|
|
|
auto newLeaseSet = new i2p::data::LeaseSet (*m_Pool); |
|
|
|
|
// TODO: make it atomic
|
|
|
|
|
auto oldLeaseSet = m_LeaseSet; |
|
|
|
|
m_LeaseSet = newLeaseSet; |
|
|
|
|
if (oldLeaseSet) |
|
|
|
|
DeleteI2NPMessage (oldLeaseSet); |
|
|
|
|
delete oldLeaseSet; |
|
|
|
|
for (auto it: m_Streams) |
|
|
|
|
it.second->SetLeaseSetUpdated (); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const I2NPMessage * StreamingDestination::GetLeaseSet () |
|
|
|
|
{ |
|
|
|
|
if (!m_LeaseSet) |
|
|
|
|
m_LeaseSet = CreateLeaseSet (); |
|
|
|
|
else |
|
|
|
|
RenewI2NPMessageHeader (m_LeaseSet); |
|
|
|
|
return m_LeaseSet; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
I2NPMessage * StreamingDestination::CreateLeaseSet () const |
|
|
|
|
{ |
|
|
|
|
// TODO: should store actual LeaseSet rather than msg
|
|
|
|
|
if (!m_Pool) return nullptr; |
|
|
|
|
i2p::data::LeaseSet leaseSet(*m_Pool); |
|
|
|
|
return CreateDatabaseStoreMsg (leaseSet); |
|
|
|
|
return CreateDatabaseStoreMsg (m_LeaseSet); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void StreamingDestination::Sign (const uint8_t * buf, int len, uint8_t * signature) const |
|
|
|
|