1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_DNS_HOST_RESOLVER_H_ 6 #define NET_DNS_HOST_RESOLVER_H_ 7 8 #include <stddef.h> 9 #include <stdint.h> 10 11 #include <memory> 12 #include <optional> 13 #include <set> 14 #include <string> 15 #include <string_view> 16 #include <vector> 17 18 #include "base/containers/span.h" 19 #include "base/values.h" 20 #include "net/base/address_family.h" 21 #include "net/base/completion_once_callback.h" 22 #include "net/base/host_port_pair.h" 23 #include "net/base/network_anonymization_key.h" 24 #include "net/base/network_handle.h" 25 #include "net/base/request_priority.h" 26 #include "net/dns/host_cache.h" 27 #include "net/dns/host_resolver_system_task.h" 28 #include "net/dns/public/dns_config_overrides.h" 29 #include "net/dns/public/dns_query_type.h" 30 #include "net/dns/public/host_resolver_results.h" 31 #include "net/dns/public/host_resolver_source.h" 32 #include "net/dns/public/mdns_listener_update_type.h" 33 #include "net/dns/public/resolve_error_info.h" 34 #include "net/dns/public/secure_dns_policy.h" 35 #include "net/log/net_log_with_source.h" 36 #include "third_party/abseil-cpp/absl/types/variant.h" 37 #include "url/scheme_host_port.h" 38 39 namespace net { 40 41 class AddressList; 42 class ContextHostResolver; 43 class DnsClient; 44 struct DnsConfigOverrides; 45 class HostResolverManager; 46 class NetLog; 47 class URLRequestContext; 48 49 // This class represents the task of resolving hostnames (or IP address 50 // literal) to an AddressList object (or other DNS-style results). 51 // 52 // Typically implemented by ContextHostResolver or wrappers thereof. See 53 // HostResolver::Create[...]() methods for construction or URLRequestContext for 54 // retrieval. 55 // 56 // See mock_host_resolver.h for test implementations. 57 class NET_EXPORT HostResolver { 58 public: 59 class NET_EXPORT Host { 60 public: 61 explicit Host(absl::variant<url::SchemeHostPort, HostPortPair> host); 62 ~Host(); 63 64 Host(const Host&); 65 Host& operator=(const Host&); 66 Host(Host&&); 67 Host& operator=(Host&&); 68 69 bool HasScheme() const; 70 const std::string& GetScheme() const; 71 std::string GetHostname() const; // With brackets for IPv6 literals. 72 std::string_view GetHostnameWithoutBrackets() const; 73 uint16_t GetPort() const; 74 75 std::string ToString() const; 76 77 const url::SchemeHostPort& AsSchemeHostPort() const; 78 79 bool operator==(const Host& other) const { return host_ == other.host_; } 80 81 bool operator<(const Host& other) const { return host_ < other.host_; } 82 83 private: 84 absl::variant<url::SchemeHostPort, HostPortPair> host_; 85 }; 86 87 // Handler for an individual host resolution request. Created by 88 // HostResolver::CreateRequest(). 89 // 90 // TODO(crbug.com/1290920): Most result retrieval here follows a pattern where 91 // it may return null or empty for requests where that result type is not 92 // available. Clean this up to always return empty for such cases and remove 93 // nullability from the return types. 94 class ResolveHostRequest { 95 public: 96 // Destruction cancels the request if running asynchronously, causing the 97 // callback to never be invoked. 98 virtual ~ResolveHostRequest() = default; 99 100 // Starts the request and returns a network error code. 101 // 102 // If the request could not be handled synchronously, returns 103 // |ERR_IO_PENDING|, and completion will be signaled later via |callback|. 104 // On any other returned value, the request was handled synchronously and 105 // |callback| will not be invoked. 106 // 107 // Results in ERR_NAME_NOT_RESOLVED if the hostname is not resolved. More 108 // detail about the underlying error can be retrieved using 109 // GetResolveErrorInfo(). 110 // 111 // The parent HostResolver must still be alive when Start() is called, but 112 // if it is destroyed before an asynchronous result completes, the request 113 // will be automatically cancelled. 114 // 115 // If cancelled before |callback| is invoked, it will never be invoked. 116 virtual int Start(CompletionOnceCallback callback) = 0; 117 118 // Address record (A or AAAA) results of the request. Should only be called 119 // after Start() signals completion, either by invoking the callback or by 120 // returning a result other than |ERR_IO_PENDING|. May return nullptr or 121 // empty for non-address requests. 122 // 123 // TODO(crbug.com/1264933): Remove and replace all usage with 124 // GetEndpointResults(). 125 virtual const AddressList* GetAddressResults() const = 0; 126 127 // Endpoint results for `A`, `AAAA`, `UNSPECIFIED`, or `HTTPS` requests. 128 // Should only be called after Start() signals completion, either by 129 // invoking the callback or by returning a result other than 130 // `ERR_IO_PENDING`. May return nullptr or empty for non-address/HTTPS 131 // requests. 132 virtual const std::vector<HostResolverEndpointResult>* GetEndpointResults() 133 const = 0; 134 135 // Text record (TXT) results of the request. Should only be called after 136 // Start() signals completion, either by invoking the callback or by 137 // returning a result other than |ERR_IO_PENDING|. May return nullptr or 138 // empty for non-TXT requests. 139 virtual const std::vector<std::string>* GetTextResults() const = 0; 140 141 // Hostname record (SRV or PTR) results of the request. For SRV results, 142 // hostnames are ordered according to their priorities and weights. See RFC 143 // 2782. May return nullptr or empty for non-SRV/PTR requests. 144 // 145 // Should only be called after Start() signals completion, either by 146 // invoking the callback or by returning a result other than 147 // |ERR_IO_PENDING|. 148 virtual const std::vector<HostPortPair>* GetHostnameResults() const = 0; 149 150 // Any DNS record aliases, such as CNAME aliases, found as a result of an 151 // address query. Includes all known aliases, e.g. from A, AAAA, or HTTPS, 152 // not just from the address used for the connection, in no particular 153 // order. Should only be called after Start() signals completion, either by 154 // invoking the callback or by returning a result other than 155 // `ERR_IO_PENDING`. Returns a list of aliases that has been fixed up and 156 // canonicalized (as URL hostnames), and thus may differ from the results 157 // stored directly in the AddressList. May return nullptr or empty for 158 // non-address/HTTPS requests. 159 // 160 // If `ResolveHostParameters::include_canonical_name` was true, alias 161 // results will always be the single "canonical name" received from the 162 // system resolver without URL hostname canonicalization (or an empty set or 163 // `nullptr` in the unusual case that the system resolver did not give a 164 // canonical name). 165 virtual const std::set<std::string>* GetDnsAliasResults() const = 0; 166 167 // Result of an experimental query. Meaning depends on the specific query 168 // type, but each boolean value generally refers to a valid or invalid 169 // record of the experimental type. May return nullptr or empty for requests 170 // without experimental result behavior. 171 NET_EXPORT virtual const std::vector<bool>* 172 GetExperimentalResultsForTesting() const; 173 174 // Error info for the request. 175 // 176 // Should only be called after Start() signals completion, either by 177 // invoking the callback or by returning a result other than 178 // |ERR_IO_PENDING|. 179 virtual ResolveErrorInfo GetResolveErrorInfo() const = 0; 180 181 // Information about the result's staleness in the host cache. Only 182 // available if results were received from the host cache, otherwise 183 // returns nullopt. 184 // 185 // Should only be called after Start() signals completion, either by 186 // invoking the callback or by returning a result other than 187 // |ERR_IO_PENDING|. 188 virtual const std::optional<HostCache::EntryStaleness>& GetStaleInfo() 189 const = 0; 190 191 // Changes the priority of the specified request. Can only be called while 192 // the request is running (after Start() returns |ERR_IO_PENDING| and before 193 // the callback is invoked). ChangeRequestPriority(RequestPriority priority)194 virtual void ChangeRequestPriority(RequestPriority priority) {} 195 }; 196 197 // Handler for a service endpoint resolution request. Unlike 198 // ResolveHostRequest, which waits for all responses, this could provide 199 // intermediate endpoint candidates in the middle of the resolution. 200 // 201 // A client owns an instance of this class. Destruction cancels the request. 202 class ServiceEndpointRequest { 203 public: 204 class Delegate { 205 public: 206 virtual ~Delegate() = default; 207 208 // Called when the request has updated endpoints. 209 virtual void OnServiceEndpointsUpdated() = 0; 210 211 // Called when all queries are responded or an error occurred. 212 // Note that this can be called without OnServiceEndpointsUpdated(). 213 virtual void OnServiceEndpointRequestFinished(int rv) = 0; 214 }; 215 216 virtual ~ServiceEndpointRequest() = default; 217 218 // Starts resolving service endpoints. `delegate` is used only when this 219 // method returns ERR_IO_PENDING. When the return value is other than 220 // ERR_IO_PENDING, resolution completed (or an error occurred) 221 // synchronously, and GetEndpointResults() will return finalized results. 222 virtual int Start(Delegate* delegate) = 0; 223 224 // The current available service endpoints. These can be changed over time 225 // while resolution is still ongoing. Changes are signaled by a call to the 226 // delegate's OnServiceEndpointsUpdated(). Results are finalized when 227 // Start() finished synchronously (returning other than ERR_IO_PENDING), or 228 // delegate's OnServiceEndpointRequestFinished() is called. 229 virtual const std::vector<ServiceEndpoint>& GetEndpointResults() = 0; 230 231 // Any DNS record aliases, such as CNAME aliases, found as a result of 232 // addresses and HTTPS queries. These can be changed over time while 233 // resolution is still ongoing. See also the comment on 234 // Request::GetDnsAliasResults() for details. 235 virtual const std::set<std::string>& GetDnsAliasResults() = 0; 236 237 // True if the client of this request can attempt cryptographic handshakes. 238 // If false, the provided service endpoints via GetEndpointResults() are not 239 // finalized to the point to allow completing transactions, and data or 240 // cryptographic handshakes must not be sent. This can be changed over time 241 // while resolution is still ongoing. 242 // TODO(crbug.com/41493696): Consider renaming this to 243 // `IsSvcbResolutionCompleted()` when Chrome supports HTTPS follow-up 244 // queries. 245 virtual bool EndpointsCryptoReady() = 0; 246 }; 247 248 // Handler for an activation of probes controlled by a HostResolver. Created 249 // by HostResolver::CreateDohProbeRequest(). 250 class ProbeRequest { 251 public: 252 // Destruction cancels the request and all probes. 253 virtual ~ProbeRequest() = default; 254 255 // Activates async running of probes. Always returns ERR_IO_PENDING or an 256 // error from activating probes. No callback as probes will never "complete" 257 // until cancellation. 258 virtual int Start() = 0; 259 }; 260 261 // The options for features::kUseDnsHttpsSvcb experiment. See the comments 262 // in net/base/features.h for more details. 263 struct NET_EXPORT HttpsSvcbOptions { 264 HttpsSvcbOptions(); 265 HttpsSvcbOptions(const HttpsSvcbOptions&); 266 HttpsSvcbOptions(HttpsSvcbOptions&&); 267 HttpsSvcbOptions& operator=(const HttpsSvcbOptions&) = default; 268 HttpsSvcbOptions& operator=(HttpsSvcbOptions&&) = default; 269 ~HttpsSvcbOptions(); 270 271 static HttpsSvcbOptions FromDict(const base::Value::Dict& dict); 272 static HttpsSvcbOptions FromFeatures(); 273 274 bool enable = false; 275 base::TimeDelta insecure_extra_time_max; 276 int insecure_extra_time_percent = 0; 277 base::TimeDelta insecure_extra_time_min; 278 base::TimeDelta secure_extra_time_max; 279 int secure_extra_time_percent = 0; 280 base::TimeDelta secure_extra_time_min; 281 }; 282 283 // Parameter-grouping struct for additional optional parameters for creation 284 // of HostResolverManagers and stand-alone HostResolvers. 285 struct NET_EXPORT ManagerOptions { 286 ManagerOptions(); 287 ManagerOptions(const ManagerOptions&); 288 ManagerOptions(ManagerOptions&&); 289 ManagerOptions& operator=(const ManagerOptions&) = default; 290 ManagerOptions& operator=(ManagerOptions&&) = default; 291 ~ManagerOptions(); 292 293 // Set |max_concurrent_resolves| to this to select a default level 294 // of concurrency. 295 static const size_t kDefaultParallelism = 0; 296 297 // How many resolve requests will be allowed to run in parallel. 298 // |kDefaultParallelism| for the resolver to choose a default value. 299 size_t max_concurrent_resolves = kDefaultParallelism; 300 301 // The maximum number of times to retry for host resolution if using the 302 // system resolver. No effect when the system resolver is not used. 303 // |kDefaultRetryAttempts| for the resolver to choose a default value. 304 size_t max_system_retry_attempts = 305 HostResolverSystemTask::Params::kDefaultRetryAttempts; 306 307 // Initial setting for whether the insecure portion of the built-in 308 // asynchronous DnsClient is enabled or disabled. See HostResolverManager:: 309 // SetInsecureDnsClientEnabled() for details. 310 bool insecure_dns_client_enabled = false; 311 312 // Initial setting for whether additional DNS types (e.g. HTTPS) may be 313 // queried when using the built-in resolver for insecure DNS. 314 bool additional_types_via_insecure_dns_enabled = true; 315 316 // Initial configuration overrides for the built-in asynchronous DnsClient. 317 // See HostResolverManager::SetDnsConfigOverrides() for details. 318 DnsConfigOverrides dns_config_overrides; 319 320 // If set to |false|, when on a WiFi connection, IPv6 will be assumed to be 321 // unreachable without actually checking. See https://crbug.com/696569 for 322 // further context. 323 bool check_ipv6_on_wifi = true; 324 325 // An experimental options for features::kUseDnsHttpsSvcb 326 // and features::kUseDnsHttpsSvcbAlpn. 327 std::optional<HostResolver::HttpsSvcbOptions> https_svcb_options; 328 }; 329 330 // Factory class. Useful for classes that need to inject and override resolver 331 // creation for tests. 332 class NET_EXPORT Factory { 333 public: 334 virtual ~Factory() = default; 335 336 // See HostResolver::CreateResolver. 337 virtual std::unique_ptr<HostResolver> CreateResolver( 338 HostResolverManager* manager, 339 std::string_view host_mapping_rules, 340 bool enable_caching); 341 342 // See HostResolver::CreateStandaloneResolver. 343 virtual std::unique_ptr<HostResolver> CreateStandaloneResolver( 344 NetLog* net_log, 345 const ManagerOptions& options, 346 std::string_view host_mapping_rules, 347 bool enable_caching); 348 }; 349 350 // Parameter-grouping struct for additional optional parameters for 351 // CreateRequest() calls. All fields are optional and have a reasonable 352 // default. 353 struct NET_EXPORT ResolveHostParameters { 354 ResolveHostParameters(); 355 ResolveHostParameters(const ResolveHostParameters& other); 356 357 // Requested DNS query type. If UNSPECIFIED, the resolver will select a set 358 // of queries automatically. It will select A, AAAA, or both as the address 359 // queries, depending on IPv4/IPv6 settings and reachability. It may also 360 // replace UNSPECIFIED with additional queries, such as HTTPS. 361 DnsQueryType dns_query_type = DnsQueryType::UNSPECIFIED; 362 363 // The initial net priority for the host resolution request. 364 RequestPriority initial_priority = RequestPriority::DEFAULT_PRIORITY; 365 366 // The source to use for resolved addresses. Default allows the resolver to 367 // pick an appropriate source. Only affects use of big external sources (eg 368 // calling the system for resolution or using DNS). Even if a source is 369 // specified, results can still come from cache, resolving "localhost" or 370 // IP literals, etc. 371 HostResolverSource source = HostResolverSource::ANY; 372 373 enum class CacheUsage { 374 // Results may come from the host cache if non-stale. 375 ALLOWED, 376 377 // Results may come from the host cache even if stale (by expiration or 378 // network changes). In secure dns AUTOMATIC mode, the cache is checked 379 // for both secure and insecure results prior to any secure DNS lookups to 380 // minimize response time. 381 STALE_ALLOWED, 382 383 // Results will not come from the host cache. 384 DISALLOWED, 385 }; 386 CacheUsage cache_usage = CacheUsage::ALLOWED; 387 388 // If |true|, requests special behavior that the "canonical name" be 389 // requested from the system and be returned as the only entry in 390 // `ResolveHostRequest::GetDnsAliasResults()` results. Setting this 391 // parameter is disallowed for any requests that cannot be resolved using 392 // the system resolver, e.g. non-address requests or requests specifying a 393 // non-`SYSTEM` `source`. 394 // 395 // TODO(crbug.com/1282281): Consider allowing the built-in resolver to still 396 // be used with this parameter. Would then function as a request to just 397 // keep the single final name from the alias chain instead of all aliases, 398 // and also skip the canonicalization unless that canonicalization is found 399 // to be fine for usage. 400 bool include_canonical_name = false; 401 402 // Hint to the resolver that resolution is only being requested for loopback 403 // hosts. 404 bool loopback_only = false; 405 406 // Set |true| iff the host resolve request is only being made speculatively 407 // to fill the cache and the result addresses will not be used. The request 408 // will receive special logging/observer treatment, and the result addresses 409 // will always be |std::nullopt|. 410 bool is_speculative = false; 411 412 // If `true`, resolver may (but is not guaranteed to) take steps to avoid 413 // the name being resolved via LLMNR or mDNS. Useful for requests where it 414 // is not desired to wait for longer timeouts on potential negative results, 415 // as is typically the case for LLMNR or mDNS queries without any results. 416 bool avoid_multicast_resolution = false; 417 418 // Controls the resolver's Secure DNS behavior for this request. 419 SecureDnsPolicy secure_dns_policy = SecureDnsPolicy::kAllow; 420 }; 421 422 // Handler for an ongoing MDNS listening operation. Created by 423 // HostResolver::CreateMdnsListener(). 424 class MdnsListener { 425 public: 426 // Delegate type for result update notifications from MdnsListener. All 427 // methods have a |result_type| field to allow a single delegate to be 428 // passed to multiple MdnsListeners and be used to listen for updates for 429 // multiple types for the same host. 430 class Delegate { 431 public: 432 virtual ~Delegate() = default; 433 434 virtual void OnAddressResult(MdnsListenerUpdateType update_type, 435 DnsQueryType result_type, 436 IPEndPoint address) = 0; 437 virtual void OnTextResult(MdnsListenerUpdateType update_type, 438 DnsQueryType result_type, 439 std::vector<std::string> text_records) = 0; 440 virtual void OnHostnameResult(MdnsListenerUpdateType update_type, 441 DnsQueryType result_type, 442 HostPortPair host) = 0; 443 444 // For results which may be valid MDNS but are not handled/parsed by 445 // HostResolver, e.g. pointers to the root domain. 446 virtual void OnUnhandledResult(MdnsListenerUpdateType update_type, 447 DnsQueryType result_type) = 0; 448 }; 449 450 // Destruction cancels the listening operation. 451 virtual ~MdnsListener() = default; 452 453 // Begins the listening operation, invoking |delegate| whenever results are 454 // updated. |delegate| will no longer be called once the listening operation 455 // is cancelled (via destruction of |this|). 456 virtual int Start(Delegate* delegate) = 0; 457 }; 458 459 HostResolver(const HostResolver&) = delete; 460 HostResolver& operator=(const HostResolver&) = delete; 461 462 // If any completion callbacks are pending when the resolver is destroyed, 463 // the host resolutions are cancelled, and the completion callbacks will not 464 // be called. 465 virtual ~HostResolver(); 466 467 // Cancels any pending requests without calling callbacks, same as 468 // destruction, except also leaves the resolver in a mostly-noop state. Any 469 // future request Start() calls (for requests created before or after 470 // OnShutdown()) will immediately fail with ERR_CONTEXT_SHUT_DOWN. 471 virtual void OnShutdown() = 0; 472 473 // Creates a request to resolve the given hostname (or IP address literal). 474 // Profiling information for the request is saved to |net_log| if non-NULL. 475 // 476 // Additional parameters may be set using |optional_parameters|. Reasonable 477 // defaults will be used if passed |nullptr|. 478 virtual std::unique_ptr<ResolveHostRequest> CreateRequest( 479 url::SchemeHostPort host, 480 NetworkAnonymizationKey network_anonymization_key, 481 NetLogWithSource net_log, 482 std::optional<ResolveHostParameters> optional_parameters) = 0; 483 484 // Create requests when scheme is unknown or non-standard. 485 // TODO(crbug.com/1206799): Rename to discourage use when scheme is known. 486 virtual std::unique_ptr<ResolveHostRequest> CreateRequest( 487 const HostPortPair& host, 488 const NetworkAnonymizationKey& network_anonymization_key, 489 const NetLogWithSource& net_log, 490 const std::optional<ResolveHostParameters>& optional_parameters) = 0; 491 492 // Creates a service endpoint resolution request. 493 virtual std::unique_ptr<ServiceEndpointRequest> CreateServiceEndpointRequest( 494 Host host, 495 NetworkAnonymizationKey network_anonymization_key, 496 NetLogWithSource net_log, 497 ResolveHostParameters parameters) = 0; 498 499 // Creates a request to probe configured DoH servers to find which can be used 500 // successfully. 501 virtual std::unique_ptr<ProbeRequest> CreateDohProbeRequest(); 502 503 // Create a listener to watch for updates to an MDNS result. 504 virtual std::unique_ptr<MdnsListener> CreateMdnsListener( 505 const HostPortPair& host, 506 DnsQueryType query_type); 507 508 // Returns the HostResolverCache |this| uses, or NULL if there isn't one. 509 // Used primarily to clear the cache and for getting debug information. 510 virtual HostCache* GetHostCache(); 511 512 // Returns the current DNS configuration |this| is using, as a Value. 513 virtual base::Value::Dict GetDnsConfigAsValue() const; 514 515 // Set the associated URLRequestContext, generally expected to be called by 516 // URLRequestContextBuilder on passing ownership of |this| to a context. May 517 // only be called once. 518 virtual void SetRequestContext(URLRequestContext* request_context); 519 520 virtual HostResolverManager* GetManagerForTesting(); 521 virtual const URLRequestContext* GetContextForTesting() const; 522 virtual handles::NetworkHandle GetTargetNetworkForTesting() const; 523 524 // Creates a new HostResolver. |manager| must outlive the returned resolver. 525 // 526 // If |mapping_rules| is non-empty, the mapping rules will be applied to 527 // requests. See MappedHostResolver for details. 528 static std::unique_ptr<HostResolver> CreateResolver( 529 HostResolverManager* manager, 530 std::string_view host_mapping_rules = "", 531 bool enable_caching = true); 532 533 // Creates a HostResolver independent of any global HostResolverManager. Only 534 // for tests and standalone tools not part of the browser. 535 // 536 // If |mapping_rules| is non-empty, the mapping rules will be applied to 537 // requests. See MappedHostResolver for details. 538 static std::unique_ptr<HostResolver> CreateStandaloneResolver( 539 NetLog* net_log, 540 std::optional<ManagerOptions> options = std::nullopt, 541 std::string_view host_mapping_rules = "", 542 bool enable_caching = true); 543 // Same, but explicitly returns the implementing ContextHostResolver. Only 544 // used by tests and by StaleHostResolver in Cronet. No mapping rules can be 545 // applied because doing so requires wrapping the ContextHostResolver. 546 static std::unique_ptr<ContextHostResolver> CreateStandaloneContextResolver( 547 NetLog* net_log, 548 std::optional<ManagerOptions> options = std::nullopt, 549 bool enable_caching = true); 550 // Same, but bind the resolver to `target_network`: all lookups will be 551 // performed exclusively for `target_network`, lookups will fail if 552 // `target_network` disconnects. This can only be used by network-bound 553 // URLRequestContexts. 554 // Due to the current implementation, if `options` is specified, its 555 // DnsConfigOverrides parameter must be empty. 556 // Only implemented for Android starting from Marshmallow. 557 static std::unique_ptr<HostResolver> CreateStandaloneNetworkBoundResolver( 558 NetLog* net_log, 559 handles::NetworkHandle network, 560 std::optional<ManagerOptions> options = std::nullopt, 561 std::string_view host_mapping_rules = "", 562 bool enable_caching = true); 563 564 // Helpers for interacting with HostCache and ProcResolver. 565 static AddressFamily DnsQueryTypeSetToAddressFamily( 566 DnsQueryTypeSet query_types); 567 static HostResolverFlags ParametersToHostResolverFlags( 568 const ResolveHostParameters& parameters); 569 570 // Helper for squashing error code to a small set of DNS error codes. 571 static int SquashErrorCode(int error); 572 573 // Builds an AddressList from the first non-protocol endpoint found in 574 // `endpoints`. 575 // 576 // TODO(crbug.com/1264933): Delete once `AddressList` usage is fully replaced 577 // in `HostResolver` and results. 578 static AddressList EndpointResultToAddressList( 579 base::span<const HostResolverEndpointResult> endpoints, 580 const std::set<std::string>& aliases); 581 582 // Returns whether there is at least one protocol endpoint in `endpoints`, and 583 // all such endpoints have ECH parameters. This can be used to implement the 584 // guidance in section 10.1 of draft-ietf-dnsop-svcb-https-11. 585 static bool AllProtocolEndpointsHaveEch( 586 base::span<const HostResolverEndpointResult> endpoints); 587 588 // Returns true if NAT64 can be used in place of an IPv4 address during host 589 // resolution. 590 static bool MayUseNAT64ForIPv4Literal(HostResolverFlags flags, 591 HostResolverSource source, 592 const IPAddress& ip_address); 593 594 protected: 595 HostResolver(); 596 597 // Utility to create a request implementation that always fails with |error| 598 // immediately on start. 599 static std::unique_ptr<ResolveHostRequest> CreateFailingRequest(int error); 600 static std::unique_ptr<ProbeRequest> CreateFailingProbeRequest(int error); 601 }; 602 603 } // namespace net 604 605 #endif // NET_DNS_HOST_RESOLVER_H_ 606