From f94990c8706cccc0804b95e27ac961963358819f Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 2 Nov 2025 12:09:06 -0500 Subject: [PATCH] i2pheaders param for HTTP server tunnel --- libi2pd_client/ClientContext.cpp | 11 ++++++++--- libi2pd_client/ClientContext.h | 1 + libi2pd_client/I2PTunnel.cpp | 6 +++--- libi2pd_client/I2PTunnel.h | 3 ++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libi2pd_client/ClientContext.cpp b/libi2pd_client/ClientContext.cpp index 7c5d7b15..bac9b11a 100644 --- a/libi2pd_client/ClientContext.cpp +++ b/libi2pd_client/ClientContext.cpp @@ -765,8 +765,6 @@ namespace client std::string accessList = section.second.get (I2P_SERVER_TUNNEL_ACCESS_LIST, ""); if(accessList == "") accessList = section.second.get (I2P_SERVER_TUNNEL_WHITE_LIST, ""); - std::string hostOverride = section.second.get (I2P_SERVER_TUNNEL_HOST_OVERRIDE, ""); - std::string webircpass = section.second.get (I2P_SERVER_TUNNEL_WEBIRC_PASSWORD, ""); bool gzip = section.second.get (I2P_SERVER_TUNNEL_GZIP, false); i2p::data::SigningKeyType sigType = section.second.get (I2P_SERVER_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519); #if !OPENSSL_PQ @@ -851,9 +849,16 @@ namespace client std::shared_ptr serverTunnel; if (type == I2P_TUNNELS_SECTION_TYPE_HTTP) - serverTunnel = std::make_shared (name, host, port, localDestination, hostOverride, inPort, gzip); + { + std::string hostOverride = section.second.get (I2P_SERVER_TUNNEL_HOST_OVERRIDE, ""); + bool i2pheaders = section.second.get (I2P_SERVER_TUNNEL_I2P_HEADERS, true); + serverTunnel = std::make_shared (name, host, port, localDestination, hostOverride, inPort, gzip, i2pheaders); + } else if (type == I2P_TUNNELS_SECTION_TYPE_IRC) + { + std::string webircpass = section.second.get (I2P_SERVER_TUNNEL_WEBIRC_PASSWORD, ""); serverTunnel = std::make_shared (name, host, port, localDestination, webircpass, inPort, gzip); + } else // regular server tunnel by default serverTunnel = std::make_shared (name, host, port, localDestination, inPort, gzip); diff --git a/libi2pd_client/ClientContext.h b/libi2pd_client/ClientContext.h index f0184882..e328ab28 100644 --- a/libi2pd_client/ClientContext.h +++ b/libi2pd_client/ClientContext.h @@ -51,6 +51,7 @@ namespace client const char I2P_CLIENT_TUNNEL_KEEP_ALIVE_INTERVAL[] = "keepaliveinterval"; const char I2P_SERVER_TUNNEL_HOST[] = "host"; const char I2P_SERVER_TUNNEL_HOST_OVERRIDE[] = "hostoverride"; + const char I2P_SERVER_TUNNEL_I2P_HEADERS[] = "i2pheaders"; const char I2P_SERVER_TUNNEL_PORT[] = "port"; const char I2P_SERVER_TUNNEL_KEYS[] = "keys"; const char I2P_SERVER_TUNNEL_SIGNATURE_TYPE[] = "signaturetype"; diff --git a/libi2pd_client/I2PTunnel.cpp b/libi2pd_client/I2PTunnel.cpp index 3fea7172..c02a8ee0 100644 --- a/libi2pd_client/I2PTunnel.cpp +++ b/libi2pd_client/I2PTunnel.cpp @@ -925,15 +925,15 @@ namespace client I2PServerTunnelHTTP::I2PServerTunnelHTTP (const std::string& name, const std::string& address, uint16_t port, std::shared_ptr localDestination, - const std::string& host, uint16_t inport, bool gzip): + const std::string& host, uint16_t inport, bool gzip, bool i2pheaders): I2PServerTunnel (name, address, port, localDestination, inport, gzip), - m_Host (host) + m_Host (host), m_I2PHeaders (i2pheaders) { } std::shared_ptr I2PServerTunnelHTTP::CreateI2PConnection (std::shared_ptr stream) { - if (m_XI2P.empty () || stream->GetRemoteIdentity () != m_From.lock ()) + if (m_I2PHeaders && (m_XI2P.empty () || stream->GetRemoteIdentity () != m_From.lock ())) { auto from = stream->GetRemoteIdentity (); m_From = from; diff --git a/libi2pd_client/I2PTunnel.h b/libi2pd_client/I2PTunnel.h index 00b95726..a6096f20 100644 --- a/libi2pd_client/I2PTunnel.h +++ b/libi2pd_client/I2PTunnel.h @@ -241,7 +241,7 @@ namespace client I2PServerTunnelHTTP (const std::string& name, const std::string& address, uint16_t port, std::shared_ptr localDestination, const std::string& host, - uint16_t inport = 0, bool gzip = true); + uint16_t inport = 0, bool gzip = true, bool i2pheaders = true); private: @@ -251,6 +251,7 @@ namespace client std::string m_Host, m_XI2P; std::weak_ptr m_From; + bool m_I2PHeaders; }; class I2PServerTunnelIRC: public I2PServerTunnel