#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/dns/dns_config_service_linux.h"
#include <netdb.h>
#include <netinet/in.h>
#include <resolv.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/files/file_path_watcher.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/sequence_checker.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/time/time.h"
#include "net/base/ip_endpoint.h"
#include "net/dns/dns_config.h"
#include "net/dns/nsswitch_reader.h"
#include "net/dns/public/resolv_reader.h"
#include "net/dns/serial_worker.h"
namespace net {
namespace internal {
namespace {
const base::FilePath::CharType kFilePathHosts[] = …);
#ifndef _PATH_RESCONF
#define _PATH_RESCONF …
#endif
constexpr base::FilePath::CharType kFilePathResolv[] = …;
#ifndef _PATH_NSSWITCH_CONF
#define _PATH_NSSWITCH_CONF …
#endif
constexpr base::FilePath::CharType kFilePathNsswitch[] = …;
std::optional<DnsConfig> ConvertResStateToDnsConfig(
const struct __res_state& res) { … }
bool SetActionBehavior(const NsswitchReader::ServiceAction& action,
std::map<NsswitchReader::Status, NsswitchReader::Action>&
in_out_parsed_behavior) { … }
bool AreActionsCompatible(
const std::vector<NsswitchReader::ServiceAction>& actions,
const std::map<NsswitchReader::Status, NsswitchReader::Action>
expected_actions) { … }
enum class IncompatibleNsswitchReason { … };
void RecordIncompatibleNsswitchReason(
IncompatibleNsswitchReason reason,
std::optional<NsswitchReader::Service> service_token) { … }
bool IsNsswitchConfigCompatible(
const std::vector<NsswitchReader::ServiceSpecification>& nsswitch_hosts) { … }
}
class DnsConfigServiceLinux::Watcher : public DnsConfigService::Watcher { … };
class DnsConfigServiceLinux::ConfigReader : public SerialWorker { … };
DnsConfigServiceLinux::DnsConfigServiceLinux()
: … { … }
DnsConfigServiceLinux::~DnsConfigServiceLinux() { … }
void DnsConfigServiceLinux::ReadConfigNow() { … }
bool DnsConfigServiceLinux::StartWatching() { … }
void DnsConfigServiceLinux::CreateReader() { … }
}
std::unique_ptr<DnsConfigService> DnsConfigService::CreateSystemService() { … }
}