From cd549937c5b337f49cfba56c2e7f4b54d0917bbd Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 17 Jan 2016 18:55:09 -0500 Subject: [PATCH] support multiple server tunnels with same destination and different ports --- ClientContext.cpp | 4 +++- ClientContext.h | 3 ++- HTTPServer.cpp | 1 + I2PTunnel.h | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index 791ab563..e93f9a4a 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -310,7 +310,9 @@ namespace client while (comma != std::string::npos); serverTunnel->SetAccessList (idents); } - if (m_ServerTunnels.insert (std::make_pair (localDestination->GetIdentHash (), std::unique_ptr(serverTunnel))).second) + if (m_ServerTunnels.insert (std::make_pair ( + std::make_tuple (localDestination->GetIdentHash (), inPort), + std::unique_ptr(serverTunnel))).second) serverTunnel->Start (); else LogPrint (eLogError, "Clients: I2P server tunnel for destination ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), " already exists"); diff --git a/ClientContext.h b/ClientContext.h index 1750f2b5..52f1ab5b 100644 --- a/ClientContext.h +++ b/ClientContext.h @@ -2,6 +2,7 @@ #define CLIENT_CONTEXT_H__ #include +#include #include #include #include "Destination.h" @@ -74,7 +75,7 @@ namespace client i2p::proxy::HTTPProxy * m_HttpProxy; i2p::proxy::SOCKSProxy * m_SocksProxy; std::map > m_ClientTunnels; // port->tunnel - std::map > m_ServerTunnels; // destination->tunnel + std::map, std::unique_ptr > m_ServerTunnels; // ->tunnel SAMBridge * m_SamBridge; BOBCommandChannel * m_BOBCommandChannel; diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 699fbde4..ab6e2631 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -742,6 +742,7 @@ namespace util s << ""; s << i2p::client::context.GetAddressBook ().ToAddress(ident); + s << ":" << it.second->GetLocalPort (); s << "
\r\n"<< std::endl; } } diff --git a/I2PTunnel.h b/I2PTunnel.h index 146466c5..7a172468 100644 --- a/I2PTunnel.h +++ b/I2PTunnel.h @@ -123,6 +123,7 @@ namespace client const std::string& GetAddress() const { return m_Address; } int GetPort () const { return m_Port; }; + uint16_t GetLocalPort () const { return m_PortDestination->GetLocalPort (); }; const boost::asio::ip::tcp::endpoint& GetEndpoint () const { return m_Endpoint; } const char* GetName() { return m_Name.c_str (); }