Skip to content

Commit

Permalink
removed NTCP
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Oct 4, 2020
1 parent d595006 commit faae270
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 1,677 deletions.
1 change: 0 additions & 1 deletion build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ set(LIBI2PD_SRC
"${LIBI2PD_SRC_DIR}/NetDb.cpp"
"${LIBI2PD_SRC_DIR}/NetDbRequests.cpp"
"${LIBI2PD_SRC_DIR}/NTCP2.cpp"
"${LIBI2PD_SRC_DIR}/NTCPSession.cpp"
"${LIBI2PD_SRC_DIR}/Poly1305.cpp"
"${LIBI2PD_SRC_DIR}/Profiling.cpp"
"${LIBI2PD_SRC_DIR}/Reseed.cpp"
Expand Down
60 changes: 23 additions & 37 deletions daemon/Daemon.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* Copyright (c) 2013-2020, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
* See full license text in LICENSE file at top of project tree
*/

#include <thread>
#include <memory>

Expand All @@ -17,7 +9,6 @@
#include "Base.h"
#include "version.h"
#include "Transports.h"
#include "NTCPSession.h"
#include "RouterInfo.h"
#include "RouterContext.h"
#include "Tunnel.h"
Expand Down Expand Up @@ -135,8 +126,8 @@ namespace i2p
i2p::context.SetNetID (netID);
i2p::context.Init ();

bool ipv6; i2p::config::GetOption("ipv6", ipv6);
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
bool ipv4; i2p::config::GetOption("ipv4", ipv4);
#ifdef MESHNET
// manual override for meshnet
ipv4 = false;
Expand All @@ -151,8 +142,8 @@ namespace i2p
i2p::context.SetSupportsV6 (ipv6);
i2p::context.SetSupportsV4 (ipv4);

bool ntcp; i2p::config::GetOption("ntcp", ntcp);
i2p::context.PublishNTCPAddress (ntcp, !ipv6);
bool ntcp; i2p::config::GetOption("ntcp", ntcp);
i2p::context.PublishNTCPAddress (ntcp, !ipv6);
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
if (ntcp2)
{
Expand Down Expand Up @@ -180,13 +171,10 @@ namespace i2p
SetMaxNumTransitTunnels (transitTunnels);

bool isFloodfill; i2p::config::GetOption("floodfill", isFloodfill);
if (isFloodfill)
{
if (isFloodfill) {
LogPrint(eLogInfo, "Daemon: router will be floodfill");
i2p::context.SetFloodfill (true);
}
else
{
} else {
i2p::context.SetFloodfill (false);
}

Expand Down Expand Up @@ -254,8 +242,7 @@ namespace i2p
i2p::transport::transports.RestrictRoutesToFamilies(fams);
restricted = fams.size() > 0;
}
if (routers.length() > 0)
{
if (routers.length() > 0) {
std::set<i2p::data::IdentHash> idents;
size_t pos = 0, comma;
do
Expand Down Expand Up @@ -291,8 +278,7 @@ namespace i2p
i2p::data::netdb.Start();

bool upnp; i2p::config::GetOption("upnp.enabled", upnp);
if (upnp)
{
if (upnp) {
d.UPnP = std::unique_ptr<i2p::transport::UPnP>(new i2p::transport::UPnP);
d.UPnP->Start ();
}
Expand All @@ -304,16 +290,16 @@ namespace i2p
d.m_NTPSync->Start ();
}

bool ntcp; i2p::config::GetOption("ntcp", ntcp);
bool ssu; i2p::config::GetOption("ssu", ssu);
bool ntcp2; i2p::config::GetOption("ntcp2.enabled", ntcp2);
bool ssu; i2p::config::GetOption("ssu", ssu);
LogPrint(eLogInfo, "Daemon: starting Transports");
if(!ssu) LogPrint(eLogInfo, "Daemon: ssu disabled");
if(!ntcp) LogPrint(eLogInfo, "Daemon: ntcp disabled");
if(!ntcp2) LogPrint(eLogInfo, "Daemon: ntcp2 disabled");

i2p::transport::transports.Start(ntcp, ssu);
if (i2p::transport::transports.IsBoundNTCP() || i2p::transport::transports.IsBoundSSU() || i2p::transport::transports.IsBoundNTCP2())
i2p::transport::transports.Start(ntcp2, ssu);
if (i2p::transport::transports.IsBoundSSU() || i2p::transport::transports.IsBoundNTCP2())
LogPrint(eLogInfo, "Daemon: Transports started");
else
else
{
LogPrint(eLogError, "Daemon: failed to start Transports");
/** shut down netdb right away */
Expand All @@ -323,23 +309,23 @@ namespace i2p
}

bool http; i2p::config::GetOption("http.enabled", http);
if (http)
{
if (http) {
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
uint16_t httpPort; i2p::config::GetOption("http.port", httpPort);
LogPrint(eLogInfo, "Daemon: starting webconsole at ", httpAddr, ":", httpPort);
try
try
{
d.httpServer = std::unique_ptr<i2p::http::HTTPServer>(new i2p::http::HTTPServer(httpAddr, httpPort));
d.httpServer->Start();
}
catch (std::exception& ex)
}
catch (std::exception& ex)
{
LogPrint (eLogError, "Daemon: failed to start webconsole: ", ex.what ());
ThrowFatal ("Unable to start webconsole at ", httpAddr, ":", httpPort, ": ", ex.what ());
}
}


LogPrint(eLogInfo, "Daemon: starting Tunnels");
i2p::tunnel::tunnels.Start();

Expand All @@ -352,12 +338,12 @@ namespace i2p
std::string i2pcpAddr; i2p::config::GetOption("i2pcontrol.address", i2pcpAddr);
uint16_t i2pcpPort; i2p::config::GetOption("i2pcontrol.port", i2pcpPort);
LogPrint(eLogInfo, "Daemon: starting I2PControl at ", i2pcpAddr, ":", i2pcpPort);
try
try
{
d.m_I2PControlService = std::unique_ptr<i2p::client::I2PControlService>(new i2p::client::I2PControlService (i2pcpAddr, i2pcpPort));
d.m_I2PControlService->Start ();
}
catch (std::exception& ex)
}
catch (std::exception& ex)
{
LogPrint (eLogError, "Daemon: failed to start I2PControl: ", ex.what ());
ThrowFatal ("Unable to start I2PControl service at ", i2pcpAddr, ":", i2pcpPort, ": ", ex.what ());
Expand All @@ -374,7 +360,7 @@ namespace i2p
LogPrint(eLogInfo, "Daemon: stopping Tunnels");
i2p::tunnel::tunnels.Stop();

if (d.UPnP)
if (d.UPnP)
{
d.UPnP->Stop ();
d.UPnP = nullptr;
Expand Down
7 changes: 0 additions & 7 deletions daemon/HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,6 @@ namespace http {
void ShowTransports (std::stringstream& s)
{
s << "<b>Transports:</b><br>\r\n";
auto ntcpServer = i2p::transport::transports.GetNTCPServer ();
if (ntcpServer)
{
auto sessions = ntcpServer->GetNTCPSessions ();
if (!sessions.empty ())
ShowNTCPTransports (s, sessions, "NTCP");
}
auto ntcp2Server = i2p::transport::transports.GetNTCP2Server ();
if (ntcp2Server)
{
Expand Down
2 changes: 1 addition & 1 deletion libi2pd/NTCP2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ namespace transport
{

auto timer = std::make_shared<boost::asio::deadline_timer>(GetService());
auto timeout = NTCP_CONNECT_TIMEOUT * 5;
auto timeout = NTCP2_CONNECT_TIMEOUT * 5;
conn->SetTerminationTimeout(timeout * 2);
timer->expires_from_now (boost::posix_time::seconds(timeout));
timer->async_wait ([conn, timeout](const boost::system::error_code& ecode)
Expand Down
Loading

0 comments on commit faae270

Please sign in to comment.