Commit efdf315b authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Prepend rather than append the <local> proxy bypass rule on Chrome OS.

This fixes BasicAuthWSConnect.BasicAuthWSConnect.

The ordering of proxy bypass rules only mattered until recently, with the addition of the <-loopback> bypass rule (Issue 413511). That rule gives a way to "subtract" the bypass of localhost, and can be used by tests need to proxy localhost (see Issue 901896).

Because later rules have priority over earlier rules, we need to move <local> to the front, or it won't be possible for user-provided (explicit) rules to override it.

Bug: 902418
Change-Id: I40fb6e23e7b79ba628595cd6724de627bedb5f73
Reviewed-on: https://chromium-review.googlesource.com/c/1321853
Commit-Queue: Eric Roman <eroman@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607267}
parent c25c2041
...@@ -217,7 +217,7 @@ const struct TestParams { ...@@ -217,7 +217,7 @@ const struct TestParams {
net::ProxyRulesExpectation::Single( // proxy_rules net::ProxyRulesExpectation::Single( // proxy_rules
"www.google.com:80", // single proxy "www.google.com:80", // single proxy
// bypass_rules // bypass_rules
"*.google.com,*foo.com:99,1.2.3.4:22,127.0.0.1/8,<local>"), "<local>,*.google.com,*foo.com:99,1.2.3.4:22,127.0.0.1/8"),
}, },
}; // tests }; // tests
......
...@@ -135,16 +135,10 @@ class ProxyBrowserTest : public InProcessBrowserTest { ...@@ -135,16 +135,10 @@ class ProxyBrowserTest : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(ProxyBrowserTest); DISALLOW_COPY_AND_ASSIGN(ProxyBrowserTest);
}; };
// We bypass manually installed proxy for localhost on chromeos.
#if defined(OS_CHROMEOS)
#define MAYBE_BasicAuthWSConnect DISABLED_BasicAuthWSConnect
#else
#define MAYBE_BasicAuthWSConnect BasicAuthWSConnect
#endif
// Test that the browser can establish a WebSocket connection via a proxy // Test that the browser can establish a WebSocket connection via a proxy
// that requires basic authentication. This test also checks the headers // that requires basic authentication. This test also checks the headers
// arrive at WebSocket server. // arrive at WebSocket server.
IN_PROC_BROWSER_TEST_F(ProxyBrowserTest, MAYBE_BasicAuthWSConnect) { IN_PROC_BROWSER_TEST_F(ProxyBrowserTest, BasicAuthWSConnect) {
// Launch WebSocket server. // Launch WebSocket server.
net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS, net::SpawnedTestServer ws_server(net::SpawnedTestServer::TYPE_WS,
net::GetWebSocketTestDataDirectory()); net::GetWebSocketTestDataDirectory());
......
...@@ -262,7 +262,7 @@ void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() { ...@@ -262,7 +262,7 @@ void ProxyConfigServiceImpl::DetermineEffectiveConfigFromDefaultNetwork() {
if (effective_config.value().proxy_rules().type != if (effective_config.value().proxy_rules().type !=
net::ProxyConfig::ProxyRules::Type::EMPTY) { net::ProxyConfig::ProxyRules::Type::EMPTY) {
net::ProxyConfig proxy_config = effective_config.value(); net::ProxyConfig proxy_config = effective_config.value();
proxy_config.proxy_rules().bypass_rules.AddRuleToBypassLocal(); proxy_config.proxy_rules().bypass_rules.PrependRuleToBypassLocal();
effective_config = net::ProxyConfigWithAnnotation( effective_config = net::ProxyConfigWithAnnotation(
proxy_config, effective_config.traffic_annotation()); proxy_config, effective_config.traffic_annotation());
} }
......
...@@ -47,12 +47,12 @@ ...@@ -47,12 +47,12 @@
} }
}, },
"ExcludeDomains": [ "ExcludeDomains": [
"google.com", "<local>",
"<local>" "google.com"
] ]
}, },
"ProxyConfig": { "ProxyConfig": {
"bypass_list":"google.com;\u003Clocal\u003E;", "bypass_list":"\u003Clocal\u003E;google.com;",
"mode":"fixed_servers", "mode":"fixed_servers",
"server":"ftp=ftp.example.com:5678;http=http.example.com:1234;socks=socks5://socks.example.com:7890;https=https.example.com:3456" "server":"ftp=ftp.example.com:5678;http=http.example.com:1234;socks=socks5://socks.example.com:7890;https=https.example.com:3456"
} }
......
{ {
"Mode": "managed", "Mode": "managed",
"ProxyConfig": "{\"bypass_list\":\"google.com;\\u003Clocal>;\",\"mode\":\"fixed_servers\",\"server\":\"ftp=ftp.example.com:5678;http=http.example.com:1234;socks=socks5://socks.example.com:7890;https=https.example.com:3456\"}", "ProxyConfig": "{\"bypass_list\":\"\\u003Clocal>;google.com;\",\"mode\":\"fixed_servers\",\"server\":\"ftp=ftp.example.com:5678;http=http.example.com:1234;socks=socks5://socks.example.com:7890;https=https.example.com:3456\"}",
"SecurityClass": "none", "SecurityClass": "none",
"Type": "wifi", "Type": "wifi",
} }
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
} }
}, },
"ExcludeDomains": [ "ExcludeDomains": [
"google.com", "<local>",
"<local>" "google.com"
] ]
} }
} }
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
} }
}, },
"ExcludeDomains": [ "ExcludeDomains": [
"google.com", "<local>",
"<local>" "google.com"
] ]
}, },
"Type": "WiFi", "Type": "WiFi",
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
} }
}, },
"ExcludeDomains": [ "ExcludeDomains": [
"google.com", "<local>",
"<local>" "google.com"
] ]
}, },
"Type": "WiFi", "Type": "WiFi",
......
...@@ -382,8 +382,8 @@ bool ProxyBypassRules::AddRuleForHostname(const std::string& optional_scheme, ...@@ -382,8 +382,8 @@ bool ProxyBypassRules::AddRuleForHostname(const std::string& optional_scheme,
return true; return true;
} }
void ProxyBypassRules::AddRuleToBypassLocal() { void ProxyBypassRules::PrependRuleToBypassLocal() {
rules_.push_back(std::make_unique<WinLocalRule>()); rules_.insert(rules_.begin(), std::make_unique<WinLocalRule>());
} }
bool ProxyBypassRules::AddRuleFromString(const std::string& raw_untrimmed, bool ProxyBypassRules::AddRuleFromString(const std::string& raw_untrimmed,
......
...@@ -122,14 +122,14 @@ class NET_EXPORT ProxyBypassRules { ...@@ -122,14 +122,14 @@ class NET_EXPORT ProxyBypassRules {
const std::string& hostname_pattern, const std::string& hostname_pattern,
int optional_port); int optional_port);
// Adds a rule that bypasses all "local" hostnames. // Adds a rule to the front of the list that bypasses all "local" hostnames.
// This matches IE's interpretation of the // This matches IE's interpretation of the
// "Bypass proxy server for local addresses" settings checkbox. Fully // "Bypass proxy server for local addresses" settings checkbox. Fully
// qualified domain names or IP addresses are considered non-local, // qualified domain names or IP addresses are considered non-local,
// regardless of what they map to (except for the loopback addresses). // regardless of what they map to (except for the loopback addresses).
// //
// TODO(https://crbug.com/902579): Fix. // TODO(https://crbug.com/902579): Fix.
void AddRuleToBypassLocal(); void PrependRuleToBypassLocal();
// Adds a rule given by the string |raw|. The format of |raw| can be any of // Adds a rule given by the string |raw|. The format of |raw| can be any of
// the following: // the following:
......
...@@ -153,7 +153,7 @@ void GetCurrentProxyConfig(const NetworkTrafficAnnotationTag traffic_annotation, ...@@ -153,7 +153,7 @@ void GetCurrentProxyConfig(const NetworkTrafficAnnotationTag traffic_annotation,
if (GetBoolFromDictionary(config_dict.get(), if (GetBoolFromDictionary(config_dict.get(),
kSCPropNetProxiesExcludeSimpleHostnames, kSCPropNetProxiesExcludeSimpleHostnames,
false)) { false)) {
proxy_config.proxy_rules().bypass_rules.AddRuleToBypassLocal(); proxy_config.proxy_rules().bypass_rules.PrependRuleToBypassLocal();
} }
*config = ProxyConfigWithAnnotation(proxy_config, traffic_annotation); *config = ProxyConfigWithAnnotation(proxy_config, traffic_annotation);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment