diff options
-rw-r--r-- | net/base/host_resolver_impl.cc | 2 | ||||
-rw-r--r-- | net/base/host_resolver_proc.cc | 23 | ||||
-rw-r--r-- | net/base/host_resolver_proc.h | 3 |
3 files changed, 28 insertions, 0 deletions
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index 94c3857..252df00 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -53,6 +53,8 @@ HostResolver* CreateSystemHostResolver( HostResolverImpl* resolver = new HostResolverImpl( NULL, CreateDefaultCache(), network_change_notifier, kMaxJobs); + if (!HostResolverProc::IPv6Supported()) + resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); return resolver; } diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc index 5ccf01a..d4e0766 100644 --- a/net/base/host_resolver_proc.cc +++ b/net/base/host_resolver_proc.cc @@ -227,4 +227,27 @@ int SystemHostResolverProc(const std::string& host, return OK; } +// TODO(jar): The following is a simple estimate of ipv6 support. We may need +// to do a test resolution, and a test connection, to REALLY verify support. +// static +bool HostResolverProc::IPv6Supported() { +#if defined(OS_POSIX) + int test_socket; +#else + SOCKET test_socket; +#endif + + test_socket = socket(AF_INET6, SOCK_STREAM, 0); + if (test_socket == -1) + return false; + +#if defined(OS_POSIX) + close(test_socket); +#else + closesocket(test_socket); +#endif + + return true; +} + } // namespace net diff --git a/net/base/host_resolver_proc.h b/net/base/host_resolver_proc.h index ca0c55d..343125d 100644 --- a/net/base/host_resolver_proc.h +++ b/net/base/host_resolver_proc.h @@ -32,6 +32,9 @@ class HostResolverProc : public base::RefCountedThreadSafe<HostResolverProc> { AddressFamily address_family, AddressList* addrlist) = 0; + // Test to see if IPv6 is supported. + static bool IPv6Supported(); + protected: friend class base::RefCountedThreadSafe<HostResolverProc>; |