Eric Orth | 4e55b36 | 2019-05-07 22:00:03 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 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_FUZZED_HOST_RESOLVER_UTIL_H_ |
| 6 | #define NET_DNS_FUZZED_HOST_RESOLVER_UTIL_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | |
| 10 | #include "net/dns/host_resolver.h" |
| 11 | |
Eric Orth | 4e55b36 | 2019-05-07 22:00:03 | [diff] [blame] | 12 | class FuzzedDataProvider; |
Eric Orth | 4e55b36 | 2019-05-07 22:00:03 | [diff] [blame] | 13 | |
| 14 | namespace net { |
| 15 | |
| 16 | class ContextHostResolver; |
| 17 | class NetLog; |
| 18 | |
| 19 | // Creates a ContextHostResolver that uses a fuzzer to determine what results to |
| 20 | // return. It inherits from ContextHostResolver, unlike MockHostResolver, so |
| 21 | // more closely matches real behavior. |
| 22 | // |
dalyk | c27699a | 2019-07-29 20:53:29 | [diff] [blame] | 23 | // By default uses a mocked out system resolver, though can be configured to use |
| 24 | // the built-in async resolver (Built in DNS stub resolver) with a fuzzed set |
| 25 | // of UDP/TCP sockets by setting ManagerOptions.insecure_dns_client_enabled to |
| 26 | // true or calling SetInsecureDnsClientEnabled on the underlying |
| 27 | // HostResolverManager. |
Eric Orth | 4e55b36 | 2019-05-07 22:00:03 | [diff] [blame] | 28 | // |
| 29 | // To make behavior most deterministic, does not use the WorkerPool to run its |
| 30 | // simulated platform host resolver calls, instead runs them on the thread it is |
| 31 | // created on. |
| 32 | // |
| 33 | // Note that it does not attempt to sort the resulting AddressList when using |
| 34 | // the mock system resolver path. |
| 35 | // |
| 36 | // The async DNS client can make system calls in AddressSorterPosix, but other |
| 37 | // methods that make system calls are stubbed out. |
| 38 | std::unique_ptr<ContextHostResolver> CreateFuzzedContextHostResolver( |
| 39 | const HostResolver::ManagerOptions& options, |
| 40 | NetLog* net_log, |
Max Moroz | cfbe47cc | 2019-06-24 17:45:02 | [diff] [blame] | 41 | FuzzedDataProvider* data_provider, |
Eric Orth | 4e55b36 | 2019-05-07 22:00:03 | [diff] [blame] | 42 | bool enable_caching); |
| 43 | |
| 44 | } // namespace net |
| 45 | |
| 46 | #endif // NET_DNS_FUZZED_HOST_RESOLVER_UTIL_H_ |