|
|
@ -189,7 +189,6 @@ namespace transport |
|
|
|
proxytype = NTCP2Server::eHTTPProxy; |
|
|
|
proxytype = NTCP2Server::eHTTPProxy; |
|
|
|
|
|
|
|
|
|
|
|
m_NTCP2Server->UseProxy(proxytype, proxyurl.host, proxyurl.port); |
|
|
|
m_NTCP2Server->UseProxy(proxytype, proxyurl.host, proxyurl.port); |
|
|
|
m_NTCP2Server->Start(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint(eLogError, "Transports: unsupported NTCP2 proxy URL ", ntcp2proxy); |
|
|
|
LogPrint(eLogError, "Transports: unsupported NTCP2 proxy URL ", ntcp2proxy); |
|
|
@ -199,9 +198,35 @@ namespace transport |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
m_NTCP2Server = new NTCP2Server (); |
|
|
|
m_NTCP2Server = new NTCP2Server (); |
|
|
|
m_NTCP2Server->Start (); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create acceptors
|
|
|
|
|
|
|
|
auto& addresses = context.GetRouterInfo ().GetAddresses (); |
|
|
|
|
|
|
|
for (const auto& address : addresses) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!address) continue; |
|
|
|
|
|
|
|
if (address->transportStyle == RouterInfo::eTransportSSU) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (m_SSUServer == nullptr && enableSSU) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
m_SSUServer->Start (); |
|
|
|
|
|
|
|
} catch ( std::exception & ex ) { |
|
|
|
|
|
|
|
LogPrint(eLogError, "Transports: Failed to bind to UDP port", address->port); |
|
|
|
|
|
|
|
delete m_SSUServer; |
|
|
|
|
|
|
|
m_SSUServer = nullptr; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
DetectExternalIP (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
LogPrint (eLogError, "Transports: SSU server already exists"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -245,34 +270,9 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// create acceptors
|
|
|
|
// start servers
|
|
|
|
auto& addresses = context.GetRouterInfo ().GetAddresses (); |
|
|
|
if (m_NTCP2Server) m_NTCP2Server->Start (); |
|
|
|
for (const auto& address : addresses) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!address) continue; |
|
|
|
|
|
|
|
if (address->transportStyle == RouterInfo::eTransportSSU) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (m_SSUServer == nullptr && enableSSU) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
m_SSUServer->Start (); |
|
|
|
|
|
|
|
} catch ( std::exception & ex ) { |
|
|
|
|
|
|
|
LogPrint(eLogError, "Transports: Failed to bind to UDP port", address->port); |
|
|
|
|
|
|
|
delete m_SSUServer; |
|
|
|
|
|
|
|
m_SSUServer = nullptr; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
DetectExternalIP (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
LogPrint (eLogError, "Transports: SSU server already exists"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT)); |
|
|
|
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT)); |
|
|
|
m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1)); |
|
|
|
m_PeerCleanupTimer->async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1)); |
|
|
|
|
|
|
|
|
|
|
|