1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 16:34:13 +00:00

server tunnel on linux binds on 127.x.x.x

This commit is contained in:
xcps 2016-08-30 01:48:37 +05:00
parent 50e3d6ff37
commit 85e65da492

View File

@ -50,9 +50,21 @@ namespace client
void I2PTunnelConnection::Connect () void I2PTunnelConnection::Connect ()
{ {
if (m_Socket) if (m_Socket) {
#ifdef __linux__
// bind to 127.x.x.x address
// where x.x.x are first three bytes from ident
m_Socket->open (boost::asio::ip::tcp::v4 ());
boost::asio::ip::address_v4::bytes_type bytes;
const uint8_t * ident = m_Stream->GetRemoteIdentity ()->GetIdentHash ();
bytes[0] = 127;
memcpy (bytes.data ()+1, ident, 3);
boost::asio::ip::address ourIP = boost::asio::ip::address_v4 (bytes);
m_Socket->bind (boost::asio::ip::tcp::endpoint (ourIP, 0));
#endif
m_Socket->async_connect (m_RemoteEndpoint, std::bind (&I2PTunnelConnection::HandleConnect, m_Socket->async_connect (m_RemoteEndpoint, std::bind (&I2PTunnelConnection::HandleConnect,
shared_from_this (), std::placeholders::_1)); shared_from_this (), std::placeholders::_1));
}
} }
void I2PTunnelConnection::Terminate () void I2PTunnelConnection::Terminate ()