// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_DNS_PUBLIC_DNS_CONFIG_OVERRIDES_H_ #define NET_DNS_PUBLIC_DNS_CONFIG_OVERRIDES_H_ #include #include #include "base/time/time.h" #include "net/base/ip_endpoint.h" #include "net/base/net_export.h" #include "net/dns/public/dns_over_https_config.h" #include "net/dns/public/secure_dns_mode.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace net { struct DnsConfig; // Overriding values to be applied over a DnsConfig struct. struct NET_EXPORT DnsConfigOverrides { DnsConfigOverrides(); DnsConfigOverrides(const DnsConfigOverrides& other); DnsConfigOverrides(DnsConfigOverrides&& other); ~DnsConfigOverrides(); DnsConfigOverrides& operator=(const DnsConfigOverrides& other); DnsConfigOverrides& operator=(DnsConfigOverrides&& other); bool operator==(const DnsConfigOverrides& other) const; bool operator!=(const DnsConfigOverrides& other) const; // Creation method that initializes all values with the defaults from // DnsConfig. Guarantees the result of OverridesEverything() will be |true|. static DnsConfigOverrides CreateOverridingEverythingWithDefaults(); // Creates a new DnsConfig where any field with an overriding value in |this| // is replaced with that overriding value. Any field without an overriding // value (|absl::nullopt|) will be copied as-is from |config|. DnsConfig ApplyOverrides(const DnsConfig& config) const; // Returns |true| if the overriding configuration is comprehensive and would // override everything in a base DnsConfig. This is the case if all Optional // fields have a value. bool OverridesEverything() const; // Overriding values. See same-named fields in DnsConfig for explanations. absl::optional> nameservers; absl::optional dns_over_tls_active; absl::optional dns_over_tls_hostname; absl::optional> search; absl::optional append_to_multi_label_name; absl::optional ndots; absl::optional fallback_period; absl::optional attempts; absl::optional doh_attempts; absl::optional rotate; absl::optional use_local_ipv6; absl::optional dns_over_https_config; absl::optional secure_dns_mode; absl::optional allow_dns_over_https_upgrade; // |hosts| is not supported for overriding except to clear it. bool clear_hosts = false; // Note no overriding value for |unhandled_options|. It is meta-configuration, // and there should be no reason to override it. }; } // namespace net #endif // NET_DNS_PUBLIC_DNS_CONFIG_OVERRIDES_H_