Skip to content

Commit

Permalink
Flag myIpAddress requests for chromeos
Browse files Browse the repository at this point in the history
This is a follow-up to https://codereview.chromium.org/238433003

We need to differentiate between myIpAddress requests and other
localhost requests so that local web servers and tests work correctly.

BUG=387109

Review URL: https://codereview.chromium.org/355953002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280230 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
stevenjb@chromium.org committed Jun 27, 2014
1 parent a14c261 commit 86a782c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chromeos/network/host_resolver_impl_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool HostResolverImplChromeOS::ResolveLocalIPAddress(
const RequestInfo& info,
net::AddressList* addresses) {
DCHECK(thread_checker_.CalledOnValidThread());
if (info.hostname() != net::GetHostName() || ipv4_address_.empty())
if (!info.is_my_ip_address() || ipv4_address_.empty())
return false;

// Use IPConfig data for localhost address lookup.
Expand Down
1 change: 1 addition & 0 deletions chromeos/network/host_resolver_impl_chromeos_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ TEST_F(HostResolverImplChromeOSTest, Resolve) {
net::HostResolver::RequestInfo info(
net::HostPortPair(net::GetHostName(), 80));
info.set_address_family(net::ADDRESS_FAMILY_IPV4);
info.set_is_my_ip_address(true);
EXPECT_EQ(net::OK, CallResolve(info));
ASSERT_EQ(1u, addresses_.size());
std::string expected = base::StringPrintf("%s:%d", kTestIPv4Address, 0);
Expand Down
3 changes: 2 additions & 1 deletion net/dns/host_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair)
address_family_(ADDRESS_FAMILY_UNSPECIFIED),
host_resolver_flags_(0),
allow_cached_response_(true),
is_speculative_(false) {}
is_speculative_(false),
is_my_ip_address_(false) {}

HostResolver::~HostResolver() {
}
Expand Down
7 changes: 7 additions & 0 deletions net/dns/host_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class NET_EXPORT HostResolver {
bool is_speculative() const { return is_speculative_; }
void set_is_speculative(bool b) { is_speculative_ = b; }

bool is_my_ip_address() const { return is_my_ip_address_; }
void set_is_my_ip_address(bool b) { is_my_ip_address_ = b; }

private:
// The hostname to resolve, and the port to use in resulting sockaddrs.
HostPortPair host_port_pair_;
Expand All @@ -103,6 +106,10 @@ class NET_EXPORT HostResolver {

// Whether this request was started by the DNS prefetcher.
bool is_speculative_;

// Indicates a request for myIpAddress (to differentiate from other requests
// for localhost, currently used by Chrome OS).
bool is_my_ip_address_;
};

// Opaque type used to cancel a request.
Expand Down
7 changes: 6 additions & 1 deletion net/proxy/proxy_resolver_v8_tracing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,12 @@ HostResolver::RequestInfo ProxyResolverV8Tracing::Job::MakeDnsRequestInfo(
}

HostResolver::RequestInfo info(host_port);

// Flag myIpAddress requests.
if (op == MY_IP_ADDRESS || op == MY_IP_ADDRESS_EX) {
// TODO: Provide a RequestInfo construction mechanism that does not
// require a hostname and sets is_my_ip_address to true instead of this.
info.set_is_my_ip_address(true);
}
// The non-ex flavors are limited to IPv4 results.
if (op == MY_IP_ADDRESS || op == DNS_RESOLVE) {
info.set_address_family(ADDRESS_FAMILY_IPV4);
Expand Down

0 comments on commit 86a782c

Please sign in to comment.