|
|
@ -2,6 +2,7 @@ |
|
|
|
#include <algorithm> |
|
|
|
#include <algorithm> |
|
|
|
#include <cryptopp/dh.h> |
|
|
|
#include <cryptopp/dh.h> |
|
|
|
#include <cryptopp/gzip.h> |
|
|
|
#include <cryptopp/gzip.h> |
|
|
|
|
|
|
|
#include "util.h" |
|
|
|
#include "Log.h" |
|
|
|
#include "Log.h" |
|
|
|
#include "RouterInfo.h" |
|
|
|
#include "RouterInfo.h" |
|
|
|
#include "RouterContext.h" |
|
|
|
#include "RouterContext.h" |
|
|
@ -367,12 +368,20 @@ namespace stream |
|
|
|
void StreamingDestination::HandleNextPacket (Packet * packet) |
|
|
|
void StreamingDestination::HandleNextPacket (Packet * packet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t sendStreamID = packet->GetSendStreamID (); |
|
|
|
uint32_t sendStreamID = packet->GetSendStreamID (); |
|
|
|
auto it = m_Streams.find (sendStreamID); |
|
|
|
if (sendStreamID) |
|
|
|
if (it != m_Streams.end ()) |
|
|
|
{ |
|
|
|
it->second->HandleNextPacket (packet); |
|
|
|
auto it = m_Streams.find (sendStreamID); |
|
|
|
|
|
|
|
if (it != m_Streams.end ()) |
|
|
|
|
|
|
|
it->second->HandleNextPacket (packet); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint ("Unknown stream ", sendStreamID); |
|
|
|
|
|
|
|
delete packet; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Unknown stream ", sendStreamID); |
|
|
|
LogPrint ("Uncoming stream is not implemented yet"); |
|
|
|
delete packet; |
|
|
|
delete packet; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -468,6 +477,7 @@ namespace stream |
|
|
|
m_SharedLocalDestination = new StreamingDestination (); |
|
|
|
m_SharedLocalDestination = new StreamingDestination (); |
|
|
|
m_Destinations[m_SharedLocalDestination->GetIdentHash ()] = m_SharedLocalDestination; |
|
|
|
m_Destinations[m_SharedLocalDestination->GetIdentHash ()] = m_SharedLocalDestination; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
LoadLocalDestinations (); |
|
|
|
|
|
|
|
|
|
|
|
m_IsRunning = true; |
|
|
|
m_IsRunning = true; |
|
|
|
m_Thread = new std::thread (std::bind (&StreamingDestinations::Run, this)); |
|
|
|
m_Thread = new std::thread (std::bind (&StreamingDestinations::Run, this)); |
|
|
@ -495,6 +505,30 @@ namespace stream |
|
|
|
m_Service.run (); |
|
|
|
m_Service.run (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void StreamingDestinations::LoadLocalDestinations () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int numDestinations = 0; |
|
|
|
|
|
|
|
boost::filesystem::path p (i2p::util::filesystem::GetDataDir()); |
|
|
|
|
|
|
|
boost::filesystem::directory_iterator end; |
|
|
|
|
|
|
|
for (boost::filesystem::directory_iterator it (p); it != end; ++it) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (boost::filesystem::is_regular_file (*it) && it->path ().extension () == ".dat") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto fullPath = |
|
|
|
|
|
|
|
#if BOOST_VERSION > 10500 |
|
|
|
|
|
|
|
it->path().string(); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
it->path(); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
auto localDestination = new StreamingDestination (fullPath); |
|
|
|
|
|
|
|
m_Destinations[localDestination->GetIdentHash ()] = localDestination; |
|
|
|
|
|
|
|
numDestinations++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (numDestinations > 0) |
|
|
|
|
|
|
|
LogPrint (numDestinations, " local destinations loaded"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Stream * StreamingDestinations::CreateClientStream (const i2p::data::LeaseSet& remote) |
|
|
|
Stream * StreamingDestinations::CreateClientStream (const i2p::data::LeaseSet& remote) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_SharedLocalDestination) return nullptr; |
|
|
|
if (!m_SharedLocalDestination) return nullptr; |
|
|
|