diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 19:12:57 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 19:12:57 +0000 |
commit | 123ab1e334b44051297c8d4242e81044478c6588 (patch) | |
tree | 7ba32a449e6715f5f4bace667b161b129745b78d /net/base/host_resolver_proc.cc | |
parent | 57d1ec8fc4b72112bd4d32df76c55395bf33681a (diff) | |
download | chromium_src-123ab1e334b44051297c8d4242e81044478c6588.zip chromium_src-123ab1e334b44051297c8d4242e81044478c6588.tar.gz chromium_src-123ab1e334b44051297c8d4242e81044478c6588.tar.bz2 |
Add a mechanism to disable IPv6.
(1) Adds the ability to specify the address family on a per-request basis.
(2) Exposes a --disable-ipv6 flag to chrome that changes the default address family from AF_UNSPEC to AF_INET (same sort of thing Firefox does).
(3) Changes the backing datastructure for HostCache:EntryMap and HostResolverImpl::JobMap from a "hash_map" to a "std::map". This was for consistency with other code (when I went to add a custom hash trait, I couldn't find any existing code which was using hashmap for custom keys).
(4) Updates about:net-internals to display an address family for the hostcache dump (since it is now a part of the key).
This change is in anticipation of turning off IPv6 host resolving in the PAC utility functions (see bug 24641). But it is also a feature addition.
BUG=24641
TEST=HostCacheTest.AddressFamilyIsPartOfKey
Review URL: http://codereview.chromium.org/302010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29686 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/host_resolver_proc.cc')
-rw-r--r-- | net/base/host_resolver_proc.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc index 8951646..af92087 100644 --- a/net/base/host_resolver_proc.cc +++ b/net/base/host_resolver_proc.cc @@ -52,12 +52,13 @@ HostResolverProc* HostResolverProc::GetDefault() { } int HostResolverProc::ResolveUsingPrevious(const std::string& host, + AddressFamily address_family, AddressList* addrlist) { if (previous_proc_) - return previous_proc_->Resolve(host, addrlist); + return previous_proc_->Resolve(host, address_family, addrlist); // Final fallback is the system resolver. - return SystemHostResolverProc(host, addrlist); + return SystemHostResolverProc(host, address_family, addrlist); } #if defined(OS_LINUX) @@ -124,7 +125,9 @@ ThreadLocalStorage::Slot DnsReloadTimer::tls_index_(base::LINKER_INITIALIZED); #endif // defined(OS_LINUX) -int SystemHostResolverProc(const std::string& host, AddressList* addrlist) { +int SystemHostResolverProc(const std::string& host, + AddressFamily address_family, + AddressList* addrlist) { // The result of |getaddrinfo| for empty hosts is inconsistent across systems. // On Windows it gives the default interface's address, whereas on Linux it // gives an error. We will make it fail on all platforms for consistency. @@ -133,7 +136,14 @@ int SystemHostResolverProc(const std::string& host, AddressList* addrlist) { struct addrinfo* ai = NULL; struct addrinfo hints = {0}; - hints.ai_family = AF_UNSPEC; + + switch (address_family) { + case ADDRESS_FAMILY_IPV4_ONLY: + hints.ai_family = AF_INET; + break; + default: + hints.ai_family = AF_UNSPEC; + } #if defined(OS_WIN) // DO NOT USE AI_ADDRCONFIG ON WINDOWS. |