Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/dns/dns_config_service_posix.h" | 5 #include "net/dns/dns_config_service_posix.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
| 15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 16 #include "net/dns/dns_protocol.h" | |
| 16 #include "net/dns/serial_worker.h" | 17 #include "net/dns/serial_worker.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 #ifndef _PATH_RESCONF // Normally defined in <resolv.h> | 23 #ifndef _PATH_RESCONF // Normally defined in <resolv.h> |
| 23 #define _PATH_RESCONF "/etc/resolv.conf" | 24 #define _PATH_RESCONF "/etc/resolv.conf" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 } | 183 } |
| 183 | 184 |
| 184 dns_config->ndots = res.ndots; | 185 dns_config->ndots = res.ndots; |
| 185 dns_config->timeout = base::TimeDelta::FromSeconds(res.retrans); | 186 dns_config->timeout = base::TimeDelta::FromSeconds(res.retrans); |
| 186 dns_config->attempts = res.retry; | 187 dns_config->attempts = res.retry; |
| 187 #if defined(RES_ROTATE) | 188 #if defined(RES_ROTATE) |
| 188 dns_config->rotate = res.options & RES_ROTATE; | 189 dns_config->rotate = res.options & RES_ROTATE; |
| 189 #endif | 190 #endif |
| 190 dns_config->edns0 = res.options & RES_USE_EDNS0; | 191 dns_config->edns0 = res.options & RES_USE_EDNS0; |
| 191 | 192 |
| 193 // If the only name server is 0.0.0.0:53, assume the configuration is invalid. | |
| 194 const IPEndPoint kDefaultAddress(IPAddressNumber(kIPv4AddressSize), | |
| 195 dns_protocol::kDefaultPort); | |
| 196 if (dns_config->nameservers.size() == 1) | |
| 197 return !(dns_config->nameservers.front() == kDefaultAddress); | |
|
mmenke
2012/06/11 22:38:54
Wonder if it makes more sense to fail if any of th
szym
2012/06/14 16:18:20
Done.
| |
| 192 return true; | 198 return true; |
| 193 } | 199 } |
| 194 #endif // !defined(OS_ANDROID) | 200 #endif // !defined(OS_ANDROID) |
| 195 | 201 |
| 196 } // namespace internal | 202 } // namespace internal |
| 197 | 203 |
| 198 // static | 204 // static |
| 199 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { | 205 scoped_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { |
| 200 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServicePosix()); | 206 return scoped_ptr<DnsConfigService>(new internal::DnsConfigServicePosix()); |
| 201 } | 207 } |
| 202 | 208 |
| 203 } // namespace net | 209 } // namespace net |
| OLD | NEW |