bind streaming destination to port for server tunnel

This commit is contained in:
orignal 2015-03-03 14:52:16 -05:00
parent 6fc0b2ecfb
commit c66ba370d5
2 changed files with 10 additions and 2 deletions

View File

@ -246,6 +246,7 @@ namespace client
I2PServerTunnel::I2PServerTunnel (const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination): I2PServerTunnel::I2PServerTunnel (const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination):
I2PService (localDestination), m_Endpoint (boost::asio::ip::address::from_string (address), port) I2PService (localDestination), m_Endpoint (boost::asio::ip::address::from_string (address), port)
{ {
m_PortDestination = localDestination->CreateStreamingDestination (port);
} }
void I2PServerTunnel::Start () void I2PServerTunnel::Start ()
@ -260,9 +261,15 @@ namespace client
void I2PServerTunnel::Accept () void I2PServerTunnel::Accept ()
{ {
if (m_PortDestination)
m_PortDestination->SetAcceptor (std::bind (&I2PServerTunnel::HandleAccept, this, std::placeholders::_1));
auto localDestination = GetLocalDestination (); auto localDestination = GetLocalDestination ();
if (localDestination) if (localDestination)
{
if (!localDestination->IsAcceptingStreams ()) // set it as default if not set yet
localDestination->AcceptStreams (std::bind (&I2PServerTunnel::HandleAccept, this, std::placeholders::_1)); localDestination->AcceptStreams (std::bind (&I2PServerTunnel::HandleAccept, this, std::placeholders::_1));
}
else else
LogPrint ("Local destination not set for server tunnel"); LogPrint ("Local destination not set for server tunnel");
} }

View File

@ -96,6 +96,7 @@ namespace client
private: private:
boost::asio::ip::tcp::endpoint m_Endpoint; boost::asio::ip::tcp::endpoint m_Endpoint;
std::shared_ptr<i2p::stream::StreamingDestination> m_PortDestination;
}; };
} }
} }