From 85e65da4925ed77a3bd3ba5a9c8d16f27ddb6ad6 Mon Sep 17 00:00:00 2001 From: xcps Date: Tue, 30 Aug 2016 01:48:37 +0500 Subject: [PATCH 1/4] server tunnel on linux binds on 127.x.x.x --- I2PTunnel.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index ad06328b..fc4da719 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -50,9 +50,21 @@ namespace client 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, shared_from_this (), std::placeholders::_1)); + } } void I2PTunnelConnection::Terminate () From f2893097a7870c567ef33c92bf48896e194fcc51 Mon Sep 17 00:00:00 2001 From: xcps Date: Tue, 30 Aug 2016 02:53:26 +0500 Subject: [PATCH 2/4] check before bind to 127.x.x.x --- I2PTunnel.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index fc4da719..cca56120 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -54,13 +54,18 @@ namespace client #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)); + + if (m_RemoteEndpoint.address ().is_v4 () && + m_RemoteEndpoint.address ().to_v4 ().to_bytes ()[0] == 127) + { + 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, shared_from_this (), std::placeholders::_1)); From 8cb69c14826ec2988afb6ca6367c3c8c3bf89d7a Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 31 Aug 2016 22:47:32 -0400 Subject: [PATCH 3/4] fixed #624. correct v6 address size --- SSUSession.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SSUSession.cpp b/SSUSession.cpp index 9245f652..26c14570 100644 --- a/SSUSession.cpp +++ b/SSUSession.cpp @@ -991,7 +991,7 @@ namespace transport else // v6 { boost::asio::ip::address_v6::bytes_type bytes; - memcpy (bytes.data (), address, 6); + memcpy (bytes.data (), address, 16); addr = boost::asio::ip::address_v6 (bytes); } SendPeerTest (nonce, addr, be16toh (port), introKey); // to Alice with her address received from Bob @@ -1033,7 +1033,7 @@ namespace transport } else if (address.is_v6 ()) { - *payload = 6; + *payload = 16; memcpy (payload + 1, address.to_v6 ().to_bytes ().data (), 16); // our IP V6 } else From aa687afd37d244cedb0939daaa7bd1867f75f26a Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 1 Sep 2016 09:48:04 -0400 Subject: [PATCH 4/4] updated LeaseSet must be sent after completion --- Destination.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Destination.cpp b/Destination.cpp index 42351787..5842e26d 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -203,6 +203,7 @@ namespace client void LeaseSetDestination::SetLeaseSet (i2p::data::LocalLeaseSet * newLeaseSet) { m_LeaseSet.reset (newLeaseSet); + i2p::garlic::GarlicDestination::SetLeaseSetUpdated (); if (m_IsPublic) { m_PublishVerificationTimer.cancel (); @@ -391,8 +392,7 @@ namespace client } void LeaseSetDestination::SetLeaseSetUpdated () - { - i2p::garlic::GarlicDestination::SetLeaseSetUpdated (); + { UpdateLeaseSet (); }