From a8bd87938dcaba7bc921d2383446bb16f53ba488 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 13 Jan 2017 13:47:51 -0500 Subject: [PATCH] honor enableuniquelocal for all server tunnel types --- I2PTunnel.cpp | 24 +++++++++++------------- I2PTunnel.h | 7 ++++--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index 6f45bcbe..843d129f 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -509,15 +509,17 @@ namespace client return; } } - CreateI2PConnection (stream); + // new connection + auto conn = CreateI2PConnection (stream); + AddHandler (conn); + conn->Connect (m_IsUniqueLocal); } } - void I2PServerTunnel::CreateI2PConnection (std::shared_ptr stream) + std::shared_ptr I2PServerTunnel::CreateI2PConnection (std::shared_ptr stream) { - auto conn = std::make_shared (this, stream, std::make_shared (GetService ()), GetEndpoint ()); - AddHandler (conn); - conn->Connect (m_IsUniqueLocal); + return std::make_shared (this, stream, std::make_shared (GetService ()), GetEndpoint ()); + } I2PServerTunnelHTTP::I2PServerTunnelHTTP (const std::string& name, const std::string& address, @@ -528,12 +530,10 @@ namespace client { } - void I2PServerTunnelHTTP::CreateI2PConnection (std::shared_ptr stream) + std::shared_ptr I2PServerTunnelHTTP::CreateI2PConnection (std::shared_ptr stream) { - auto conn = std::make_shared (this, stream, + return std::make_shared (this, stream, std::make_shared (GetService ()), GetEndpoint (), m_Host); - AddHandler (conn); - conn->Connect (); } I2PServerTunnelIRC::I2PServerTunnelIRC (const std::string& name, const std::string& address, @@ -544,11 +544,9 @@ namespace client { } - void I2PServerTunnelIRC::CreateI2PConnection (std::shared_ptr stream) + std::shared_ptr I2PServerTunnelIRC::CreateI2PConnection (std::shared_ptr stream) { - auto conn = std::make_shared (this, stream, std::make_shared (GetService ()), GetEndpoint (), this->m_WebircPass); - AddHandler (conn); - conn->Connect (); + return std::make_shared (this, stream, std::make_shared (GetService ()), GetEndpoint (), this->m_WebircPass); } void I2PUDPServerTunnel::HandleRecvFromI2P(const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len) diff --git a/I2PTunnel.h b/I2PTunnel.h index fab33803..4b9b2c9b 100644 --- a/I2PTunnel.h +++ b/I2PTunnel.h @@ -268,6 +268,7 @@ namespace client void SetAccessList (const std::set& accessList); void SetUniqueLocal (bool isUniqueLocal) { m_IsUniqueLocal = isUniqueLocal; } + bool IsUniqueLocal () const { return m_IsUniqueLocal; } const std::string& GetAddress() const { return m_Address; } int GetPort () const { return m_Port; }; @@ -285,7 +286,7 @@ namespace client void Accept (); void HandleAccept (std::shared_ptr stream); - virtual void CreateI2PConnection (std::shared_ptr stream); + virtual std::shared_ptr CreateI2PConnection (std::shared_ptr stream); private: @@ -308,7 +309,7 @@ namespace client private: - void CreateI2PConnection (std::shared_ptr stream); + std::shared_ptr CreateI2PConnection (std::shared_ptr stream); private: @@ -325,7 +326,7 @@ namespace client private: - void CreateI2PConnection (std::shared_ptr stream); + std::shared_ptr CreateI2PConnection (std::shared_ptr stream); private: