mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
try adding ipv6 only mode for ssu
This commit is contained in:
parent
4cf4436169
commit
a3b08654b4
32
SSU.cpp
32
SSU.cpp
@ -10,12 +10,31 @@ namespace i2p
|
|||||||
{
|
{
|
||||||
namespace transport
|
namespace transport
|
||||||
{
|
{
|
||||||
SSUServer::SSUServer (int port): m_Thread (nullptr), m_ThreadV6 (nullptr), m_ReceiversThread (nullptr),
|
|
||||||
|
SSUServer::SSUServer (const boost::asio::ip::address & addr, int port):
|
||||||
|
m_OnlyV6(true), m_IsRunning(false),
|
||||||
|
m_Thread (nullptr), m_ThreadV6 (nullptr), m_ReceiversThread (nullptr),
|
||||||
|
m_Work (m_Service), m_WorkV6 (m_ServiceV6), m_ReceiversWork (m_ReceiversService),
|
||||||
|
m_EndpointV6 (addr, port),
|
||||||
|
m_Socket (m_ReceiversService, m_Endpoint), m_SocketV6 (m_ReceiversService),
|
||||||
|
m_IntroducersUpdateTimer (m_Service), m_PeerTestsCleanupTimer (m_Service)
|
||||||
|
{
|
||||||
|
m_SocketV6.open (boost::asio::ip::udp::v6());
|
||||||
|
m_SocketV6.set_option (boost::asio::ip::v6_only (true));
|
||||||
|
m_SocketV6.set_option (boost::asio::socket_base::receive_buffer_size (65535));
|
||||||
|
m_SocketV6.set_option (boost::asio::socket_base::send_buffer_size (65535));
|
||||||
|
m_SocketV6.bind (m_EndpointV6);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSUServer::SSUServer (int port):
|
||||||
|
m_OnlyV6(false), m_IsRunning(false),
|
||||||
|
m_Thread (nullptr), m_ThreadV6 (nullptr), m_ReceiversThread (nullptr),
|
||||||
m_Work (m_Service), m_WorkV6 (m_ServiceV6), m_ReceiversWork (m_ReceiversService),
|
m_Work (m_Service), m_WorkV6 (m_ServiceV6), m_ReceiversWork (m_ReceiversService),
|
||||||
m_Endpoint (boost::asio::ip::udp::v4 (), port), m_EndpointV6 (boost::asio::ip::udp::v6 (), port),
|
m_Endpoint (boost::asio::ip::udp::v4 (), port), m_EndpointV6 (boost::asio::ip::udp::v6 (), port),
|
||||||
m_Socket (m_ReceiversService, m_Endpoint), m_SocketV6 (m_ReceiversService),
|
m_Socket (m_ReceiversService, m_Endpoint), m_SocketV6 (m_ReceiversService),
|
||||||
m_IntroducersUpdateTimer (m_Service), m_PeerTestsCleanupTimer (m_Service)
|
m_IntroducersUpdateTimer (m_Service), m_PeerTestsCleanupTimer (m_Service)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_Socket.set_option (boost::asio::socket_base::receive_buffer_size (65535));
|
m_Socket.set_option (boost::asio::socket_base::receive_buffer_size (65535));
|
||||||
m_Socket.set_option (boost::asio::socket_base::send_buffer_size (65535));
|
m_Socket.set_option (boost::asio::socket_base::send_buffer_size (65535));
|
||||||
if (context.SupportsV6 ())
|
if (context.SupportsV6 ())
|
||||||
@ -35,13 +54,16 @@ namespace transport
|
|||||||
void SSUServer::Start ()
|
void SSUServer::Start ()
|
||||||
{
|
{
|
||||||
m_IsRunning = true;
|
m_IsRunning = true;
|
||||||
m_ReceiversThread = new std::thread (std::bind (&SSUServer::RunReceivers, this));
|
m_ReceiversThread = new std::thread (std::bind (&SSUServer::RunReceivers, this));
|
||||||
m_Thread = new std::thread (std::bind (&SSUServer::Run, this));
|
if (!m_OnlyV6)
|
||||||
m_ReceiversService.post (std::bind (&SSUServer::Receive, this));
|
{
|
||||||
|
m_Thread = new std::thread (std::bind (&SSUServer::Run, this));
|
||||||
|
m_ReceiversService.post (std::bind (&SSUServer::Receive, this));
|
||||||
|
}
|
||||||
if (context.SupportsV6 ())
|
if (context.SupportsV6 ())
|
||||||
{
|
{
|
||||||
m_ThreadV6 = new std::thread (std::bind (&SSUServer::RunV6, this));
|
m_ThreadV6 = new std::thread (std::bind (&SSUServer::RunV6, this));
|
||||||
m_ReceiversService.post (std::bind (&SSUServer::ReceiveV6, this));
|
m_ReceiversService.post (std::bind (&SSUServer::ReceiveV6, this));
|
||||||
}
|
}
|
||||||
SchedulePeerTestsCleanupTimer ();
|
SchedulePeerTestsCleanupTimer ();
|
||||||
ScheduleIntroducersUpdateTimer (); // wait for 30 seconds and decide if we need introducers
|
ScheduleIntroducersUpdateTimer (); // wait for 30 seconds and decide if we need introducers
|
||||||
|
4
SSU.h
4
SSU.h
@ -37,6 +37,7 @@ namespace transport
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
SSUServer (int port);
|
SSUServer (int port);
|
||||||
|
SSUServer (const boost::asio::ip::address & addr, int port); // ipv6 only constructor
|
||||||
~SSUServer ();
|
~SSUServer ();
|
||||||
void Start ();
|
void Start ();
|
||||||
void Stop ();
|
void Stop ();
|
||||||
@ -93,8 +94,9 @@ namespace transport
|
|||||||
uint64_t creationTime;
|
uint64_t creationTime;
|
||||||
PeerTestParticipant role;
|
PeerTestParticipant role;
|
||||||
std::shared_ptr<SSUSession> session; // for Bob to Alice
|
std::shared_ptr<SSUSession> session; // for Bob to Alice
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool m_OnlyV6;
|
||||||
bool m_IsRunning;
|
bool m_IsRunning;
|
||||||
std::thread * m_Thread, * m_ThreadV6, * m_ReceiversThread;
|
std::thread * m_Thread, * m_ThreadV6, * m_ReceiversThread;
|
||||||
boost::asio::io_service m_Service, m_ServiceV6, m_ReceiversService;
|
boost::asio::io_service m_Service, m_ServiceV6, m_ReceiversService;
|
||||||
|
@ -120,11 +120,14 @@ namespace transport
|
|||||||
m_NTCPServer->Start ();
|
m_NTCPServer->Start ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address->transportStyle == RouterInfo::eTransportSSU && address->host.is_v4 ())
|
if (address->transportStyle == RouterInfo::eTransportSSU)
|
||||||
{
|
{
|
||||||
if (!m_SSUServer)
|
if (!m_SSUServer)
|
||||||
{
|
{
|
||||||
m_SSUServer = new SSUServer (address->port);
|
if (address->host.is_v4())
|
||||||
|
m_SSUServer = new SSUServer (address->port);
|
||||||
|
else
|
||||||
|
m_SSUServer = new SSUServer (address->host, address->port);
|
||||||
LogPrint (eLogInfo, "Transports: Start listening UDP port ", address->port);
|
LogPrint (eLogInfo, "Transports: Start listening UDP port ", address->port);
|
||||||
m_SSUServer->Start ();
|
m_SSUServer->Start ();
|
||||||
DetectExternalIP ();
|
DetectExternalIP ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user