summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2025-05-21 18:43:12 +0200
committerDavid Lönnhager <david.l@mullvad.net>2025-05-22 12:51:31 +0200
commitf66e9b92cb75e0342cd3757efc3de7ef6d7e1b9f (patch)
tree37f7a00d50be9184ac5059f34b3c7144b8c0d83b
parentef5e2ee5f694bd687db0b94ad67c14c53f287c31 (diff)
downloadmullvadvpn-f66e9b92cb75e0342cd3757efc3de7ef6d7e1b9f.tar.xz
mullvadvpn-f66e9b92cb75e0342cd3757efc3de7ef6d7e1b9f.zip
Reconnect when unavailable IP version becomes available
-rw-r--r--CHANGELOG.md2
-rw-r--r--talpid-core/src/tunnel_state_machine/error_state.rs7
-rw-r--r--talpid-types/src/net/mod.rs8
3 files changed, 15 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef2a197b7f..16a59fb8b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,8 @@ supported.
- Use a local DNS resolver on the 127.0.0.0/8 network, regardless of macOS version.
### Fixed
+- Automatically connect when IP version becomes available.
+
#### Linux
- Fix syntax error in Apparmor profile.
diff --git a/talpid-core/src/tunnel_state_machine/error_state.rs b/talpid-core/src/tunnel_state_machine/error_state.rs
index ca280b9584..8ee25c764a 100644
--- a/talpid-core/src/tunnel_state_machine/error_state.rs
+++ b/talpid-core/src/tunnel_state_machine/error_state.rs
@@ -10,7 +10,7 @@ use crate::firewall::FirewallPolicy;
use crate::resolver::LOCAL_DNS_RESOLVER;
use futures::StreamExt;
use talpid_types::{
- tunnel::{ErrorStateCause, FirewallPolicyError},
+ tunnel::{ErrorStateCause, FirewallPolicyError, ParameterGenerationError},
ErrorExt,
};
@@ -185,7 +185,10 @@ impl TunnelState for ErrorState {
Some(TunnelCommand::Connectivity(connectivity)) => {
shared_values.connectivity = connectivity;
if !connectivity.is_offline()
- && matches!(self.block_reason, ErrorStateCause::IsOffline)
+ // Reconnect if we're no longer offline
+ && (matches!(self.block_reason, ErrorStateCause::IsOffline)
+ // Try to reconnect if missing IP connectivity becomes available
+ || matches!(self.block_reason, ErrorStateCause::TunnelParameterError(ParameterGenerationError::IpVersionUnavailable { family }) if connectivity.has_family(family)))
{
#[cfg(target_os = "macos")]
if !*LOCAL_DNS_RESOLVER {
diff --git a/talpid-types/src/net/mod.rs b/talpid-types/src/net/mod.rs
index 68d8b0a0b8..b92bdc9ffc 100644
--- a/talpid-types/src/net/mod.rs
+++ b/talpid-types/src/net/mod.rs
@@ -613,6 +613,14 @@ impl Connectivity {
.unwrap_or(false)
}
+ /// Whether connectivity for `ip_version` seems to be available on the host.
+ pub fn has_family(&self, ip_version: IpVersion) -> bool {
+ match ip_version {
+ IpVersion::V4 => self.has_ipv4(),
+ IpVersion::V6 => self.has_ipv6(),
+ }
+ }
+
pub fn new(ipv4: bool, ipv6: bool) -> Connectivity {
match (ipv4, ipv6) {
(true, true) => Connectivity::Online(IpAvailability::Ipv4AndIpv6),