diff options
| author | Linus Färnstrand <faern@faern.net> | 2023-04-21 13:15:41 +0200 |
|---|---|---|
| committer | Linus Färnstrand <faern@faern.net> | 2023-04-21 13:24:08 +0200 |
| commit | 3a29e794787d95120622a4cacd8442ddf47d151d (patch) | |
| tree | dfe495f906211dd19b436b2f36b620cb6e59efcb | |
| parent | 1db27c74da915b5320bbf2808d8534d123d59dcd (diff) | |
| download | mullvadvpn-3a29e794787d95120622a4cacd8442ddf47d151d.tar.xz mullvadvpn-3a29e794787d95120622a4cacd8442ddf47d151d.zip | |
Rename Windows DNS management error variant names
| -rw-r--r-- | talpid-core/src/dns/windows/auto.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/dns/windows/iphlpapi.rs | 12 | ||||
| -rw-r--r-- | talpid-core/src/dns/windows/netsh.rs | 12 | ||||
| -rw-r--r-- | talpid-core/src/dns/windows/tcpip.rs | 18 |
4 files changed, 22 insertions, 22 deletions
diff --git a/talpid-core/src/dns/windows/auto.rs b/talpid-core/src/dns/windows/auto.rs index a5575820b3..d4cd5d838e 100644 --- a/talpid-core/src/dns/windows/auto.rs +++ b/talpid-core/src/dns/windows/auto.rs @@ -84,7 +84,7 @@ impl DnsMonitor { Err(super::Error::Iphlpapi(iphlpapi::Error::SetInterfaceDnsSettings(error))) => { *error == RPC_S_SERVER_UNAVAILABLE } - Err(super::Error::Netsh(netsh::Error::NetshError(Some(1)))) => true, + Err(super::Error::Netsh(netsh::Error::Netsh(Some(1)))) => true, _ => false, }; if is_dnscache_error { diff --git a/talpid-core/src/dns/windows/iphlpapi.rs b/talpid-core/src/dns/windows/iphlpapi.rs index 98f5034060..8cd8859224 100644 --- a/talpid-core/src/dns/windows/iphlpapi.rs +++ b/talpid-core/src/dns/windows/iphlpapi.rs @@ -29,11 +29,11 @@ use windows_sys::{ pub enum Error { /// Failure to obtain an interface LUID given an alias. #[error(display = "Failed to obtain LUID for the interface alias")] - InterfaceLuidError(#[error(source)] io::Error), + ObtainInterfaceLuid(#[error(source)] io::Error), /// Failure to obtain an interface GUID. #[error(display = "Failed to obtain GUID for the interface")] - InterfaceGuidError(#[error(source)] io::Error), + ObtainInterfaceGuid(#[error(source)] io::Error), /// Failed to set DNS settings on interface. #[error(display = "Failed to set DNS settings on interface: {}", _0)] @@ -41,7 +41,7 @@ pub enum Error { /// Failure to flush DNS cache. #[error(display = "Failed to flush DNS resolver cache")] - FlushResolverCacheError(#[error(source)] super::dnsapi::Error), + FlushResolverCache(#[error(source)] super::dnsapi::Error), /// Failed to load iphlpapi.dll. #[error(display = "Failed to load iphlpapi.dll")] @@ -117,8 +117,8 @@ impl DnsMonitorT for DnsMonitor { } fn set(&mut self, interface: &str, servers: &[IpAddr]) -> Result<(), Error> { - let guid = guid_from_luid(&luid_from_alias(interface).map_err(Error::InterfaceLuidError)?) - .map_err(Error::InterfaceGuidError)?; + let guid = guid_from_luid(&luid_from_alias(interface).map_err(Error::ObtainInterfaceLuid)?) + .map_err(Error::ObtainInterfaceGuid)?; let mut v4_servers = vec![]; let mut v6_servers = vec![]; @@ -208,5 +208,5 @@ fn set_interface_dns_servers<T: ToString>( } fn flush_dns_cache() -> Result<(), Error> { - super::dnsapi::flush_resolver_cache().map_err(Error::FlushResolverCacheError) + super::dnsapi::flush_resolver_cache().map_err(Error::FlushResolverCache) } diff --git a/talpid-core/src/dns/windows/netsh.rs b/talpid-core/src/dns/windows/netsh.rs index 7c0450f855..406b3710c4 100644 --- a/talpid-core/src/dns/windows/netsh.rs +++ b/talpid-core/src/dns/windows/netsh.rs @@ -26,11 +26,11 @@ const NETSH_TIMEOUT: Duration = Duration::from_secs(10); pub enum Error { /// Failure to obtain an interface LUID given an alias. #[error(display = "Failed to obtain LUID for the interface alias")] - InterfaceLuidError(#[error(source)] io::Error), + ObtainInterfaceLuid(#[error(source)] io::Error), /// Failure to obtain an interface index. #[error(display = "Failed to obtain index of the interface")] - InterfaceIndexError(#[error(source)] io::Error), + ObtainInterfaceIndex(#[error(source)] io::Error), /// Failure to spawn netsh subprocess. #[error(display = "Failed to spawn 'netsh'")] @@ -50,7 +50,7 @@ pub enum Error { /// netsh returned a non-zero status. #[error(display = "'netsh' returned an error: {:?}", _0)] - NetshError(Option<i32>), + Netsh(Option<i32>), /// netsh did not return in a timely manner. #[error(display = "'netsh' took too long to complete")] @@ -71,9 +71,9 @@ impl DnsMonitorT for DnsMonitor { } fn set(&mut self, interface: &str, servers: &[IpAddr]) -> Result<(), Error> { - let interface_luid = luid_from_alias(interface).map_err(Error::InterfaceLuidError)?; + let interface_luid = luid_from_alias(interface).map_err(Error::ObtainInterfaceLuid)?; let interface_index = - index_from_luid(&interface_luid).map_err(Error::InterfaceIndexError)?; + index_from_luid(&interface_luid).map_err(Error::ObtainInterfaceIndex)?; self.current_index = Some(interface_index); @@ -154,7 +154,7 @@ fn run_netsh_with_timeout(netsh_input: String, timeout: Duration) -> Result<(), match wait_for_child(&mut subproc, timeout) { Ok(Some(status)) => { if !status.success() { - return Err(Error::NetshError(status.code())); + return Err(Error::Netsh(status.code())); } Ok(()) } diff --git a/talpid-core/src/dns/windows/tcpip.rs b/talpid-core/src/dns/windows/tcpip.rs index 2fdb7e3c28..c1d577f5fe 100644 --- a/talpid-core/src/dns/windows/tcpip.rs +++ b/talpid-core/src/dns/windows/tcpip.rs @@ -15,19 +15,19 @@ use winreg::{ pub enum Error { /// Failure to obtain an interface LUID given an alias. #[error(display = "Failed to obtain LUID for the interface alias")] - InterfaceLuidError(#[error(source)] io::Error), + ObtainInterfaceLuid(#[error(source)] io::Error), /// Failure to obtain an interface GUID. #[error(display = "Failed to obtain GUID for the interface")] - InterfaceGuidError(#[error(source)] io::Error), + ObtainInterfaceGuid(#[error(source)] io::Error), /// Failure to flush DNS cache. #[error(display = "Failed to flush DNS resolver cache")] - FlushResolverCacheError(#[error(source)] super::dnsapi::Error), + FlushResolverCache(#[error(source)] super::dnsapi::Error), /// Failed to update DNS servers for interface. #[error(display = "Failed to update interface DNS servers")] - SetResolversError(#[error(source)] io::Error), + SetResolvers(#[error(source)] io::Error), } pub struct DnsMonitor { @@ -46,8 +46,8 @@ impl DnsMonitorT for DnsMonitor { } fn set(&mut self, interface: &str, servers: &[IpAddr]) -> Result<(), Error> { - let guid = guid_from_luid(&luid_from_alias(interface).map_err(Error::InterfaceLuidError)?) - .map_err(Error::InterfaceGuidError)?; + let guid = guid_from_luid(&luid_from_alias(interface).map_err(Error::ObtainInterfaceLuid)?) + .map_err(Error::ObtainInterfaceGuid)?; set_dns(&guid, servers)?; self.current_guid = Some(guid); if self.should_flush { @@ -75,12 +75,12 @@ impl DnsMonitor { } fn set_dns(interface: &GUID, servers: &[IpAddr]) -> Result<(), Error> { - let transaction = Transaction::new().map_err(Error::SetResolversError)?; + let transaction = Transaction::new().map_err(Error::SetResolvers)?; let result = match set_dns_inner(&transaction, interface, servers) { Ok(()) => transaction.commit(), Err(error) => transaction.rollback().and(Err(error)), }; - result.map_err(Error::SetResolversError) + result.map_err(Error::SetResolvers) } fn set_dns_inner( @@ -157,7 +157,7 @@ fn config_interface<'a>( } fn flush_dns_cache() -> Result<(), Error> { - super::dnsapi::flush_resolver_cache().map_err(Error::FlushResolverCacheError) + super::dnsapi::flush_resolver_cache().map_err(Error::FlushResolverCache) } /// Obtain a string representation for a GUID object. |
