customizing "system" DNS server with config key "dns"

This commit is contained in:
zonyitoo
2022-02-25 14:31:42 +08:00
parent 12eadcdd39
commit 9050d726de
3 changed files with 5 additions and 1 deletions

View File

@@ -173,4 +173,4 @@ daemonize = "0.4"
byteorder = "1.3"
env_logger = "0.9"
byte_string = "1.0"
tokio = { version = "1", features = ["net", "time", "macros", "io-util"]}
tokio = { version = "1", features = ["net", "time", "macros", "io-util"] }

View File

@@ -590,6 +590,8 @@ Example configuration:
// Value could be IP address of DNS server, for example, "8.8.8.8".
// DNS client will automatically request port 53 with both TCP and UDP protocol.
//
// - system, uses system provided API (`getaddrinfo` on *NIX)
//
// It also allows some pre-defined well-known public DNS servers:
// - google (TCP, UDP)
// - cloudflare (TCP, UDP)

View File

@@ -1736,6 +1736,8 @@ impl Config {
/// 2. Pre-defined. Like `google`, `cloudflare`
pub fn set_dns_formatted(&mut self, dns: &str) -> Result<(), Error> {
self.dns = match dns {
"system" => DnsConfig::System,
#[cfg(feature = "trust-dns")]
"google" => DnsConfig::TrustDns(ResolverConfig::google()),