Skip to content
/ i2pd Public
forked from PurpleI2P/i2pd

Commit

Permalink
hostoverride added
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Feb 26, 2016
1 parent 9d6d182 commit 8dcf704
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
5 changes: 3 additions & 2 deletions ClientContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ namespace client
std::string keys = section.second.get<std::string> (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<std::string, std::string> options;
Expand All @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions ClientContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
9 changes: 6 additions & 3 deletions I2PTunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,17 @@ namespace client
}

I2PServerTunnelHTTP::I2PServerTunnelHTTP (const std::string& name, const std::string& address,
int port, std::shared_ptr<ClientDestination> localDestination, int inport):
I2PServerTunnel (name, address, port, localDestination, inport)
int port, std::shared_ptr<ClientDestination> 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<i2p::stream::Stream> stream)
{
auto conn = std::make_shared<I2PTunnelConnectionHTTP> (this, stream, std::make_shared<boost::asio::ip::tcp::socket> (GetService ()), GetEndpoint (), GetAddress ());
auto conn = std::make_shared<I2PTunnelConnectionHTTP> (this, stream,
std::make_shared<boost::asio::ip::tcp::socket> (GetService ()), GetEndpoint (), m_Host);
AddHandler (conn);
conn->Connect ();
}
Expand Down
9 changes: 7 additions & 2 deletions I2PTunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,16 @@ namespace client
public:

I2PServerTunnelHTTP (const std::string& name, const std::string& address, int port,
std::shared_ptr<ClientDestination> localDestination, int inport = 0);
std::shared_ptr<ClientDestination> localDestination, const std::string& host,
int inport = 0);

private:

void CreateI2PConnection (std::shared_ptr<i2p::stream::Stream> stream);
void CreateI2PConnection (std::shared_ptr<i2p::stream::Stream> stream);

private:

std::string m_Host;
};
}
}
Expand Down

0 comments on commit 8dcf704

Please sign in to comment.