mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
check before bind to 127.x.x.x
This commit is contained in:
parent
85e65da492
commit
f2893097a7
1 changed files with 12 additions and 7 deletions
|
@ -54,13 +54,18 @@ namespace client
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
// bind to 127.x.x.x address
|
// bind to 127.x.x.x address
|
||||||
// where x.x.x are first three bytes from ident
|
// 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;
|
if (m_RemoteEndpoint.address ().is_v4 () &&
|
||||||
const uint8_t * ident = m_Stream->GetRemoteIdentity ()->GetIdentHash ();
|
m_RemoteEndpoint.address ().to_v4 ().to_bytes ()[0] == 127)
|
||||||
bytes[0] = 127;
|
{
|
||||||
memcpy (bytes.data ()+1, ident, 3);
|
m_Socket->open (boost::asio::ip::tcp::v4 ());
|
||||||
boost::asio::ip::address ourIP = boost::asio::ip::address_v4 (bytes);
|
boost::asio::ip::address_v4::bytes_type bytes;
|
||||||
m_Socket->bind (boost::asio::ip::tcp::endpoint (ourIP, 0));
|
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
|
#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));
|
||||||
|
|
Loading…
Add table
Reference in a new issue