mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-11 13:27:52 +00:00
use shared ClientDestination
This commit is contained in:
parent
789eb48698
commit
c7173d5e1c
@ -11,7 +11,7 @@ namespace i2p
|
||||
{
|
||||
namespace datagram
|
||||
{
|
||||
DatagramDestination::DatagramDestination (std::shared_ptr<i2p::client::LeaseSetDestination> owner):
|
||||
DatagramDestination::DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner):
|
||||
m_Owner (owner), m_Receiver (nullptr)
|
||||
{
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace i2p
|
||||
{
|
||||
namespace client
|
||||
{
|
||||
class LeaseSetDestination;
|
||||
class ClientDestination;
|
||||
}
|
||||
namespace datagram
|
||||
{
|
||||
@ -25,7 +25,7 @@ namespace datagram
|
||||
|
||||
public:
|
||||
|
||||
DatagramDestination (std::shared_ptr<i2p::client::LeaseSetDestination> owner);
|
||||
DatagramDestination (std::shared_ptr<i2p::client::ClientDestination> owner);
|
||||
~DatagramDestination ();
|
||||
|
||||
void SendDatagramTo (const uint8_t * payload, size_t len, const i2p::data::IdentHash& ident, uint16_t fromPort = 0, uint16_t toPort = 0);
|
||||
@ -47,7 +47,7 @@ namespace datagram
|
||||
|
||||
private:
|
||||
|
||||
std::shared_ptr<i2p::client::LeaseSetDestination> m_Owner;
|
||||
std::shared_ptr<i2p::client::ClientDestination> m_Owner;
|
||||
Receiver m_Receiver; // default
|
||||
std::map<uint16_t, Receiver> m_ReceiversByPorts;
|
||||
|
||||
|
@ -662,7 +662,7 @@ namespace client
|
||||
{
|
||||
if (LeaseSetDestination::Start ())
|
||||
{
|
||||
m_StreamingDestination = std::make_shared<i2p::stream::StreamingDestination> (shared_from_this ()); // TODO:
|
||||
m_StreamingDestination = std::make_shared<i2p::stream::StreamingDestination> (GetSharedFromThis ()); // TODO:
|
||||
m_StreamingDestination->Start ();
|
||||
for (auto it: m_StreamingDestinationsByPorts)
|
||||
it.second->Start ();
|
||||
@ -735,7 +735,7 @@ namespace client
|
||||
streamRequestComplete(CreateStream (leaseSet, port));
|
||||
else
|
||||
{
|
||||
auto s = std::static_pointer_cast<ClientDestination>(shared_from_this ());
|
||||
auto s = GetSharedFromThis ();
|
||||
RequestDestination (dest,
|
||||
[s, streamRequestComplete, port](std::shared_ptr<i2p::data::LeaseSet> ls)
|
||||
{
|
||||
@ -788,7 +788,7 @@ namespace client
|
||||
|
||||
std::shared_ptr<i2p::stream::StreamingDestination> ClientDestination::CreateStreamingDestination (int port, bool gzip)
|
||||
{
|
||||
auto dest = std::make_shared<i2p::stream::StreamingDestination> (shared_from_this (), port, gzip);
|
||||
auto dest = std::make_shared<i2p::stream::StreamingDestination> (GetSharedFromThis (), port, gzip);
|
||||
if (port)
|
||||
m_StreamingDestinationsByPorts[port] = dest;
|
||||
else // update default
|
||||
@ -799,7 +799,7 @@ namespace client
|
||||
i2p::datagram::DatagramDestination * ClientDestination::CreateDatagramDestination ()
|
||||
{
|
||||
if (!m_DatagramDestination)
|
||||
m_DatagramDestination = new i2p::datagram::DatagramDestination (shared_from_this ());
|
||||
m_DatagramDestination = new i2p::datagram::DatagramDestination (GetSharedFromThis ());
|
||||
return m_DatagramDestination;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,9 @@ namespace client
|
||||
private:
|
||||
|
||||
void PersistTemporaryKeys ();
|
||||
|
||||
std::shared_ptr<ClientDestination> GetSharedFromThis ()
|
||||
{ return std::static_pointer_cast<ClientDestination>(shared_from_this ()); }
|
||||
|
||||
private:
|
||||
|
||||
i2p::data::PrivateKeys m_Keys;
|
||||
|
@ -780,7 +780,7 @@ namespace stream
|
||||
m_CurrentRemoteLease = nullptr;
|
||||
}
|
||||
|
||||
StreamingDestination::StreamingDestination (std::shared_ptr<i2p::client::LeaseSetDestination> owner, uint16_t localPort, bool gzip):
|
||||
StreamingDestination::StreamingDestination (std::shared_ptr<i2p::client::ClientDestination> owner, uint16_t localPort, bool gzip):
|
||||
m_Owner (owner), m_LocalPort (localPort), m_Gzip (gzip),
|
||||
m_PendingIncomingTimer (m_Owner->GetService ())
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ namespace i2p
|
||||
{
|
||||
namespace client
|
||||
{
|
||||
class LeaseSetDestination;
|
||||
class ClientDestination;
|
||||
}
|
||||
namespace stream
|
||||
{
|
||||
@ -193,7 +193,7 @@ namespace stream
|
||||
|
||||
typedef std::function<void (std::shared_ptr<Stream>)> Acceptor;
|
||||
|
||||
StreamingDestination (std::shared_ptr<i2p::client::LeaseSetDestination> owner, uint16_t localPort = 0, bool gzip = true);
|
||||
StreamingDestination (std::shared_ptr<i2p::client::ClientDestination> owner, uint16_t localPort = 0, bool gzip = true);
|
||||
~StreamingDestination ();
|
||||
|
||||
void Start ();
|
||||
@ -204,7 +204,7 @@ namespace stream
|
||||
void SetAcceptor (const Acceptor& acceptor);
|
||||
void ResetAcceptor ();
|
||||
bool IsAcceptorSet () const { return m_Acceptor != nullptr; };
|
||||
std::shared_ptr<i2p::client::LeaseSetDestination> GetOwner () const { return m_Owner; };
|
||||
std::shared_ptr<i2p::client::ClientDestination> GetOwner () const { return m_Owner; };
|
||||
uint16_t GetLocalPort () const { return m_LocalPort; };
|
||||
|
||||
void HandleDataMessagePayload (const uint8_t * buf, size_t len);
|
||||
@ -218,7 +218,7 @@ namespace stream
|
||||
|
||||
private:
|
||||
|
||||
std::shared_ptr<i2p::client::LeaseSetDestination> m_Owner;
|
||||
std::shared_ptr<i2p::client::ClientDestination> m_Owner;
|
||||
uint16_t m_LocalPort;
|
||||
bool m_Gzip; // gzip compression of data messages
|
||||
std::mutex m_StreamsMutex;
|
||||
|
Loading…
Reference in New Issue
Block a user