diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index 15d3b6ad..4cd4a673 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -246,6 +246,7 @@ namespace client I2PServerTunnel::I2PServerTunnel (const std::string& address, int port, std::shared_ptr localDestination): I2PService (localDestination), m_Endpoint (boost::asio::ip::address::from_string (address), port) { + m_PortDestination = localDestination->CreateStreamingDestination (port); } void I2PServerTunnel::Start () @@ -260,9 +261,15 @@ namespace client void I2PServerTunnel::Accept () { + if (m_PortDestination) + m_PortDestination->SetAcceptor (std::bind (&I2PServerTunnel::HandleAccept, this, std::placeholders::_1)); + auto localDestination = GetLocalDestination (); if (localDestination) - localDestination->AcceptStreams (std::bind (&I2PServerTunnel::HandleAccept, this, std::placeholders::_1)); + { + if (!localDestination->IsAcceptingStreams ()) // set it as default if not set yet + localDestination->AcceptStreams (std::bind (&I2PServerTunnel::HandleAccept, this, std::placeholders::_1)); + } else LogPrint ("Local destination not set for server tunnel"); } diff --git a/I2PTunnel.h b/I2PTunnel.h index d4be85c7..3d91eec5 100644 --- a/I2PTunnel.h +++ b/I2PTunnel.h @@ -95,7 +95,8 @@ namespace client private: - boost::asio::ip::tcp::endpoint m_Endpoint; + boost::asio::ip::tcp::endpoint m_Endpoint; + std::shared_ptr m_PortDestination; }; } }