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+))?(/.*)"); boost::smatch m; std::string path; - if(boost::regex_search(m_url, m, rHTTP, boost::match_extra)) { + if(boost::regex_search(m_url, m, rHTTP, boost::match_extra)) + { server=m[1].str(); - if(m[2].str() != "") { - port=m[3].str(); - } + if (m[2].str() != "") port=m[3].str(); path=m[4].str(); } LogPrint(eLogDebug,"--- HTTP Proxy server is: ",server, " port is: ", port, "\n path is: ",path); @@ -117,8 +120,10 @@ namespace proxy m_path = path; } - bool HTTPProHTTP/1.1 200 OK X-Frame-Options: SAMEORIGIN Date: Wed, 23 Jul 2025 10:11:46 GMT Content-Type: text/plain; charset=utf-8 Connection: close Transfer-Encoding: chunked Cache-Control: max-age=0, private, must-revalidate, no-transform Set-Cookie: i_like_gitea=c7f8d226c864f69c; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=o3MRE5S7pxFEBLreg8Z5GqZ9fz86MTc1MzI2NTUwNjUzMDg1OTYyMg; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax X-Cache-Status: HIT X-Cache-Age: 0 683f 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+))?(/.*)"); boost::smatch m; std::string path; - if(boost::regex_search(m_url, m, rHTTP, boost::match_extra)) { + if(boost::regex_search(m_url, m, rHTTP, boost::match_extra)) + { server=m[1].str(); - if(m[2].str() != "") { - port=m[3].str(); - } + if (m[2].str() != "") port=m[3].str(); path=m[4].str(); } LogPrint(eLogDebug,"--- HTTP Proxy server is: ",server, " port is: ", port, "\n path is: ",path); @@ -117,8 +120,10 @@ namespace proxy m_path = path; } - bool HTTPPro 0