mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-13 19:37:51 +00:00
tunnel options for SOCKS proxy
This commit is contained in:
parent
4b983300fe
commit
0305e4cf8a
@ -55,15 +55,7 @@ namespace client
|
||||
if(LoadPrivateKeys (keys, httpProxyKeys))
|
||||
{
|
||||
std::map<std::string, std::string> params;
|
||||
std::string value;
|
||||
if (i2p::config::GetOption("httpproxy.inbound.length", value))
|
||||
params["inbound.length"] = value;
|
||||
if (i2p::config::GetOption("httpproxy.inbound.quantity", value))
|
||||
params["inbound.quantity"] = value;
|
||||
if (i2p::config::GetOption("httpproxy.outbound.length", value))
|
||||
params["outbound.length"] = value;
|
||||
if (i2p::config::GetOption("httpproxy.outbound.quantity", value))
|
||||
params["outbound.quantity"] = value;
|
||||
ReadI2CPOptionsFromConfig ("httpproxy.", params);
|
||||
localDestination = CreateNewLocalDestination (keys, false, ¶ms);
|
||||
}
|
||||
else
|
||||
@ -77,8 +69,10 @@ namespace client
|
||||
}
|
||||
}
|
||||
|
||||
localDestination = nullptr;
|
||||
bool socksproxy; i2p::config::GetOption("socksproxy.enabled", socksproxy);
|
||||
if (socksproxy) {
|
||||
if (socksproxy)
|
||||
{
|
||||
std::string socksProxyKeys; i2p::config::GetOption("socksproxy.keys", socksProxyKeys);
|
||||
std::string socksProxyAddr; i2p::config::GetOption("socksproxy.address", socksProxyAddr);
|
||||
uint16_t socksProxyPort; i2p::config::GetOption("socksproxy.port", socksProxyPort);
|
||||
@ -88,8 +82,14 @@ namespace client
|
||||
if (socksProxyKeys.length () > 0)
|
||||
{
|
||||
i2p::data::PrivateKeys keys;
|
||||
LoadPrivateKeys (keys, socksProxyKeys);
|
||||
localDestination = CreateNewLocalDestination (keys, false);
|
||||
if (LoadPrivateKeys (keys, socksProxyKeys))
|
||||
{
|
||||
std::map<std::string, std::string> params;
|
||||
ReadI2CPOptionsFromConfig ("socksproxy.", params);
|
||||
localDestination = CreateNewLocalDestination (keys, false, ¶ms);
|
||||
}
|
||||
else
|
||||
LogPrint(eLogError, "Clients: failed to load SOCKS Proxy key");
|
||||
}
|
||||
try {
|
||||
m_SocksProxy = new i2p::proxy::SOCKSProxy(socksProxyAddr, socksProxyPort, socksOutProxyAddr, socksOutProxyPort, localDestination);
|
||||
@ -374,6 +374,19 @@ namespace client
|
||||
options[I2CP_PARAM_TAGS_TO_SEND] = GetI2CPOption (section, I2CP_PARAM_TAGS_TO_SEND, DEFAULT_TAGS_TO_SEND);
|
||||
}
|
||||
|
||||
void ClientContext::ReadI2CPOptionsFromConfig (const std::string& prefix, std::map<std::string, std::string>& options) const
|
||||
{
|
||||
std::string value;
|
||||
if (i2p::config::GetOption(prefix + I2CP_PARAM_INBOUND_TUNNEL_LENGTH, value))
|
||||
options[I2CP_PARAM_INBOUND_TUNNEL_LENGTH] = value;
|
||||
if (i2p::config::GetOption(prefix + I2CP_PARAM_INBOUND_TUNNELS_QUANTITY, value))
|
||||
options[I2CP_PARAM_INBOUND_TUNNELS_QUANTITY] = value;
|
||||
if (i2p::config::GetOption(prefix + I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH, value))
|
||||
options[I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH] = value;
|
||||
if (i2p::config::GetOption(prefix + I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY, value))
|
||||
options[I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY] = value;
|
||||
}
|
||||
|
||||
void ClientContext::ReadTunnels ()
|
||||
{
|
||||
boost::property_tree::ptree pt;
|
||||
|
@ -75,7 +75,8 @@ namespace client
|
||||
template<typename Section, typename Type>
|
||||
std::string GetI2CPOption (const Section& section, const std::string& name, const Type& value) const;
|
||||
template<typename Section>
|
||||
void ReadI2CPOptions (const Section& section, std::map<std::string, std::string>& options) const;
|
||||
void ReadI2CPOptions (const Section& section, std::map<std::string, std::string>& options) const;
|
||||
void ReadI2CPOptionsFromConfig (const std::string& prefix, std::map<std::string, std::string>& options) const;
|
||||
|
||||
void CleanupUDP(const boost::system::error_code & ecode);
|
||||
void ScheduleCleanupUDP();
|
||||
|
@ -93,7 +93,11 @@ namespace config {
|
||||
("socksproxy.address", value<std::string>()->default_value("127.0.0.1"), "SOCKS Proxy listen address")
|
||||
("socksproxy.port", value<uint16_t>()->default_value(4447), "SOCKS Proxy listen port")
|
||||
("socksproxy.keys", value<std::string>()->default_value(""), "File to persist SOCKS Proxy keys")
|
||||
("socksproxy.outproxy", value<std::string>()->default_value("127.0.0.1"), "Upstream outproxy address for SOCKS Proxy")
|
||||
("socksproxy.inbound.length", value<std::string>()->default_value("3"), "SOCKS proxy inbound tunnel length")
|
||||
("socksproxy.outbound.length", value<std::string>()->default_value("3"), "SOCKS proxy outbound tunnel length")
|
||||
("socksproxy.inbound.quantity", value<std::string>()->default_value("5"), "SOCKS proxy inbound tunnels quantity")
|
||||
("socksproxy.outbound.quantity", value<std::string>()->default_value("5"), "SOCKS proxy outbound tunnels quantity")
|
||||
("socksproxy.outproxy", value<std::string>()->default_value("127.0.0.1"), "Upstream outproxy address for SOCKS Proxy")
|
||||
("socksproxy.outproxyport", value<uint16_t>()->default_value(9050), "Upstream outproxy port for SOCKS Proxy")
|
||||
;
|
||||
|
||||
|
8
Config.h
8
Config.h
@ -78,6 +78,12 @@ namespace config {
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool GetOption(const std::string& name, T& value)
|
||||
{
|
||||
return GetOption (name.c_str (), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set value of given parameter
|
||||
* @param name Name of settable parameter
|
||||
@ -93,7 +99,7 @@ namespace config {
|
||||
m_Options.at(name).value() = value;
|
||||
notify(m_Options);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check is value explicitly given or default
|
||||
|
@ -50,12 +50,16 @@ All options below still possible in cmdline, but better write it in config file:
|
||||
* --httpproxy.outbound.length= - Outbound tunnels length if keys is set. 3 by default
|
||||
* --httpproxy.outbound.quantity= - Outbound tunnels quantity if keys is set. 5 by default
|
||||
|
||||
* --socksproxy.address= - The address to listen on (SOCKS Proxy)
|
||||
* --socksproxy.port= - The port to listen on (SOCKS Proxy). 4447 by default
|
||||
* --socksproxy.enabled= - If SOCKS proxy is enabled. true by default
|
||||
* --socksproxy.address= - The address to listen on (SOCKS Proxy)
|
||||
* --socksproxy.port= - The port to listen on (SOCKS Proxy). 4447 by default
|
||||
* --socksproxy.keys= - optional keys file for SOCKS proxy local destination
|
||||
* --socksproxy.enabled= - If SOCKS proxy is enabled. true by default
|
||||
* --socksproxy.outproxy= - Address of outproxy. requests outside i2p will go there
|
||||
* --socksproxy.outproxyport= - Outproxy remote port
|
||||
* --socksproxy.inbound.length= - Inbound tunnels length if keys is set. 3 by default
|
||||
* --socksproxy.inbound.quantity= - Inbound tunnels quantity if keys is set. 5 by default
|
||||
* --socksproxy.outbound.length= - Outbound tunnels length if keys is set. 3 by default
|
||||
* --socksproxy.outbound.quantity= - Outbound tunnels quantity if keys is set. 5 by default
|
||||
* --socksproxy.outproxy= - Address of outproxy. requests outside i2p will go there
|
||||
* --socksproxy.outproxyport= - Outproxy remote port
|
||||
|
||||
* --sam.address= - The address to listen on (SAM bridge)
|
||||
* --sam.port= - Port of SAM bridge. Usually 7656. SAM is off if not specified
|
||||
|
Loading…
Reference in New Issue
Block a user