|
|
@ -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 ()) |
|
|
@ -36,8 +55,11 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
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)); |
|
|
|
|
|
|
|
if (!m_OnlyV6) |
|
|
|
|
|
|
|
{ |
|
|
|
m_Thread = new std::thread (std::bind (&SSUServer::Run, this)); |
|
|
|
m_Thread = new std::thread (std::bind (&SSUServer::Run, this)); |
|
|
|
m_ReceiversService.post (std::bind (&SSUServer::Receive, 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)); |
|
|
|