mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
removed NTCP
This commit is contained in:
parent
d595006d1f
commit
faae2709d9
9 changed files with 30 additions and 1677 deletions
|
@ -133,7 +133,7 @@ namespace transport
|
|||
Transports::Transports ():
|
||||
m_IsOnline (true), m_IsRunning (false), m_IsNAT (true), m_Thread (nullptr), m_Service (nullptr),
|
||||
m_Work (nullptr), m_PeerCleanupTimer (nullptr), m_PeerTestTimer (nullptr),
|
||||
m_NTCPServer (nullptr), m_SSUServer (nullptr), m_NTCP2Server (nullptr),
|
||||
m_SSUServer (nullptr), m_NTCP2Server (nullptr),
|
||||
m_DHKeysPairSupplier (5), m_X25519KeysPairSupplier (5), // 5 pre-generated keys
|
||||
m_TotalSentBytes(0), m_TotalReceivedBytes(0), m_TotalTransitTransmittedBytes (0),
|
||||
m_InBandwidth (0), m_OutBandwidth (0), m_TransitBandwidth(0),
|
||||
|
@ -154,7 +154,7 @@ namespace transport
|
|||
}
|
||||
}
|
||||
|
||||
void Transports::Start (bool enableNTCP, bool enableSSU)
|
||||
void Transports::Start (bool enableNTCP2, bool enableSSU)
|
||||
{
|
||||
if (!m_Service)
|
||||
{
|
||||
|
@ -169,50 +169,10 @@ namespace transport
|
|||
m_X25519KeysPairSupplier.Start ();
|
||||
m_IsRunning = true;
|
||||
m_Thread = new std::thread (std::bind (&Transports::Run, this));
|
||||
std::string ntcpproxy; i2p::config::GetOption("ntcpproxy", ntcpproxy);
|
||||
std::string ntcp2proxy; i2p::config::GetOption("ntcp2.proxy", ntcp2proxy);
|
||||
i2p::http::URL proxyurl;
|
||||
uint16_t softLimit, hardLimit, threads;
|
||||
i2p::config::GetOption("limits.ntcpsoft", softLimit);
|
||||
i2p::config::GetOption("limits.ntcphard", hardLimit);
|
||||
i2p::config::GetOption("limits.ntcpthreads", threads);
|
||||
if(softLimit > 0 && hardLimit > 0 && softLimit >= hardLimit)
|
||||
{
|
||||
LogPrint(eLogError, "ntcp soft limit must be less than ntcp hard limit");
|
||||
return;
|
||||
}
|
||||
if(ntcpproxy.size() && enableNTCP)
|
||||
{
|
||||
if(proxyurl.parse(ntcpproxy))
|
||||
{
|
||||
if(proxyurl.schema == "socks" || proxyurl.schema == "http")
|
||||
{
|
||||
m_NTCPServer = new NTCPServer(threads);
|
||||
m_NTCPServer->SetSessionLimits(softLimit, hardLimit);
|
||||
NTCPServer::ProxyType proxytype = NTCPServer::eSocksProxy;
|
||||
|
||||
if (proxyurl.schema == "http")
|
||||
proxytype = NTCPServer::eHTTPProxy;
|
||||
m_NTCPServer->UseProxy(proxytype, proxyurl.host, proxyurl.port);
|
||||
m_NTCPServer->Start();
|
||||
if(!m_NTCPServer->NetworkIsReady())
|
||||
{
|
||||
LogPrint(eLogError, "Transports: NTCP failed to start with proxy");
|
||||
m_NTCPServer->Stop();
|
||||
delete m_NTCPServer;
|
||||
m_NTCPServer = nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
LogPrint(eLogError, "Transports: unsupported NTCP proxy URL ", ntcpproxy);
|
||||
}
|
||||
else
|
||||
LogPrint(eLogError, "Transports: invalid NTCP proxy url ", ntcpproxy);
|
||||
return;
|
||||
}
|
||||
i2p::http::URL proxyurl;
|
||||
// create NTCP2. TODO: move to acceptor
|
||||
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
|
||||
if (ntcp2)
|
||||
if (enableNTCP2)
|
||||
{
|
||||
if(!ntcp2proxy.empty())
|
||||
{
|
||||
|
@ -248,20 +208,6 @@ namespace transport
|
|||
for (const auto& address : addresses)
|
||||
{
|
||||
if (!address) continue;
|
||||
if (m_NTCPServer == nullptr && enableNTCP)
|
||||
{
|
||||
m_NTCPServer = new NTCPServer (threads);
|
||||
m_NTCPServer->SetSessionLimits(softLimit, hardLimit);
|
||||
m_NTCPServer->Start ();
|
||||
if (!(m_NTCPServer->IsBoundV6() || m_NTCPServer->IsBoundV4())) {
|
||||
/** failed to bind to NTCP */
|
||||
LogPrint(eLogError, "Transports: failed to bind to TCP");
|
||||
m_NTCPServer->Stop();
|
||||
delete m_NTCPServer;
|
||||
m_NTCPServer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (address->transportStyle == RouterInfo::eTransportSSU)
|
||||
{
|
||||
if (m_SSUServer == nullptr && enableSSU)
|
||||
|
@ -306,13 +252,7 @@ namespace transport
|
|||
delete m_SSUServer;
|
||||
m_SSUServer = nullptr;
|
||||
}
|
||||
if (m_NTCPServer)
|
||||
{
|
||||
m_NTCPServer->Stop ();
|
||||
delete m_NTCPServer;
|
||||
m_NTCPServer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
if (m_NTCP2Server)
|
||||
{
|
||||
m_NTCP2Server->Stop ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue