Commit 7aeea3a2 authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Bypass the proxy implicitly for "loopback" (on Windows only).

Bug: 904889
Change-Id: I52e5b4cc2bff0cff0b1c7d6ec55d26b01924c288
Reviewed-on: https://chromium-review.googlesource.com/c/1333906
Commit-Queue: Eric Roman <eroman@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607855}
parent 912b4b95
......@@ -9,6 +9,7 @@
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "net/base/host_port_pair.h"
#include "net/base/ip_address.h"
#include "net/base/parse_number.h"
......@@ -446,13 +447,20 @@ bool ProxyBypassRules::MatchesImplicitRules(const GURL& url) {
// *.localhost
// localhost6
// localhost6.localdomain6
// loopback [Windows only]
// loopback. [Windows only]
// [::1]
// 127.0.0.1/8
// 169.254/16
// [FE80::]/10
//
// TODO(eroman): Does "loopback" need special treatment on Windows?
return net::IsLocalhost(url) || IsLinkLocalIP(url);
return net::IsLocalhost(url) ||
IsLinkLocalIP(url)
#if defined(OS_WIN)
// See http://crbug.com/904889
|| (url.host_piece() == "loopback") ||
(url.host_piece() == "loopback.")
#endif
;
}
} // namespace net
......@@ -7,9 +7,16 @@
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "net/proxy_resolution/proxy_config_service_common_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN)
// On Windows, "loopback" resolves to localhost and is implicitly bypassed to
// match WinInet.
#define BYPASS_LOOPBACK
#endif
namespace net {
namespace {
......@@ -47,14 +54,18 @@ void ExpectBypassLocalhost(
bool bypasses,
const std::set<std::string>& inverted_hosts = std::set<std::string>()) {
const char* kHosts[] = {
"localhost",
"localhost.",
"foo.localhost",
"localhost6",
"localhost6.localdomain6",
"127.0.0.1",
"127.100.0.2",
"[::1]",
"localhost",
"localhost.",
"foo.localhost",
"localhost6",
"localhost6.localdomain6",
"127.0.0.1",
"127.100.0.2",
"[::1]",
#if defined(BYPASS_LOOPBACK)
"loopback",
"loopback.",
#endif
};
ExpectRulesMatch(rules, kHosts, base::size(kHosts), bypasses, inverted_hosts);
......@@ -76,10 +87,17 @@ void ExpectBypassMisc(
bool bypasses,
const std::set<std::string>& inverted_hosts = std::set<std::string>()) {
const char* kHosts[] = {
"192.168.0.1", "170.254.0.0", "128.0.0.1", "[::2]", "[FD80::1]", "foo",
"www.example3.com",
// On Windows, "loopback" is an implicitly matched hostname.
"loopback",
"192.168.0.1",
"170.254.0.0",
"128.0.0.1",
"[::2]",
"[FD80::1]",
"foo",
"www.example3.com",
#if !defined(BYPASS_LOOPBACK)
"loopback",
"loopback.",
#endif
};
ExpectRulesMatch(rules, kHosts, base::size(kHosts), bypasses, inverted_hosts);
......@@ -343,7 +361,7 @@ TEST(ProxyBypassRulesTest, BypassSimpleHostnames) {
// Confusingly, <local> rule is NOT about localhost names. There is however
// overlap on "localhost6?" as it is both a simple hostname and a localhost
// name
ExpectBypassLocalhost(rules, false, {"localhost", "localhost6"});
ExpectBypassLocalhost(rules, false, {"localhost", "localhost6", "loopback"});
// Should NOT bypass link-local addresses.
ExpectBypassLinkLocal(rules, false);
......
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