|
|
@ -7,6 +7,7 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include <pthread.h> |
|
|
|
#include "Log.h" |
|
|
|
#include "Log.h" |
|
|
|
#include "Timestamp.h" |
|
|
|
#include "Timestamp.h" |
|
|
|
#include "RouterContext.h" |
|
|
|
#include "RouterContext.h" |
|
|
@ -23,7 +24,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
SSUServer::SSUServer (const boost::asio::ip::address & addr, int port): |
|
|
|
SSUServer::SSUServer (const boost::asio::ip::address & addr, int port): |
|
|
|
m_OnlyV6(true), m_IsRunning(false), m_Thread (nullptr), |
|
|
|
m_OnlyV6(true), m_IsRunning(false), m_Thread (nullptr), |
|
|
|
m_ReceiversThread (nullptr), m_ReceiversThreadV6 (nullptr), m_Work (m_Service), |
|
|
|
m_ReceiversThread (nullptr), m_ReceiversThreadV6 (nullptr), m_Work (m_Service), |
|
|
|
m_ReceiversWork (m_ReceiversService), m_ReceiversWorkV6 (m_ReceiversServiceV6), |
|
|
|
m_ReceiversWork (m_ReceiversService), m_ReceiversWorkV6 (m_ReceiversServiceV6), |
|
|
|
m_EndpointV6 (addr, port), m_Socket (m_ReceiversService, m_Endpoint), |
|
|
|
m_EndpointV6 (addr, port), m_Socket (m_ReceiversService, m_Endpoint), |
|
|
@ -36,7 +37,7 @@ namespace transport |
|
|
|
|
|
|
|
|
|
|
|
SSUServer::SSUServer (int port): |
|
|
|
SSUServer::SSUServer (int port): |
|
|
|
m_OnlyV6(false), m_IsRunning(false), m_Thread (nullptr), |
|
|
|
m_OnlyV6(false), m_IsRunning(false), m_Thread (nullptr), |
|
|
|
m_ReceiversThread (nullptr), m_ReceiversThreadV6 (nullptr), m_Work (m_Service), |
|
|
|
m_ReceiversThread (nullptr), m_ReceiversThreadV6 (nullptr), m_Work (m_Service), |
|
|
|
m_ReceiversWork (m_ReceiversService), m_ReceiversWorkV6 (m_ReceiversServiceV6), |
|
|
|
m_ReceiversWork (m_ReceiversService), m_ReceiversWorkV6 (m_ReceiversServiceV6), |
|
|
|
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_SocketV6 (m_ReceiversServiceV6), |
|
|
|
m_Socket (m_ReceiversService), m_SocketV6 (m_ReceiversServiceV6), |
|
|
@ -100,7 +101,7 @@ namespace transport |
|
|
|
if (context.SupportsV6 ()) |
|
|
|
if (context.SupportsV6 ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_ReceiversThreadV6 = new std::thread (std::bind (&SSUServer::RunReceiversV6, this)); |
|
|
|
m_ReceiversThreadV6 = new std::thread (std::bind (&SSUServer::RunReceiversV6, this)); |
|
|
|
if (!m_Thread) |
|
|
|
if (!m_Thread) |
|
|
|
m_Thread = new std::thread (std::bind (&SSUServer::Run, this)); |
|
|
|
m_Thread = new std::thread (std::bind (&SSUServer::Run, this)); |
|
|
|
m_ReceiversServiceV6.post (std::bind (&SSUServer::ReceiveV6, this)); |
|
|
|
m_ReceiversServiceV6.post (std::bind (&SSUServer::ReceiveV6, this)); |
|
|
|
ScheduleTerminationV6 (); |
|
|
|
ScheduleTerminationV6 (); |
|
|
@ -142,6 +143,8 @@ namespace transport |
|
|
|
|
|
|
|
|
|
|
|
void SSUServer::Run () |
|
|
|
void SSUServer::Run () |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
pthread_setname_np(pthread_self(), "SSU"); |
|
|
|
|
|
|
|
|
|
|
|
while (m_IsRunning) |
|
|
|
while (m_IsRunning) |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
@ -157,6 +160,8 @@ namespace transport |
|
|
|
|
|
|
|
|
|
|
|
void SSUServer::RunReceivers () |
|
|
|
void SSUServer::RunReceivers () |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
pthread_setname_np(pthread_self(), "SSUv4"); |
|
|
|
|
|
|
|
|
|
|
|
while (m_IsRunning) |
|
|
|
while (m_IsRunning) |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
@ -179,6 +184,8 @@ namespace transport |
|
|
|
|
|
|
|
|
|
|
|
void SSUServer::RunReceiversV6 () |
|
|
|
void SSUServer::RunReceiversV6 () |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
pthread_setname_np(pthread_self(), "SSUv6"); |
|
|
|
|
|
|
|
|
|
|
|
while (m_IsRunning) |
|
|
|
while (m_IsRunning) |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
|