Browse Source

tunnel options for SOCKS proxy

pull/700/head
orignal 8 years ago
parent
commit
0305e4cf8a
  1. 37
      ClientContext.cpp
  2. 3
      ClientContext.h
  3. 6
      Config.cpp
  4. 8
      Config.h
  5. 14
      docs/configuration.md

37
ClientContext.cpp

@ -55,15 +55,7 @@ namespace client
if(LoadPrivateKeys (keys, httpProxyKeys)) if(LoadPrivateKeys (keys, httpProxyKeys))
{ {
std::map<std::string, std::string> params; std::map<std::string, std::string> params;
std::string value; ReadI2CPOptionsFromConfig ("httpproxy.", params);
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;
localDestination = CreateNewLocalDestination (keys, false, &params); localDestination = CreateNewLocalDestination (keys, false, &params);
} }
else else
@ -77,8 +69,10 @@ namespace client
} }
} }
localDestination = nullptr;
bool socksproxy; i2p::config::GetOption("socksproxy.enabled", socksproxy); bool socksproxy; i2p::config::GetOption("socksproxy.enabled", socksproxy);
if (socksproxy) { if (socksproxy)
{
std::string socksProxyKeys; i2p::config::GetOption("socksproxy.keys", socksProxyKeys); std::string socksProxyKeys; i2p::config::GetOption("socksproxy.keys", socksProxyKeys);
std::string socksProxyAddr; i2p::config::GetOption("socksproxy.address", socksProxyAddr); std::string socksProxyAddr; i2p::config::GetOption("socksproxy.address", socksProxyAddr);
uint16_t socksProxyPort; i2p::config::GetOption("socksproxy.port", socksProxyPort); uint16_t socksProxyPort; i2p::config::GetOption("socksproxy.port", socksProxyPort);
@ -88,8 +82,14 @@ namespace client
if (socksProxyKeys.length () > 0) if (socksProxyKeys.length () > 0)
{ {
i2p::data::PrivateKeys keys; i2p::data::PrivateKeys keys;
LoadPrivateKeys (keys, socksProxyKeys); if (LoadPrivateKeys (keys, socksProxyKeys))
localDestination = CreateNewLocalDestination (keys, false); {
std::map<std::string, std::string> params;
ReadI2CPOptionsFromConfig ("socksproxy.", params);
localDestination = CreateNewLocalDestination (keys, false, &params);
}
else
LogPrint(eLogError, "Clients: failed to load SOCKS Proxy key");
} }
try { try {
m_SocksProxy = new i2p::proxy::SOCKSProxy(socksProxyAddr, socksProxyPort, socksOutProxyAddr, socksOutProxyPort, localDestination); 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); 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 () void ClientContext::ReadTunnels ()
{ {
boost::property_tree::ptree pt; boost::property_tree::ptree pt;

3
ClientContext.h

@ -75,7 +75,8 @@ namespace client
template<typename Section, typename Type> template<typename Section, typename Type>
std::string GetI2CPOption (const Section& section, const std::string& name, const Type& value) const; std::string GetI2CPOption (const Section& section, const std::string& name, const Type& value) const;
template<typename Section> 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 CleanupUDP(const boost::system::error_code & ecode);
void ScheduleCleanupUDP(); void ScheduleCleanupUDP();

6
Config.cpp

@ -93,7 +93,11 @@ namespace config {
("socksproxy.address", value<std::string>()->default_value("127.0.0.1"), "SOCKS Proxy listen address") ("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.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.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") ("socksproxy.outproxyport", value<uint16_t>()->default_value(9050), "Upstream outproxy port for SOCKS Proxy")
; ;

8
Config.h

@ -78,6 +78,12 @@ namespace config {
return true; 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 * @brief Set value of given parameter
* @param name Name of settable parameter * @param name Name of settable parameter
@ -93,7 +99,7 @@ namespace config {
m_Options.at(name).value() = value; m_Options.at(name).value() = value;
notify(m_Options); notify(m_Options);
return true; return true;
} }
/** /**
* @brief Check is value explicitly given or default * @brief Check is value explicitly given or default

14
docs/configuration.md

@ -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.length= - Outbound tunnels length if keys is set. 3 by default
* --httpproxy.outbound.quantity= - Outbound tunnels quantity if keys is set. 5 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.enabled= - If SOCKS proxy is enabled. true by default
* --socksproxy.port= - The port to listen on (SOCKS Proxy). 4447 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.keys= - optional keys file for SOCKS proxy local destination
* --socksproxy.enabled= - If SOCKS proxy is enabled. true by default * --socksproxy.inbound.length= - Inbound tunnels length if keys is set. 3 by default
* --socksproxy.outproxy= - Address of outproxy. requests outside i2p will go there * --socksproxy.inbound.quantity= - Inbound tunnels quantity if keys is set. 5 by default
* --socksproxy.outproxyport= - Outproxy remote port * --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.address= - The address to listen on (SAM bridge)
* --sam.port= - Port of SAM bridge. Usually 7656. SAM is off if not specified * --sam.port= - Port of SAM bridge. Usually 7656. SAM is off if not specified

Loading…
Cancel
Save