summaryrefslogtreecommitdiffhomepage
path: root/talpid-dbus
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2021-05-26 15:17:22 +0200
committerDavid Lönnhager <david.l@mullvad.net>2021-06-09 15:55:08 +0200
commit3258b05945fddfddb98dff967c1bd1cbc04608c1 (patch)
tree950e51c7e2a65ac6138d6beb43d668dceef85eaa /talpid-dbus
parent998fa82ebaa7dc056c38607c437c0837c4c26b72 (diff)
downloadmullvadvpn-3258b05945fddfddb98dff967c1bd1cbc04608c1.tar.xz
mullvadvpn-3258b05945fddfddb98dff967c1bd1cbc04608c1.zip
Work around issue where systemd-resolved only replaces a single existing DNS server on an interface
Diffstat (limited to 'talpid-dbus')
-rw-r--r--talpid-dbus/src/systemd_resolved.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/talpid-dbus/src/systemd_resolved.rs b/talpid-dbus/src/systemd_resolved.rs
index 67836a2772..d8cf6f8419 100644
--- a/talpid-dbus/src/systemd_resolved.rs
+++ b/talpid-dbus/src/systemd_resolved.rs
@@ -44,6 +44,9 @@ pub enum Error {
#[error(display = "Failed to revert DNS settings of interface: {}", _0)]
RevertDnsError(String, #[error(source)] dbus::Error),
+ #[error(display = "Failed to replace DNS settings")]
+ ReplaceDnsError,
+
#[error(display = "Failed to perform RPC call on D-Bus")]
DBusRpcError(#[error(source)] dbus::Error),
@@ -318,7 +321,31 @@ impl SystemdResolved {
.iter()
.map(|addr| (ip_version(addr), ip_to_bytes(addr)))
.collect::<Vec<_>>();
- self.as_link_object(link_object_path.clone())
+ let link_object = self.as_link_object(link_object_path.clone());
+ let mut attempt = 0;
+ loop {
+ // Workaround for bug where old resolvers are not properly
+ // replaced in systemd-resolved.
+ // v248.3
+ link_object
+ .method_call(
+ LINK_INTERFACE,
+ SET_DNS_METHOD,
+ (Vec::<(i32, Vec<u8>)>::new(),),
+ )
+ .map_err(Error::DBusRpcError)?;
+ let new_servers: Vec<(i32, Vec<u8>)> = link_object
+ .get(LINK_INTERFACE, DNS_SERVERS)
+ .map_err(Error::DBusRpcError)?;
+ if new_servers.is_empty() {
+ break;
+ }
+ if attempt == 10 {
+ return Err(Error::ReplaceDnsError);
+ }
+ attempt += 1;
+ }
+ link_object
.method_call(LINK_INTERFACE, SET_DNS_METHOD, (servers,))
.map_err(Error::DBusRpcError)
}