summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-07-24 13:39:57 +0200
committerDavid Lönnhager <david.l@mullvad.net>2020-08-04 10:52:43 +0200
commit4128984c95ebd25c8c30ff19fb0e992f4f6f9b5a (patch)
treef9304d51d1559593a012c6099f51b64f6e5f63e7
parentabf7bb0dd3021daef52593515a98b0ebb189d9a0 (diff)
downloadmullvadvpn-4128984c95ebd25c8c30ff19fb0e992f4f6f9b5a.tar.xz
mullvadvpn-4128984c95ebd25c8c30ff19fb0e992f4f6f9b5a.zip
Add specific firewall policy errors
-rw-r--r--mullvad-cli/src/cmds/status.rs7
-rw-r--r--talpid-types/src/tunnel.rs36
2 files changed, 39 insertions, 4 deletions
diff --git a/mullvad-cli/src/cmds/status.rs b/mullvad-cli/src/cmds/status.rs
index 10834b60b3..ffa834134e 100644
--- a/mullvad-cli/src/cmds/status.rs
+++ b/mullvad-cli/src/cmds/status.rs
@@ -120,8 +120,11 @@ fn print_blocked_reason(reason: &ErrorStateCause) {
println!("Blocked: {}", AuthFailed::from(auth_failure_str));
}
#[cfg(target_os = "linux")]
- ErrorStateCause::SetFirewallPolicyError => {
- println!("Blocked: {}", ErrorStateCause::SetFirewallPolicyError);
+ ErrorStateCause::SetFirewallPolicyError(error) => {
+ println!(
+ "Blocked: {}",
+ ErrorStateCause::SetFirewallPolicyError(error.clone())
+ );
println!("Your kernel might be terribly out of date or missing nftables");
}
other => println!("Blocked: {}", other),
diff --git a/talpid-types/src/tunnel.rs b/talpid-types/src/tunnel.rs
index dda152d3f1..202db6002b 100644
--- a/talpid-types/src/tunnel.rs
+++ b/talpid-types/src/tunnel.rs
@@ -75,7 +75,7 @@ pub enum ErrorStateCause {
/// Failed to configure IPv6 because it's disabled in the platform.
Ipv6Unavailable,
/// Failed to set firewall policy.
- SetFirewallPolicyError,
+ SetFirewallPolicyError(FirewallPolicyError),
/// Failed to set system DNS server.
SetDnsError,
/// Failed to start connection to remote server.
@@ -111,6 +111,30 @@ pub enum ParameterGenerationError {
CustomTunnelHostResultionError,
}
+/// Application that prevents setting the firewall policy.
+#[cfg(windows)]
+#[derive(Debug, Serialize, Clone, PartialEq, Deserialize)]
+pub struct BlockingApplication {
+ pub name: String,
+ pub pid: u32,
+}
+
+/// Errors that can occur when setting the firewall policy.
+#[derive(err_derive::Error, Debug, Serialize, Clone, PartialEq, Deserialize)]
+#[serde(rename_all = "snake_case")]
+#[serde(tag = "reason", content = "details")]
+#[cfg_attr(target_os = "android", derive(IntoJava))]
+#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.talpid.tunnel"))]
+pub enum FirewallPolicyError {
+ /// General firewall failure
+ #[error(display = "Failed to set firewall policy")]
+ Generic,
+ /// An application prevented the firewall policy from being set
+ #[cfg(windows)]
+ #[error(display = "An application prevented the firewall policy from being set")]
+ Locked(Option<BlockingApplication>),
+}
+
impl fmt::Display for ErrorStateCause {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::ErrorStateCause::*;
@@ -126,7 +150,15 @@ impl fmt::Display for ErrorStateCause {
);
}
Ipv6Unavailable => "Failed to configure IPv6 because it's disabled in the platform",
- SetFirewallPolicyError => "Failed to set firewall policy",
+ SetFirewallPolicyError(ref err) => {
+ return match err {
+ #[cfg(windows)]
+ FirewallPolicyError::Locked(Some(value)) => {
+ write!(f, "{}: {} (pid {})", err, value.name, value.pid)
+ }
+ _ => write!(f, "{}", err),
+ };
+ }
SetDnsError => "Failed to set system DNS server",
StartTunnelError => "Failed to start connection to remote server",
TunnelParameterError(ref err) => {