1 // Copyright 2016 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_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 12 class FuzzedDataProvider; 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 // 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. 28 // 29 // To make behavior most deterministic, it is recommended that tests and fuzzers 30 // run all system DNS resolution on the current thread. 31 // 32 // Note that it does not attempt to sort the resulting AddressList when using 33 // the mock system resolver path. 34 // 35 // The async DNS client can make system calls in AddressSorterPosix, but other 36 // methods that make system calls are stubbed out. 37 std::unique_ptr<ContextHostResolver> CreateFuzzedContextHostResolver( 38 const HostResolver::ManagerOptions& options, 39 NetLog* net_log, 40 FuzzedDataProvider* data_provider, 41 bool enable_caching); 42 43 } // namespace net 44 45 #endif // NET_DNS_FUZZED_HOST_RESOLVER_UTIL_H_ 46