Change the default SOCKS version used by gnome settings (and environment variables) to be 5 instead of 4.
BUG=56833
TEST=Open Chrome in gnome. Go to change the proxy settings (which will pop open the gnome network settings). Enter as socks proxy server, "localhost:8080". Now load chrome://net-internals/#proxy and verify that it says the proxy server is "socks5://localhost:8080" (and NOT socks4://localhost:8080).
Review URL: http://codereview.chromium.org/3413037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60734 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc
index 1cf9e3d..b61167f 100644
--- a/net/proxy/proxy_config_service_linux.cc
+++ b/net/proxy/proxy_config_service_linux.cc
@@ -43,11 +43,11 @@
// TODO(arindam): Remove URI string manipulation by using MapUrlSchemeToProxy.
std::string FixupProxyHostScheme(ProxyServer::Scheme scheme,
std::string host) {
- if (scheme == ProxyServer::SCHEME_SOCKS4 &&
- StartsWithASCII(host, "socks5://", false)) {
- // We default to socks 4, but if the user specifically set it to
- // socks5://, then use that.
- scheme = ProxyServer::SCHEME_SOCKS5;
+ if (scheme == ProxyServer::SCHEME_SOCKS5 &&
+ StartsWithASCII(host, "socks4://", false)) {
+ // We default to socks 5, but if the user specifically set it to
+ // socks4://, then use that.
+ scheme = ProxyServer::SCHEME_SOCKS4;
}
// Strip the scheme if any.
std::string::size_type colon = host.find("://");
@@ -152,11 +152,13 @@
}
if (config->proxy_rules().empty()) {
// If the above were not defined, try for socks.
- ProxyServer::Scheme scheme = ProxyServer::SCHEME_SOCKS4;
+ // For environment variables, we default to version 5, per the gnome
+ // documentation: http://library.gnome.org/devel/gnet/stable/gnet-socks.html
+ ProxyServer::Scheme scheme = ProxyServer::SCHEME_SOCKS5;
std::string env_version;
if (env_var_getter_->GetVar("SOCKS_VERSION", &env_version)
- && env_version == "5")
- scheme = ProxyServer::SCHEME_SOCKS5;
+ && env_version == "4")
+ scheme = ProxyServer::SCHEME_SOCKS4;
if (GetProxyFromEnvVarForScheme("SOCKS_SERVER", scheme, &proxy_server)) {
config->proxy_rules().type = ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
config->proxy_rules().single_proxy = proxy_server;
@@ -915,7 +917,7 @@
host += ":" + base::IntToString(port);
}
host = FixupProxyHostScheme(
- is_socks ? ProxyServer::SCHEME_SOCKS4 : ProxyServer::SCHEME_HTTP,
+ is_socks ? ProxyServer::SCHEME_SOCKS5 : ProxyServer::SCHEME_HTTP,
host);
ProxyServer proxy_server = ProxyServer::FromURI(host,
ProxyServer::SCHEME_HTTP);
@@ -982,7 +984,9 @@
// Try socks.
if (GetProxyFromGConf("/system/proxy/socks_", true, &proxy_server)) {
// gconf settings do not appear to distinguish between socks
- // version. We default to version 4.
+ // version. We default to version 5. For more information on this policy
+ // decisions, see:
+ // http://code.google.com/p/chromium/issues/detail?id=55912#c2
config->proxy_rules().type = ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
config->proxy_rules().single_proxy = proxy_server;
}