diff --git a/ClientContext.cpp b/ClientContext.cpp index 9f5756e6..19d841d3 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -311,7 +311,8 @@ namespace client std::string keys = section.second.get (I2P_SERVER_TUNNEL_KEYS); // optional params int inPort = section.second.get (I2P_SERVER_TUNNEL_INPORT, 0); - std::string accessList = section.second.get (I2P_SERVER_TUNNEL_ACCESS_LIST, ""); + std::string accessList = section.second.get (I2P_SERVER_TUNNEL_ACCESS_LIST, ""); + std::string hostOverride = section.second.get (I2P_SERVER_TUNNEL_HOST_OVERRIDE, ""); i2p::data::SigningKeyType sigType = section.second.get (I2P_SERVER_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256); // I2CP std::map options; @@ -324,7 +325,7 @@ namespace client if (!localDestination) localDestination = CreateNewLocalDestination (k, true, &options); I2PServerTunnel * serverTunnel = (type == I2P_TUNNELS_SECTION_TYPE_HTTP) ? - new I2PServerTunnelHTTP (name, host, port, localDestination, inPort) : + new I2PServerTunnelHTTP (name, host, port, localDestination, hostOverride, inPort) : new I2PServerTunnel (name, host, port, localDestination, inPort); if (accessList.length () > 0) { diff --git a/ClientContext.h b/ClientContext.h index 52f1ab5b..30e495da 100644 --- a/ClientContext.h +++ b/ClientContext.h @@ -28,6 +28,7 @@ namespace client const char I2P_CLIENT_TUNNEL_SIGNATURE_TYPE[] = "signaturetype"; const char I2P_CLIENT_TUNNEL_DESTINATION_PORT[] = "destinationport"; const char I2P_SERVER_TUNNEL_HOST[] = "host"; + const char I2P_SERVER_TUNNEL_HOST_OVERRIDE[] = "hostoverride"; 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/I2PTunnel.cpp b/I2PTunnel.cpp index 07b9bd83..4eb1c573 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -422,14 +422,17 @@ namespace client } I2PServerTunnelHTTP::I2PServerTunnelHTTP (const std::string& name, const std::string& address, - int port, std::shared_ptr localDestination, int inport): - I2PServerTunnel (name, address, port, localDestination, inport) + int port, std::shared_ptr localDestination, + const std::string& host, int inport): + I2PServerTunnel (name, address, port, localDestination, inport), + m_Host (host.length () > 0 ? host : address) { } void I2PServerTunnelHTTP::CreateI2PConnection (std::shared_ptr stream) { - auto conn = std::make_shared (this, stream, std::make_shared (GetService ()), GetEndpoint (), GetAddress ()); + auto conn = std::make_shared (this, stream, + std::make_shared (GetService ()), GetEndpoint (), m_Host); AddHandler (conn); conn->Connect (); } diff --git a/I2PTunnel.h b/I2PTunnel.h index 4530a141..834897f7 100644 --- a/I2PTunnel.h +++ b/I2PTunnel.h @@ -152,11 +152,16 @@ namespace client public: I2PServerTunnelHTTP (const std::string& name, const std::string& address, int port, - std::shared_ptr localDestination, int inport = 0); + std::shared_ptr localDestination, const std::string& host, + int inport = 0); private: - void CreateI2PConnection (std::shared_ptr stream); + void CreateI2PConnection (std::shared_ptr stream); + + private: + + std::string m_Host; }; } }