mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
read optional destination port form config
This commit is contained in:
parent
1d737409ec
commit
fee68cf333
@ -280,12 +280,12 @@ namespace client
|
||||
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT);
|
||||
std::string keys = section.second.get<std::string> (I2P_CLIENT_TUNNEL_KEYS);
|
||||
// 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;
|
||||
if (keys.length () > 0)
|
||||
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)
|
||||
clientTunnel->Start ();
|
||||
else
|
||||
@ -299,9 +299,10 @@ namespace client
|
||||
int port = section.second.get<int> (I2P_SERVER_TUNNEL_PORT);
|
||||
std::string keys = section.second.get<std::string> (I2P_SERVER_TUNNEL_KEYS);
|
||||
// optional params
|
||||
|
||||
int inPort = section.second.get (I2P_SERVER_TUNNEL_INPORT, 0);
|
||||
|
||||
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)
|
||||
serverTunnel->Start ();
|
||||
else
|
||||
|
@ -27,6 +27,7 @@ namespace client
|
||||
const char I2P_SERVER_TUNNEL_HOST[] = "host";
|
||||
const char I2P_SERVER_TUNNEL_PORT[] = "port";
|
||||
const char I2P_SERVER_TUNNEL_KEYS[] = "keys";
|
||||
const char I2P_SERVER_TUNNEL_INPORT[] = "inport";
|
||||
const char TUNNELS_CONFIG_FILENAME[] = "tunnels.cfg";
|
||||
|
||||
class ClientContext
|
||||
|
@ -246,10 +246,11 @@ namespace client
|
||||
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)
|
||||
{
|
||||
m_PortDestination = localDestination->CreateStreamingDestination (port);
|
||||
m_PortDestination = localDestination->CreateStreamingDestination (inport > 0 ? inport : port);
|
||||
}
|
||||
|
||||
void I2PServerTunnel::Start ()
|
||||
|
@ -84,7 +84,8 @@ namespace client
|
||||
{
|
||||
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 Stop ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user