Skip to content
/ i2pd Public
forked from PurpleI2P/i2pd

Commit

Permalink
bind streaming destination to port for server tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Mar 3, 2015
1 parent 6fc0b2e commit c66ba37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion I2PTunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ namespace client
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)
{
m_PortDestination = localDestination->CreateStreamingDestination (port);
}

void I2PServerTunnel::Start ()
Expand All @@ -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");
}
Expand Down
3 changes: 2 additions & 1 deletion I2PTunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ namespace client

private:

boost::asio::ip::tcp::endpoint m_Endpoint;
boost::asio::ip::tcp::endpoint m_Endpoint;
std::shared_ptr<i2p::stream::StreamingDestination> m_PortDestination;
};
}
}
Expand Down

0 comments on commit c66ba37

Please sign in to comment.