|
|
@ -308,13 +308,15 @@ namespace stream |
|
|
|
m_IdentHash = i2p::data::CalculateIdentHash (m_Identity); |
|
|
|
m_IdentHash = i2p::data::CalculateIdentHash (m_Identity); |
|
|
|
m_SigningPrivateKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag, |
|
|
|
m_SigningPrivateKey.Initialize (i2p::crypto::dsap, i2p::crypto::dsaq, i2p::crypto::dsag, |
|
|
|
CryptoPP::Integer (m_Keys.signingPrivateKey, 20)); |
|
|
|
CryptoPP::Integer (m_Keys.signingPrivateKey, 20)); |
|
|
|
i2p::tunnel::tunnels.CreateTunnelPool (this); |
|
|
|
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
StreamingDestination::~StreamingDestination () |
|
|
|
StreamingDestination::~StreamingDestination () |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_LeaseSet) |
|
|
|
if (m_LeaseSet) |
|
|
|
DeleteI2NPMessage (m_LeaseSet); |
|
|
|
DeleteI2NPMessage (m_LeaseSet); |
|
|
|
|
|
|
|
if (m_Pool) |
|
|
|
|
|
|
|
i2p::tunnel::tunnels.DeleteTunnelPool (m_Pool); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void StreamingDestination::HandleNextPacket (Packet * packet) |
|
|
|
void StreamingDestination::HandleNextPacket (Packet * packet) |
|
|
@ -346,12 +348,20 @@ namespace stream |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
I2NPMessage * StreamingDestination::GetLeaseSet () |
|
|
|
void StreamingDestination::UpdateLeaseSet () |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_LeaseSet) // temporary always create new LeaseSet
|
|
|
|
auto newLeaseSet = CreateLeaseSet (); |
|
|
|
DeleteI2NPMessage (m_LeaseSet); |
|
|
|
// TODO: make it atomic
|
|
|
|
m_LeaseSet = CreateLeaseSet (); |
|
|
|
auto oldLeaseSet = m_LeaseSet; |
|
|
|
|
|
|
|
m_LeaseSet = newLeaseSet; |
|
|
|
|
|
|
|
if (oldLeaseSet) |
|
|
|
|
|
|
|
DeleteI2NPMessage (oldLeaseSet); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
I2NPMessage * StreamingDestination::GetLeaseSet () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!m_LeaseSet) |
|
|
|
|
|
|
|
m_LeaseSet = CreateLeaseSet (); |
|
|
|
return m_LeaseSet; |
|
|
|
return m_LeaseSet; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -371,7 +381,7 @@ namespace stream |
|
|
|
size += 256; // encryption key
|
|
|
|
size += 256; // encryption key
|
|
|
|
memset (buf + size, 0, 128); |
|
|
|
memset (buf + size, 0, 128); |
|
|
|
size += 128; // signing key
|
|
|
|
size += 128; // signing key
|
|
|
|
auto tunnels = i2p::tunnel::tunnels.GetInboundTunnels (5); // 5 tunnels maximum
|
|
|
|
auto tunnels = m_Pool->GetInboundTunnels (5); // 5 tunnels maximum
|
|
|
|
buf[size] = tunnels.size (); // num leases
|
|
|
|
buf[size] = tunnels.size (); // num leases
|
|
|
|
size++; // num
|
|
|
|
size++; // num
|
|
|
|
for (auto it: tunnels) |
|
|
|
for (auto it: tunnels) |
|
|
@ -412,6 +422,17 @@ namespace stream |
|
|
|
if (sharedLocalDestination) |
|
|
|
if (sharedLocalDestination) |
|
|
|
sharedLocalDestination->DeleteStream (stream); |
|
|
|
sharedLocalDestination->DeleteStream (stream); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void StartStreaming () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!sharedLocalDestination) |
|
|
|
|
|
|
|
sharedLocalDestination = new StreamingDestination (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void StopStreaming () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delete sharedLocalDestination; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HandleDataMessage (i2p::data::IdentHash * destination, const uint8_t * buf, size_t len) |
|
|
|
void HandleDataMessage (i2p::data::IdentHash * destination, const uint8_t * buf, size_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|