diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-10-10 12:30:57 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-10-10 12:30:57 +0200 |
| commit | 6dc00a8cd1985451bd9d89c8b0f5105af88241f8 (patch) | |
| tree | ab0202f1d11448b94c6c067b97d01a98452cf983 | |
| parent | 5459b51327c7ae7b660ddf97a3f82467146382e5 (diff) | |
| parent | 6129cd1e0fcc118f125dc3200377396e5e8c7428 (diff) | |
| download | mullvadvpn-6dc00a8cd1985451bd9d89c8b0f5105af88241f8.tar.xz mullvadvpn-6dc00a8cd1985451bd9d89c8b0f5105af88241f8.zip | |
Merge branch 'log-linux-dns-manager'
| -rw-r--r-- | talpid-core/src/security/linux/dns/mod.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/talpid-core/src/security/linux/dns/mod.rs b/talpid-core/src/security/linux/dns/mod.rs index 9a5c915061..2e1760bd1c 100644 --- a/talpid-core/src/security/linux/dns/mod.rs +++ b/talpid-core/src/security/linux/dns/mod.rs @@ -3,8 +3,7 @@ mod resolvconf; mod static_resolv_conf; mod systemd_resolved; -use std::env; -use std::net::IpAddr; +use std::{env, fmt, net::IpAddr}; use self::network_manager::NetworkManager; use self::resolvconf::Resolvconf; @@ -33,17 +32,31 @@ pub enum DnsSettings { NetworkManager(NetworkManager), } +impl fmt::Display for DnsSettings { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let name = match self { + DnsSettings::Resolvconf(..) => "resolvconf", + DnsSettings::StaticResolvConf(..) => "/etc/resolv.conf", + DnsSettings::SystemdResolved(..) => "systemd-resolve", + DnsSettings::NetworkManager(..) => "network manager", + }; + f.write_str(name) + } +} + impl DnsSettings { pub fn new() -> Result<Self> { let dns_module = env::var_os("TALPID_DNS_MODULE"); - Ok(match dns_module.as_ref().and_then(|value| value.to_str()) { + let manager = match dns_module.as_ref().and_then(|value| value.to_str()) { Some("static-file") => DnsSettings::StaticResolvConf(StaticResolvConf::new()?), Some("resolvconf") => DnsSettings::Resolvconf(Resolvconf::new()?), Some("systemd") => DnsSettings::SystemdResolved(SystemdResolved::new()?), Some("network-manager") => DnsSettings::NetworkManager(NetworkManager::new()?), Some(_) | None => Self::with_detected_dns_manager()?, - }) + }; + debug!("Managing DNS via {}", manager); + Ok(manager) } fn with_detected_dns_manager() -> Result<Self> { |
