|
|
@ -118,14 +118,17 @@ namespace stream |
|
|
|
if (flags & PACKET_FLAG_FROM_INCLUDED) |
|
|
|
if (flags & PACKET_FLAG_FROM_INCLUDED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("From identity"); |
|
|
|
LogPrint ("From identity"); |
|
|
|
if (!m_RemoteLeaseSet) |
|
|
|
optionData += m_RemoteIdentity.FromBuffer (optionData, packet->GetOptionSize ()); |
|
|
|
|
|
|
|
if (m_RemoteLeaseSet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
i2p::data::Identity * identity = (i2p::data::Identity *)optionData; |
|
|
|
if (m_RemoteIdentity.Hash () != m_RemoteLeaseSet->GetIdentHash ()) // check recieved identity
|
|
|
|
LogPrint ("Incoming stream from ", identity->Hash ().ToBase64 ()); |
|
|
|
{ |
|
|
|
m_RemoteLeaseSet = i2p::data::netdb.FindLeaseSet (identity->Hash ()); |
|
|
|
LogPrint ("Unexpected identity ", m_RemoteIdentity.Hash ().ToBase64 (), " ", m_RemoteLeaseSet->GetIdentHash ().ToBase64 (), " expected"); |
|
|
|
if (!m_RemoteLeaseSet) |
|
|
|
m_RemoteLeaseSet = nullptr; |
|
|
|
LogPrint ("LeaseSet ", identity->Hash ().ToBase64 (), " not found"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
LogPrint ("Incoming stream from ", m_RemoteIdentity.Hash ().ToBase64 ()); |
|
|
|
optionData += sizeof (i2p::data::Identity); |
|
|
|
optionData += sizeof (i2p::data::Identity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -304,11 +307,15 @@ namespace stream |
|
|
|
|
|
|
|
|
|
|
|
bool Stream::SendPacket (const uint8_t * buf, size_t len) |
|
|
|
bool Stream::SendPacket (const uint8_t * buf, size_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!m_RemoteLeaseSet) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UpdateCurrentRemoteLease (); |
|
|
|
if (!m_RemoteLeaseSet) |
|
|
|
if (!m_RemoteLeaseSet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Can't send packet. Missing remote LeaseSet"); |
|
|
|
LogPrint ("Can't send packet. Missing remote LeaseSet"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
I2NPMessage * leaseSet = nullptr; |
|
|
|
I2NPMessage * leaseSet = nullptr; |
|
|
|
|
|
|
|
|
|
|
@ -347,6 +354,12 @@ namespace stream |
|
|
|
|
|
|
|
|
|
|
|
void Stream::UpdateCurrentRemoteLease () |
|
|
|
void Stream::UpdateCurrentRemoteLease () |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!m_RemoteLeaseSet) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_RemoteLeaseSet = i2p::data::netdb.FindLeaseSet (m_RemoteIdentity.Hash ()); |
|
|
|
|
|
|
|
if (!m_RemoteLeaseSet) |
|
|
|
|
|
|
|
LogPrint ("LeaseSet ", m_RemoteIdentity.Hash ().ToBase64 (), " not found"); |
|
|
|
|
|
|
|
} |
|
|
|
if (m_RemoteLeaseSet) |
|
|
|
if (m_RemoteLeaseSet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto leases = m_RemoteLeaseSet->GetNonExpiredLeases (); |
|
|
|
auto leases = m_RemoteLeaseSet->GetNonExpiredLeases (); |
|
|
|