diff --git a/Config.cpp b/Config.cpp index e6d44d59..3156ac66 100644 --- a/Config.cpp +++ b/Config.cpp @@ -124,6 +124,8 @@ namespace config { ("notransit", value()->zero_tokens()->default_value(false), "Router will not accept transit tunnels at startup") ("floodfill", value()->zero_tokens()->default_value(false), "Router will be floodfill") ("bandwidth", value()->default_value(""), "Bandwidth limit: integer in kbps or letters: L (32), O (256), P (2048), X (>9000)") + ("ntcp", value()->zero_tokens()->default_value(true), "enable ntcp transport") + ("ssu", value()->zero_tokens()->default_value(true), "enable ssu transport") #ifdef _WIN32 ("svcctl", value()->default_value(""), "Windows service management ('install' or 'remove')") ("insomnia", value()->zero_tokens()->default_value(false), "Prevent system from sleeping") diff --git a/Daemon.cpp b/Daemon.cpp index b580f827..0a82a5cb 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -205,8 +205,10 @@ namespace i2p LogPrint(eLogInfo, "Daemon: starting UPnP"); d.m_UPnP.Start (); #endif + bool ntcp; i2p::config::GetOption("ntcp", ntcp); + bool ssu; i2p::config::GetOption("ssu", ssu); LogPrint(eLogInfo, "Daemon: starting Transports"); - i2p::transport::transports.Start(); + i2p::transport::transports.Start(ntcp, ssu); if (i2p::transport::transports.IsBoundNTCP() || i2p::transport::transports.IsBoundSSU()) { LogPrint(eLogInfo, "Daemon: Transports started"); } else { diff --git a/I2CP.cpp b/I2CP.cpp index b7f91cdd..3005efd0 100644 --- a/I2CP.cpp +++ b/I2CP.cpp @@ -474,11 +474,16 @@ namespace client { offset += identsize; uint32_t payloadLen = bufbe32toh (buf + offset); - offset += 4; - uint32_t nonce = bufbe32toh (buf + offset + payloadLen); - if (m_IsSendAccepted) - SendMessageStatusMessage (nonce, eI2CPMessageStatusAccepted); // accepted - m_Destination->SendMsgTo (buf + offset, payloadLen, identity.GetIdentHash (), nonce); + if (payloadLen + offset <= len) + { + offset += 4; + uint32_t nonce = bufbe32toh (buf + offset + payloadLen); + if (m_IsSendAccepted) + SendMessageStatusMessage (nonce, eI2CPMessageStatusAccepted); // accepted + m_Destination->SendMsgTo (buf + offset, payloadLen, identity.GetIdentHash (), nonce); + } + else + LogPrint(eLogError, "I2CP: cannot send message, too big"); } else LogPrint(eLogError, "I2CP: invalid identity"); diff --git a/Makefile.linux b/Makefile.linux index e00fd705..70e9e7dd 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -28,15 +28,15 @@ endif NEEDED_CXXFLAGS += -fPIC ifeq ($(USE_STATIC),yes) - LIBDIR := /usr/lib + #LIBDIR = /usr/lib LDLIBS = $(LIBDIR)/libboost_system.a LDLIBS += $(LIBDIR)/libboost_date_time.a LDLIBS += $(LIBDIR)/libboost_filesystem.a LDLIBS += $(LIBDIR)/libboost_program_options.a - LDLIBS += $(LIBDIR)/libcrypto.a LDLIBS += $(LIBDIR)/libssl.a + LDLIBS += $(LIBDIR)/libcrypto.a LDLIBS += $(LIBDIR)/libz.a - LDLIBS += -lpthread -static-libstdc++ -static-libgcc + LDLIBS += -lpthread -static-libstdc++ -static-libgcc -lrt USE_AESNI := no else LDLIBS = -lcrypto -lssl -lz -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread diff --git a/Transports.cpp b/Transports.cpp index 52b1d261..be27ffd1 100644 --- a/Transports.cpp +++ b/Transports.cpp @@ -105,7 +105,7 @@ namespace transport Stop (); } - void Transports::Start () + void Transports::Start (bool enableNTCP, bool enableSSU) { m_DHKeysPairSupplier.Start (); m_IsRunning = true; @@ -114,7 +114,7 @@ namespace transport auto& addresses = context.GetRouterInfo ().GetAddresses (); for (auto address : addresses) { - if (!m_NTCPServer) + if (!m_NTCPServer && enableNTCP) { m_NTCPServer = new NTCPServer (); m_NTCPServer->Start (); @@ -129,7 +129,7 @@ namespace transport if (address->transportStyle == RouterInfo::eTransportSSU && address->host.is_v4 ()) { - if (!m_SSUServer) + if (!m_SSUServer && enableSSU) { m_SSUServer = new SSUServer (address->port); LogPrint (eLogInfo, "Transports: Start listening UDP port ", address->port); diff --git a/Transports.h b/Transports.h index 0e1b621b..a7e7dc1d 100644 --- a/Transports.h +++ b/Transports.h @@ -73,7 +73,7 @@ namespace transport Transports (); ~Transports (); - void Start (); + void Start (bool enableNTCP=true, bool enableSSU=true); void Stop (); bool IsBoundNTCP() const { return m_NTCPServer != nullptr; }