From a09c67772c66db14c645c091fade7c680ed7c564 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 17 Mar 2015 11:44:01 -0400 Subject: [PATCH] specify keys file for proxy's local destination --- ClientContext.cpp | 12 ++- HTTPProxy.cpp | 84 ++++++++++------- HTTPProxy.h | 12 +-- README.md | 3 +- SOCKS.cpp | 223 ++++++++++++++++++++++++++++------------------ SOCKS.h | 9 +- 6 files changed, 209 insertions(+), 134 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index 4073421b..051d12bc 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -37,11 +37,15 @@ namespace client m_SharedLocalDestination->Start (); } + std::shared_ptr localDestination; // proxies - m_HttpProxy = new i2p::proxy::HTTPProxy(i2p::util::config::GetArg("-httpproxyport", 4446)); + std::string proxyKeys = i2p::util::config::GetArg("-proxykeys", ""); + if (proxyKeys.length () > 0) + localDestination = LoadLocalDestination (proxyKeys, false); + m_HttpProxy = new i2p::proxy::HTTPProxy(i2p::util::config::GetArg("-httpproxyport", 4446), localDestination); m_HttpProxy->Start(); LogPrint("HTTP Proxy started"); - m_SocksProxy = new i2p::proxy::SOCKSProxy(i2p::util::config::GetArg("-socksproxyport", 4447)); + m_SocksProxy = new i2p::proxy::SOCKSProxy(i2p::util::config::GetArg("-socksproxyport", 4447), localDestination); m_SocksProxy->Start(); LogPrint("SOCKS Proxy Started"); @@ -49,7 +53,7 @@ namespace client std::string ircDestination = i2p::util::config::GetArg("-ircdest", ""); if (ircDestination.length () > 0) // ircdest is presented { - std::shared_ptr localDestination = nullptr; + localDestination = nullptr; std::string ircKeys = i2p::util::config::GetArg("-irckeys", ""); if (ircKeys.length () > 0) localDestination = LoadLocalDestination (ircKeys, false); @@ -62,7 +66,7 @@ namespace client std::string eepKeys = i2p::util::config::GetArg("-eepkeys", ""); if (eepKeys.length () > 0) // eepkeys file is presented { - auto localDestination = LoadLocalDestination (eepKeys, true); + localDestination = LoadLocalDestination (eepKeys, true); auto serverTunnel = new I2PServerTunnel (i2p::util::config::GetArg("-eephost", "127.0.0.1"), i2p::util::config::GetArg("-eepport", 80), localDestination); serverTunnel->Start (); diff --git a/HTTPProxy.cpp b/HTTPProxy.cpp index 8f2a1654..8c7fb299 100644 --- a/HTTPProxy.cpp +++ b/HTTPProxy.cpp @@ -18,9 +18,11 @@ namespace i2p namespace proxy { static const size_t http_buffer_size = 8192; - class HTTPProxyHandler: public i2p::client::I2PServiceHandler, public std::enable_shared_from_this { + class HTTPProxyHandler: public i2p::client::I2PServiceHandler, public std::enable_shared_from_this + { private: - enum state { + enum state + { GET_METHOD, GET_HOSTNAME, GET_HTTPV, @@ -53,6 +55,7 @@ namespace proxy state m_state;//Parsing state public: + HTTPProxyHandler(HTTPProxyServer * parent, boost::asio::ip::tcp::socket * sock) : I2PServiceHandler(parent), m_sock(sock) { EnterState(GET_METHOD); } @@ -92,7 +95,8 @@ namespace proxy std::bind(&HTTPProxyHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1)); } - void HTTPProxyHandler::EnterState(HTTPProxyHandler::state nstate) { + void HTTPProxyHandler::EnterState(HTTPProxyHandler::state nstate) + { m_state = nstate; } @@ -104,11 +108,10 @@ namespace proxy boost::regex rHTTP("http://(.*?)(:(\\d+))?(/.*)"); HTTP/1.1 200 OK Transfer-Encoding: chunked Cache-Control: max-age=0, private, must-revalidate, no-transform Set-Cookie: i_like_gitea=3566449399e5718f; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=Mpe4KBDSO_Dq4M8uCcBlo6opZ146MTc1MzI2NTUwMDgyNDQxMzcwMg; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax X-Frame-Options: SAMEORIGIN Date: Wed, 23 Jul 2025 10:11:41 GMT Content-Type: text/plain; charset=utf-8 Connection: close X-Cache-Status: HIT X-Cache-Age: 0 6a33 From a09c67772c66db14c645c091fade7c680ed7c564 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 17 Mar 2015 11:44:01 -0400 Subject: [PATCH] specify keys file for proxy's local destination --- ClientContext.cpp | 12 ++- HTTPProxy.cpp | 84 ++++++++++------- HTTPProxy.h | 12 +-- README.md | 3 +- SOCKS.cpp | 223 ++++++++++++++++++++++++++++------------------ SOCKS.h | 9 +- 6 files changed, 209 insertions(+), 134 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index 4073421b..051d12bc 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -37,11 +37,15 @@ namespace client m_SharedLocalDestination->Start (); } + std::shared_ptr localDestination; // proxies - m_HttpProxy = new i2p::proxy::HTTPProxy(i2p::util::config::GetArg("-httpproxyport", 4446)); + std::string proxyKeys = i2p::util::config::GetArg("-proxykeys", ""); + if (proxyKeys.length () > 0) + localDestination = LoadLocalDestination (proxyKeys, false); + m_HttpProxy = new i2p::proxy::HTTPProxy(i2p::util::config::GetArg("-httpproxyport", 4446), localDestination); m_HttpProxy->Start(); LogPrint("HTTP Proxy started"); - m_SocksProxy = new i2p::proxy::SOCKSProxy(i2p::util::config::GetArg("-socksproxyport", 4447)); + m_SocksProxy = new i2p::proxy::SOCKSProxy(i2p::util::config::GetArg("-socksproxyport", 4447), localDestination); m_SocksProxy->Start(); LogPrint("SOCKS Proxy Started"); @@ -49,7 +53,7 @@ namespace client std::string ircDestination = i2p::util::config::GetArg("-ircdest", ""); if (ircDestination.length () > 0) // ircdest is presented { - std::shared_ptr localDestination = nullptr; + localDestination = nullptr; std::string ircKeys = i2p::util::config::GetArg("-irckeys", ""); if (ircKeys.length () > 0) localDestination = LoadLocalDestination (ircKeys, false); @@ -62,7 +66,7 @@ namespace client std::string eepKeys = i2p::util::config::GetArg("-eepkeys", ""); if (eepKeys.length () > 0) // eepkeys file is presented { - auto localDestination = LoadLocalDestination (eepKeys, true); + localDestination = LoadLocalDestination (eepKeys, true); auto serverTunnel = new I2PServerTunnel (i2p::util::config::GetArg("-eephost", "127.0.0.1"), i2p::util::config::GetArg("-eepport", 80), localDestination); serverTunnel->Start (); diff --git a/HTTPProxy.cpp b/HTTPProxy.cpp index 8f2a1654..8c7fb299 100644 --- a/HTTPProxy.cpp +++ b/HTTPProxy.cpp @@ -18,9 +18,11 @@ namespace i2p namespace proxy { static const size_t http_buffer_size = 8192; - class HTTPProxyHandler: public i2p::client::I2PServiceHandler, public std::enable_shared_from_this { + class HTTPProxyHandler: public i2p::client::I2PServiceHandler, public std::enable_shared_from_this + { private: - enum state { + enum state + { GET_METHOD, GET_HOSTNAME, GET_HTTPV, @@ -53,6 +55,7 @@ namespace proxy state m_state;//Parsing state public: + HTTPProxyHandler(HTTPProxyServer * parent, boost::asio::ip::tcp::socket * sock) : I2PServiceHandler(parent), m_sock(sock) { EnterState(GET_METHOD); } @@ -92,7 +95,8 @@ namespace proxy std::bind(&HTTPProxyHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1)); } - void HTTPProxyHandler::EnterState(HTTPProxyHandler::state nstate) { + void HTTPProxyHandler::EnterState(HTTPProxyHandler::state nstate) + { m_state = nstate; } @@ -104,11 +108,10 @@ namespace proxy boost::regex rHTTP("http://(.*?)(:(\\d+))?(/.*)"); 0