From fee68cf333997daa3f7c6db0d4ab3cf3b30826b0 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 15 Mar 2015 11:28:30 -0400 Subject: [PATCH] read optional destination port form config --- ClientContext.cpp | 9 +++++---- ClientContext.h | 1 + I2PTunnel.cpp | 5 +++-- I2PTunnel.h | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index cbc916fc..fb85f88c 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -280,12 +280,12 @@ namespace client int port = section.second.get (I2P_CLIENT_TUNNEL_PORT); std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS); // optional params - //int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0); + int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0); std::shared_ptr localDestination = nullptr; if (keys.length () > 0) localDestination = LoadLocalDestination (keys, false); - auto clientTunnel = new I2PClientTunnel (dest, port, localDestination); + auto clientTunnel = new I2PClientTunnel (dest, port, localDestination, destinationPort); if (m_ClientTunnels.insert (std::make_pair (port, std::unique_ptr(clientTunnel))).second) clientTunnel->Start (); else @@ -299,9 +299,10 @@ namespace client int port = section.second.get (I2P_SERVER_TUNNEL_PORT); std::string keys = section.second.get (I2P_SERVER_TUNNEL_KEYS); // optional params - + int inPort = section.second.get (I2P_SERVER_TUNNEL_INPORT, 0); + auto localDestination = LoadLocalDestination (keys, true); - auto serverTunnel = new I2PServerTunnel (host, port, localDestination); + auto serverTunnel = new I2PServerTunnel (host, port, localDestination, inPort); if (m_ServerTunnels.insert (std::make_pair (localDestination->GetIdentHash (), std::unique_ptr(serverTunnel))).second) serverTunnel->Start (); else diff --git a/ClientContext.h b/ClientContext.h index d0f57edc..87ce4519 100644 --- a/ClientContext.h +++ b/ClientContext.h @@ -27,6 +27,7 @@ namespace client const char I2P_SERVER_TUNNEL_HOST[] = "host"; const char I2P_SERVER_TUNNEL_PORT[] = "port"; const char I2P_SERVER_TUNNEL_KEYS[] = "keys"; + const char I2P_SERVER_TUNNEL_INPORT[] = "inport"; const char TUNNELS_CONFIG_FILENAME[] = "tunnels.cfg"; class ClientContext diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index 43398318..b4925438 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -246,10 +246,11 @@ namespace client return nullptr; } - I2PServerTunnel::I2PServerTunnel (const std::string& address, int port, std::shared_ptr localDestination): + I2PServerTunnel::I2PServerTunnel (const std::string& address, int port, + std::shared_ptr localDestination, int inport): I2PService (localDestination), m_Endpoint (boost::asio::ip::address::from_string (address), port) { - m_PortDestination = localDestination->CreateStreamingDestination (port); + m_PortDestination = localDestination->CreateStreamingDestination (inport > 0 ? inport : port); } void I2PServerTunnel::Start () diff --git a/I2PTunnel.h b/I2PTunnel.h index 7c36f543..88e0083a 100644 --- a/I2PTunnel.h +++ b/I2PTunnel.h @@ -84,7 +84,8 @@ namespace client { public: - I2PServerTunnel (const std::string& address, int port, std::shared_ptr localDestination); + I2PServerTunnel (const std::string& address, int port, + std::shared_ptr localDestination, int inport = 0); void Start (); void Stop ();