Browse Source

read optional destination port form config

pull/164/head
orignal 10 years ago
parent
commit
fee68cf333
  1. 9
      ClientContext.cpp
  2. 1
      ClientContext.h
  3. 5
      I2PTunnel.cpp
  4. 3
      I2PTunnel.h

9
ClientContext.cpp

@ -280,12 +280,12 @@ namespace client
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT); int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT);
std::string keys = section.second.get<std::string> (I2P_CLIENT_TUNNEL_KEYS); std::string keys = section.second.get<std::string> (I2P_CLIENT_TUNNEL_KEYS);
// optional params // optional params
//int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0); int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0);
std::shared_ptr<ClientDestination> localDestination = nullptr; std::shared_ptr<ClientDestination> localDestination = nullptr;
if (keys.length () > 0) if (keys.length () > 0)
localDestination = LoadLocalDestination (keys, false); localDestination = LoadLocalDestination (keys, false);
auto clientTunnel = new I2PClientTunnel (dest, port, localDestination); auto clientTunnel = new I2PClientTunnel (dest, port, localDestination, destinationPort);
if (m_ClientTunnels.insert (std::make_pair (port, std::unique_ptr<I2PClientTunnel>(clientTunnel))).second) if (m_ClientTunnels.insert (std::make_pair (port, std::unique_ptr<I2PClientTunnel>(clientTunnel))).second)
clientTunnel->Start (); clientTunnel->Start ();
else else
@ -299,9 +299,10 @@ namespace client
int port = section.second.get<int> (I2P_SERVER_TUNNEL_PORT); int port = section.second.get<int> (I2P_SERVER_TUNNEL_PORT);
std::string keys = section.second.get<std::string> (I2P_SERVER_TUNNEL_KEYS); std::string keys = section.second.get<std::string> (I2P_SERVER_TUNNEL_KEYS);
// optional params // optional params
int inPort = section.second.get (I2P_SERVER_TUNNEL_INPORT, 0);
auto localDestination = LoadLocalDestination (keys, true); auto localDestination = LoadLocalDestination (keys, true);
auto serverTunnel = new I2PServerTunnel (host, port, localDestination); auto serverTunnel = new I2PServerTunnel (host, port, localDestination, inPort);
if (m_ServerTunnels.insert (std::make_pair (localDestination->GetIdentHash (), std::unique_ptr<I2PServerTunnel>(serverTunnel))).second) if (m_ServerTunnels.insert (std::make_pair (localDestination->GetIdentHash (), std::unique_ptr<I2PServerTunnel>(serverTunnel))).second)
serverTunnel->Start (); serverTunnel->Start ();
else else

1
ClientContext.h

@ -27,6 +27,7 @@ namespace client
const char I2P_SERVER_TUNNEL_HOST[] = "host"; const char I2P_SERVER_TUNNEL_HOST[] = "host";
const char I2P_SERVER_TUNNEL_PORT[] = "port"; const char I2P_SERVER_TUNNEL_PORT[] = "port";
const char I2P_SERVER_TUNNEL_KEYS[] = "keys"; const char I2P_SERVER_TUNNEL_KEYS[] = "keys";
const char I2P_SERVER_TUNNEL_INPORT[] = "inport";
const char TUNNELS_CONFIG_FILENAME[] = "tunnels.cfg"; const char TUNNELS_CONFIG_FILENAME[] = "tunnels.cfg";
class ClientContext class ClientContext

5
I2PTunnel.cpp

@ -246,10 +246,11 @@ namespace client
return nullptr; return nullptr;
} }
I2PServerTunnel::I2PServerTunnel (const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination): I2PServerTunnel::I2PServerTunnel (const std::string& address, int port,
std::shared_ptr<ClientDestination> localDestination, int inport):
I2PService (localDestination), m_Endpoint (boost::asio::ip::address::from_string (address), port) I2PService (localDestination), m_Endpoint (boost::asio::ip::address::from_string (address), port)
{ {
m_PortDestination = localDestination->CreateStreamingDestination (port); m_PortDestination = localDestination->CreateStreamingDestination (inport > 0 ? inport : port);
} }
void I2PServerTunnel::Start () void I2PServerTunnel::Start ()

3
I2PTunnel.h

@ -84,7 +84,8 @@ namespace client
{ {
public: public:
I2PServerTunnel (const std::string& address, int port, std::shared_ptr<ClientDestination> localDestination); I2PServerTunnel (const std::string& address, int port,
std::shared_ptr<ClientDestination> localDestination, int inport = 0);
void Start (); void Start ();
void Stop (); void Stop ();

Loading…
Cancel
Save