summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-11 17:55:08 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-17 11:14:45 -0300
commit57ee8a66fb0ccb82524024d5e76cf5bae2c6cfa8 (patch)
treec199b4b49465e62c00717e9553bd198ed384aa41
parenta8925c7d5ba0b2cf42d701e66922e29f9341124c (diff)
downloadmullvadvpn-57ee8a66fb0ccb82524024d5e76cf5bae2c6cfa8.tar.xz
mullvadvpn-57ee8a66fb0ccb82524024d5e76cf5bae2c6cfa8.zip
Allow setting the DNS module through env. variable
-rw-r--r--README.md6
-rw-r--r--talpid-core/src/security/linux/dns/mod.rs11
2 files changed, 17 insertions, 0 deletions
diff --git a/README.md b/README.md
index e3d1d3c642..9b4065a2d6 100644
--- a/README.md
+++ b/README.md
@@ -140,6 +140,12 @@ sections.
* `TALPID_NFTABLES_COUNTERS` - Set to `"1"` to add packet counters to all firewall rules on
Linux.
+* `TALPID_DNS_MODULE` - Allows changing the method that will be used for DNS configuration on Linux.
+ By default this is automatically detected, but you can set it to one of the options below to
+ choose a specific method:
+ * `"static-file"`: change the `/etc/resolv.conf` file directly
+ * `"resolvconf"`: use the `resolvconf` program
+
## Building and running the Electron GUI app
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))