diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-09-11 17:55:08 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-09-17 11:14:45 -0300 |
| commit | 57ee8a66fb0ccb82524024d5e76cf5bae2c6cfa8 (patch) | |
| tree | c199b4b49465e62c00717e9553bd198ed384aa41 /talpid-core | |
| parent | a8925c7d5ba0b2cf42d701e66922e29f9341124c (diff) | |
| download | mullvadvpn-57ee8a66fb0ccb82524024d5e76cf5bae2c6cfa8.tar.xz mullvadvpn-57ee8a66fb0ccb82524024d5e76cf5bae2c6cfa8.zip | |
Allow setting the DNS module through env. variable
Diffstat (limited to 'talpid-core')
| -rw-r--r-- | talpid-core/src/security/linux/dns/mod.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/talpid-core/src/security/linux/dns/mod.rs b/talpid-core/src/security/linux/dns/mod.rs index 3e6dafed0f..7cc004ce96 100644 --- a/talpid-core/src/security/linux/dns/mod.rs +++ b/talpid-core/src/security/linux/dns/mod.rs @@ -1,6 +1,7 @@ mod resolvconf; mod static_resolv_conf; +use std::env; use std::net::IpAddr; use self::resolvconf::Resolvconf; @@ -26,6 +27,16 @@ pub enum DnsSettings { 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()) { + Some("static-file") => DnsSettings::StaticResolvConf(StaticResolvConf::new()?), + Some("resolvconf") => DnsSettings::Resolvconf(Resolvconf::new()?), + Some(_) | None => Self::with_detected_dns_manager()?, + }) + } + + fn with_detected_dns_manager() -> Result<Self> { Resolvconf::new() .map(DnsSettings::Resolvconf) .or_else(|_| StaticResolvConf::new().map(DnsSettings::StaticResolvConf)) |
