mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 02:44:15 +00:00
prefer public ipv6 instead rfc4941 (closes #1251)
Wokrs only on linux-based systems. Not tested on other *nix systems, and not works on windows. Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
a0e545a6f1
commit
ed42948051
@ -23,6 +23,10 @@
|
|||||||
#include "HTTP.h"
|
#include "HTTP.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <linux/in6.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
namespace transport
|
namespace transport
|
||||||
@ -1198,6 +1202,11 @@ namespace transport
|
|||||||
ep = boost::asio::ip::tcp::endpoint (m_Address6->address(), address->port);
|
ep = boost::asio::ip::tcp::endpoint (m_Address6->address(), address->port);
|
||||||
else if (m_YggdrasilAddress && !context.SupportsV6 ())
|
else if (m_YggdrasilAddress && !context.SupportsV6 ())
|
||||||
ep = boost::asio::ip::tcp::endpoint (m_YggdrasilAddress->address(), address->port);
|
ep = boost::asio::ip::tcp::endpoint (m_YggdrasilAddress->address(), address->port);
|
||||||
|
#ifdef __linux__
|
||||||
|
// Set preference to use public IPv6 address -- tested on linux, not works on windows, and not tested on others
|
||||||
|
typedef boost::asio::detail::socket_option::boolean<IPV6_ADDR_PREFERENCES, IPV6_PREFER_SRC_PUBLIC> ipv6PreferPubAddr;
|
||||||
|
m_NTCP2V6Acceptor->set_option (ipv6PreferPubAddr (true));
|
||||||
|
#endif
|
||||||
m_NTCP2V6Acceptor->bind (ep);
|
m_NTCP2V6Acceptor->bind (ep);
|
||||||
m_NTCP2V6Acceptor->listen ();
|
m_NTCP2V6Acceptor->listen ();
|
||||||
|
|
||||||
|
@ -14,6 +14,10 @@
|
|||||||
#include "SSU.h"
|
#include "SSU.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <linux/in6.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <boost/winapi/error_codes.hpp>
|
#include <boost/winapi/error_codes.hpp>
|
||||||
#endif
|
#endif
|
||||||
@ -62,6 +66,11 @@ namespace transport
|
|||||||
m_SocketV6.set_option (boost::asio::ip::v6_only (true));
|
m_SocketV6.set_option (boost::asio::ip::v6_only (true));
|
||||||
m_SocketV6.set_option (boost::asio::socket_base::receive_buffer_size (SSU_SOCKET_RECEIVE_BUFFER_SIZE));
|
m_SocketV6.set_option (boost::asio::socket_base::receive_buffer_size (SSU_SOCKET_RECEIVE_BUFFER_SIZE));
|
||||||
m_SocketV6.set_option (boost::asio::socket_base::send_buffer_size (SSU_SOCKET_SEND_BUFFER_SIZE));
|
m_SocketV6.set_option (boost::asio::socket_base::send_buffer_size (SSU_SOCKET_SEND_BUFFER_SIZE));
|
||||||
|
#ifdef __linux__
|
||||||
|
// Set preference to use public IPv6 address -- tested on linux, not works on windows, and not tested on others
|
||||||
|
typedef boost::asio::detail::socket_option::boolean<IPV6_ADDR_PREFERENCES, IPV6_PREFER_SRC_PUBLIC> ipv6PreferPubAddr;
|
||||||
|
m_SocketV6.set_option (ipv6PreferPubAddr(true));
|
||||||
|
#endif
|
||||||
m_SocketV6.bind (m_EndpointV6);
|
m_SocketV6.bind (m_EndpointV6);
|
||||||
LogPrint (eLogInfo, "SSU: Start listening v6 port ", m_EndpointV6.port());
|
LogPrint (eLogInfo, "SSU: Start listening v6 port ", m_EndpointV6.port());
|
||||||
}
|
}
|
||||||
|
@ -177,13 +177,13 @@ namespace util
|
|||||||
|
|
||||||
SaveStateHelper (T& orig): m_Original (orig), m_Copy (orig) {};
|
SaveStateHelper (T& orig): m_Original (orig), m_Copy (orig) {};
|
||||||
~SaveStateHelper () { m_Original = m_Copy; };
|
~SaveStateHelper () { m_Original = m_Copy; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
T& m_Original;
|
T& m_Original;
|
||||||
T m_Copy;
|
T m_Copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace net
|
namespace net
|
||||||
{
|
{
|
||||||
int GetMTU (const boost::asio::ip::address& localAddress);
|
int GetMTU (const boost::asio::ip::address& localAddress);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user