summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2023-08-07 13:55:03 +0200
committerDavid Lönnhager <david.l@mullvad.net>2023-08-08 11:04:45 +0200
commit79bf21804b0ddf7783910903fafb12d9c4f5da4a (patch)
treed5e14fb5e0b3f98b2691faa871a9bf5bc48e2f20
parent19c2fd3325dd0ac3dcfb30a66b9a30fc0c524e99 (diff)
downloadmullvadvpn-79bf21804b0ddf7783910903fafb12d9c4f5da4a.tar.xz
mullvadvpn-79bf21804b0ddf7783910903fafb12d9c4f5da4a.zip
Explain why run-time linking is used for SetInterfaceDnsSettings
-rw-r--r--talpid-core/src/dns/windows/iphlpapi.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/talpid-core/src/dns/windows/iphlpapi.rs b/talpid-core/src/dns/windows/iphlpapi.rs
index d76b2db6c7..9fe4b3bfc4 100644
--- a/talpid-core/src/dns/windows/iphlpapi.rs
+++ b/talpid-core/src/dns/windows/iphlpapi.rs
@@ -1,3 +1,8 @@
+//! DNS monitor that uses `SetInterfaceDnsSettings`. According to
+//! <https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-setinterfacednssettings>,
+//! it requires at least Windows 10, build 19041. For that reason, use run-time linking and fall
+//! back on other methods if it is not available.
+
use crate::dns::DnsMonitorT;
use once_cell::sync::OnceCell;
use std::{
@@ -75,6 +80,8 @@ impl IphlpApi {
return Err(Error::LoadDll(io::Error::last_os_error()));
}
+ // This function is loaded at runtime since it may be unavailable. See the module-level docs.
+ // TODO: `windows_sys` can be used directly when support for Windows 10, 2004, is dropped.
let set_interface_dns_settings =
unsafe { GetProcAddress(module, s!("SetInterfaceDnsSettings")) };
let set_interface_dns_settings = set_interface_dns_settings.ok_or_else(|| {