mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-21 15:26:13 -05:00
Compare commits
3
Commits
v3.7.1
...
release/next
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e718ff3357 | ||
|
|
a63c1e74db | ||
|
|
22c2a383da |
No files matched your search
Generated
+13
-13
@@ -292,7 +292,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auth"
|
name = "auth"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"block2",
|
"block2",
|
||||||
@@ -554,7 +554,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "browser-launcher"
|
name = "browser-launcher"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"log",
|
"log",
|
||||||
@@ -919,7 +919,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
@@ -2133,7 +2133,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gp-xml"
|
name = "gp-xml"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"url",
|
"url",
|
||||||
"xmltree",
|
"xmltree",
|
||||||
@@ -2141,7 +2141,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpapi"
|
name = "gpapi"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
@@ -2205,7 +2205,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpauth"
|
name = "gpauth"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"auth",
|
"auth",
|
||||||
@@ -2223,7 +2223,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpclient"
|
name = "gpclient"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -2254,7 +2254,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpgui-helper"
|
name = "gpgui-helper"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -2275,7 +2275,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gphip"
|
name = "gphip"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"askama",
|
"askama",
|
||||||
@@ -2294,7 +2294,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpservice"
|
name = "gpservice"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -2332,7 +2332,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gptunnel"
|
name = "gptunnel"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gpapi",
|
"gpapi",
|
||||||
"log",
|
"log",
|
||||||
@@ -2344,7 +2344,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpvpnc"
|
name = "gpvpnc"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
"ipnet",
|
"ipnet",
|
||||||
@@ -3860,7 +3860,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openconnect"
|
name = "openconnect"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autotools",
|
"autotools",
|
||||||
"cc",
|
"cc",
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ members = [
|
|||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
rust-version = "1.91"
|
rust-version = "1.91"
|
||||||
version = "3.7.0"
|
version = "3.7.1"
|
||||||
authors = ["Kevin Yue <[email protected]>"]
|
authors = ["Kevin Yue <[email protected]>"]
|
||||||
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|||||||
@@ -2,7 +2,13 @@
|
|||||||
|
|
||||||
**GP Connect** is a GlobalProtect VPN client built on OpenConnect. The desktop app runs on Windows, macOS, Linux, FreeBSD, and OpenBSD. The command-line client is `gpclient`.
|
**GP Connect** is a GlobalProtect VPN client built on OpenConnect. The desktop app runs on Windows, macOS, Linux, FreeBSD, and OpenBSD. The command-line client is `gpclient`.
|
||||||
|
|
||||||
[Features](#features) · [Installation](#installation) · [Usage](#usage) · [Troubleshooting](#troubleshooting) · [Building from source](#building-from-source)
|
<p align="center">
|
||||||
|
<a href="#features">Features</a> ·
|
||||||
|
<a href="#installation">Installation</a> ·
|
||||||
|
<a href="#usage">Usage</a> ·
|
||||||
|
<a href="#troubleshooting">Troubleshooting</a> ·
|
||||||
|
<a href="#building-from-source">Building from source</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<picture>
|
<picture>
|
||||||
@@ -117,7 +123,7 @@ On glibc systems, install the prebuilt package:
|
|||||||
sudo emerge --ask net-vpn/globalprotect-openconnect-bin::yuezk
|
sudo emerge --ask net-vpn/globalprotect-openconnect-bin::yuezk
|
||||||
```
|
```
|
||||||
|
|
||||||
The source package is `net-vpn/globalprotect-openconnect::yuezk`.
|
The source package is `net-vpn/globalprotect-openconnect::yuezk`. For a headless installation, see the [CLI-only overlay instructions](https://github.com/yuezk/gentoo-overlay#cli-only).
|
||||||
|
|
||||||
If Portage requests keyword or USE flag changes, review and apply them, then rerun the install command.
|
If Portage requests keyword or USE flag changes, review and apply them, then rerun the install command.
|
||||||
|
|
||||||
@@ -154,7 +160,7 @@ Packages are available on the [openSUSE Build Service](https://build.opensuse.or
|
|||||||
|
|
||||||
### Other Distributions
|
### Other Distributions
|
||||||
|
|
||||||
Requires glibc 2.39 or later. Download the archive for [x86_64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.0/globalprotect-openconnect_3.7.0_x86_64.bin.tar.xz) or [ARM64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.0/globalprotect-openconnect_3.7.0_aarch64.bin.tar.xz).
|
Download the archive for [x86_64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.0/globalprotect-openconnect_3.7.0_x86_64.bin.tar.xz) or [ARM64](https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v3.7.0/globalprotect-openconnect_3.7.0_aarch64.bin.tar.xz).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tar -xJf globalprotect-openconnect_*.bin.tar.xz
|
tar -xJf globalprotect-openconnect_*.bin.tar.xz
|
||||||
|
|||||||
@@ -325,7 +325,10 @@ async fn wait_for_brokered_idle(
|
|||||||
_ = interval.tick() => {},
|
_ = interval.tick() => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
let idle = matches!(*vpn_state_rx.borrow(), VpnState::Disconnected | VpnState::Failed(_)) && registry.is_empty();
|
let idle = matches!(
|
||||||
|
*vpn_state_rx.borrow(),
|
||||||
|
VpnState::Disconnected | VpnState::UnexpectedDisconnect { .. } | VpnState::Failed(_)
|
||||||
|
) && registry.is_empty();
|
||||||
if !idle {
|
if !idle {
|
||||||
idle_since = None;
|
idle_since = None;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -174,6 +174,12 @@ impl RequestDispatcher {
|
|||||||
.stop_non_tunnel_attachment(authority.session_id, authority.generation, connection_id)?;
|
.stop_non_tunnel_attachment(authority.session_id, authority.generation, connection_id)?;
|
||||||
Ok(PendingDispatch::Drain(drain))
|
Ok(PendingDispatch::Drain(drain))
|
||||||
}
|
}
|
||||||
|
WsRequest::AbandonReconnect { attempt } => {
|
||||||
|
let authority = authority
|
||||||
|
.ok_or_else(|| ServiceResult::rejected(ServiceErrorCode::InvalidRequest, "Connection session is missing"))?;
|
||||||
|
self.lifecycle.abandon_reconnect(attempt, authority.session_id);
|
||||||
|
Err(ServiceResult::Accepted)
|
||||||
|
}
|
||||||
WsRequest::Disconnect(_) => Err(self.lifecycle.request_disconnect()),
|
WsRequest::Disconnect(_) => Err(self.lifecycle.request_disconnect()),
|
||||||
request => Ok(PendingDispatch::Other(request)),
|
request => Ok(PendingDispatch::Other(request)),
|
||||||
}
|
}
|
||||||
@@ -259,6 +265,7 @@ impl RequestDispatcher {
|
|||||||
ServiceResult::Accepted
|
ServiceResult::Accepted
|
||||||
}
|
}
|
||||||
WsRequest::Connect(_)
|
WsRequest::Connect(_)
|
||||||
|
| WsRequest::AbandonReconnect { .. }
|
||||||
| WsRequest::StopNonTunnelAttachment { .. }
|
| WsRequest::StopNonTunnelAttachment { .. }
|
||||||
| WsRequest::Disconnect(_)
|
| WsRequest::Disconnect(_)
|
||||||
| WsRequest::StoreEditedHipReportChunk(_)
|
| WsRequest::StoreEditedHipReportChunk(_)
|
||||||
|
|||||||
+180
-16
@@ -76,6 +76,7 @@ impl LifecycleHandle {
|
|||||||
let cancellation = CancellationToken::new();
|
let cancellation = CancellationToken::new();
|
||||||
admissions.current = Some(Admission {
|
admissions.current = Some(Admission {
|
||||||
attempt,
|
attempt,
|
||||||
|
restart,
|
||||||
phase: AdmissionPhase::Preparing,
|
phase: AdmissionPhase::Preparing,
|
||||||
stop_requested: false,
|
stop_requested: false,
|
||||||
cancellation: cancellation.clone(),
|
cancellation: cancellation.clone(),
|
||||||
@@ -89,6 +90,19 @@ impl LifecycleHandle {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn abandon_reconnect(&self, attempt: u64, owner: Uuid) {
|
||||||
|
let mut admissions = self.admissions.lock().expect("VPN lifecycle admissions mutex poisoned");
|
||||||
|
// A replacement that already owns admission will publish its own outcome.
|
||||||
|
if admissions.restart == Some((attempt, owner)) {
|
||||||
|
admissions.restart = None;
|
||||||
|
self.state.send_replace(VpnState::UnexpectedDisconnect {
|
||||||
|
attempt,
|
||||||
|
owner,
|
||||||
|
reason: None,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn submit_test_connection(
|
fn submit_test_connection(
|
||||||
&self,
|
&self,
|
||||||
@@ -217,7 +231,7 @@ impl LifecycleHandle {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_attempt(&self, attempt: u64) {
|
fn clear_attempt(&self, attempt: u64, state: Option<VpnState>) {
|
||||||
let completion = {
|
let completion = {
|
||||||
let mut admissions = self.admissions.lock().expect("VPN lifecycle admissions mutex poisoned");
|
let mut admissions = self.admissions.lock().expect("VPN lifecycle admissions mutex poisoned");
|
||||||
let Some(admission) = admissions.current.as_ref() else {
|
let Some(admission) = admissions.current.as_ref() else {
|
||||||
@@ -226,6 +240,20 @@ impl LifecycleHandle {
|
|||||||
if admission.attempt != attempt {
|
if admission.attempt != attempt {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let state = match admission.restart {
|
||||||
|
Some((attempt, owner)) if !admission.stop_requested && !admissions.closed => {
|
||||||
|
let reason = match state {
|
||||||
|
Some(VpnState::Failed(reason)) => Some(reason),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
Some(VpnState::UnexpectedDisconnect { attempt, owner, reason })
|
||||||
|
}
|
||||||
|
Some(_) if state.is_none() => Some(VpnState::Disconnected),
|
||||||
|
_ => state,
|
||||||
|
};
|
||||||
|
if let Some(state) = state {
|
||||||
|
self.state.send_replace(state);
|
||||||
|
}
|
||||||
let completion = Arc::clone(&admission.completion);
|
let completion = Arc::clone(&admission.completion);
|
||||||
admissions.current = None;
|
admissions.current = None;
|
||||||
completion
|
completion
|
||||||
@@ -357,7 +385,7 @@ impl Drop for ConnectReservation {
|
|||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if !self.transferred {
|
if !self.transferred {
|
||||||
self.cancellation.cancel();
|
self.cancellation.cancel();
|
||||||
self.lifecycle.clear_attempt(self.attempt);
|
self.lifecycle.clear_attempt(self.attempt, None);
|
||||||
// A full queue already wakes the actor; a closed queue has no actor to wake.
|
// A full queue already wakes the actor; a closed queue has no actor to wake.
|
||||||
let _ = self.lifecycle.events.try_send(LifecycleEvent::PreparationReleased);
|
let _ = self.lifecycle.events.try_send(LifecycleEvent::PreparationReleased);
|
||||||
}
|
}
|
||||||
@@ -375,6 +403,7 @@ struct Admissions {
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct Admission {
|
struct Admission {
|
||||||
attempt: u64,
|
attempt: u64,
|
||||||
|
restart: Option<(u64, Uuid)>,
|
||||||
phase: AdmissionPhase,
|
phase: AdmissionPhase,
|
||||||
stop_requested: bool,
|
stop_requested: bool,
|
||||||
cancellation: CancellationToken,
|
cancellation: CancellationToken,
|
||||||
@@ -444,6 +473,7 @@ struct ActiveAttempt {
|
|||||||
task: tokio::task::JoinHandle<()>,
|
task: tokio::task::JoinHandle<()>,
|
||||||
failure: Option<String>,
|
failure: Option<String>,
|
||||||
reconnect_required: bool,
|
reconnect_required: bool,
|
||||||
|
tunnel_established: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct VpnTask {
|
pub(crate) struct VpnTask {
|
||||||
@@ -638,6 +668,7 @@ impl VpnTask {
|
|||||||
task,
|
task,
|
||||||
failure: None,
|
failure: None,
|
||||||
reconnect_required: false,
|
reconnect_required: false,
|
||||||
|
tunnel_established: false,
|
||||||
});
|
});
|
||||||
if activated {
|
if activated {
|
||||||
self.send_state(VpnState::Connecting(Box::new(info)));
|
self.send_state(VpnState::Connecting(Box::new(info)));
|
||||||
@@ -720,16 +751,20 @@ impl VpnTask {
|
|||||||
self.send_state(VpnState::Connected(Box::new(info.with_members(members, failures))));
|
self.send_state(VpnState::Connected(Box::new(info.with_members(members, failures))));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn publish_connected(&self, attempt: u64, info: ConnectInfo, session_info: SessionInfo) {
|
fn publish_connected(&mut self, attempt: u64, info: ConnectInfo, session_info: SessionInfo) {
|
||||||
let connected = VpnState::Connected(Box::new(ConnectedInfo::new(info, Some(session_info))));
|
let connected = VpnState::Connected(Box::new(ConnectedInfo::new(info, Some(session_info))));
|
||||||
let admissions = self
|
let mut admissions = self
|
||||||
.lifecycle
|
.lifecycle
|
||||||
.admissions
|
.admissions
|
||||||
.lock()
|
.lock()
|
||||||
.expect("VPN lifecycle admissions mutex poisoned");
|
.expect("VPN lifecycle admissions mutex poisoned");
|
||||||
if admissions.current.as_ref().is_some_and(|admission| {
|
if let Some(admission) = admissions.current.as_mut().filter(|admission| {
|
||||||
admission.attempt == attempt && admission.phase == AdmissionPhase::Active && !admission.stop_requested
|
admission.attempt == attempt && admission.phase == AdmissionPhase::Active && !admission.stop_requested
|
||||||
}) {
|
}) {
|
||||||
|
admission.restart = None;
|
||||||
|
if let Some(active) = self.active.as_mut().filter(|active| active.attempt == attempt) {
|
||||||
|
active.tunnel_established = true;
|
||||||
|
}
|
||||||
self.send_state(connected);
|
self.send_state(connected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -777,17 +812,23 @@ impl VpnTask {
|
|||||||
admission.completion.completed.store(true, Ordering::Release);
|
admission.completion.completed.store(true, Ordering::Release);
|
||||||
admission.completion.notify.notify_waiters();
|
admission.completion.notify.notify_waiters();
|
||||||
}
|
}
|
||||||
} else if let Some(reason) = active.failure {
|
|
||||||
self.send_state(VpnState::Failed(reason));
|
|
||||||
self.lifecycle.clear_attempt(attempt);
|
|
||||||
} else {
|
} else {
|
||||||
self.finish_attempt(attempt);
|
let unexpectedly_ended = active
|
||||||
|
.session_id
|
||||||
|
.filter(|_| active.tunnel_established && !active.cancellation.is_cancelled());
|
||||||
|
let state = if let Some(owner) = unexpectedly_ended {
|
||||||
|
VpnState::UnexpectedDisconnect {
|
||||||
|
attempt,
|
||||||
|
owner,
|
||||||
|
reason: active.failure,
|
||||||
}
|
}
|
||||||
|
} else if let Some(reason) = active.failure {
|
||||||
|
VpnState::Failed(reason)
|
||||||
|
} else {
|
||||||
|
VpnState::Disconnected
|
||||||
|
};
|
||||||
|
self.lifecycle.clear_attempt(attempt, Some(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finish_attempt(&self, attempt: u64) {
|
|
||||||
self.send_state(VpnState::Disconnected);
|
|
||||||
self.lifecycle.clear_attempt(attempt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_state(&self, state: VpnState) {
|
fn send_state(&self, state: VpnState) {
|
||||||
@@ -1067,6 +1108,7 @@ mod tests {
|
|||||||
task: tokio::spawn(async {}),
|
task: tokio::spawn(async {}),
|
||||||
failure: None,
|
failure: None,
|
||||||
reconnect_required: false,
|
reconnect_required: false,
|
||||||
|
tunnel_established: false,
|
||||||
});
|
});
|
||||||
task.send_state(VpnState::Connecting(Box::new(info)));
|
task.send_state(VpnState::Connecting(Box::new(info)));
|
||||||
let mut member = gpapi::session::GatewaySessionSummary {
|
let mut member = gpapi::session::GatewaySessionSummary {
|
||||||
@@ -1087,6 +1129,126 @@ mod tests {
|
|||||||
task.end_attempt(0).await;
|
task.end_attempt(0).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn unexpected_disconnect_requires_an_established_tunnel() {
|
||||||
|
for established in [false, true] {
|
||||||
|
let (state, observed) = watch::channel(VpnState::Disconnected);
|
||||||
|
let (mut task, lifecycle) = VpnTask::new(state, false, registry());
|
||||||
|
let owner = Uuid::new_v4();
|
||||||
|
let info = ConnectInfo::new(
|
||||||
|
"portal.example.com".into(),
|
||||||
|
gpapi::gateway::Gateway::new("vpn".into(), "vpn.example.com".into()),
|
||||||
|
vec![],
|
||||||
|
);
|
||||||
|
let reservation = lifecycle.reserve_connect(None).unwrap();
|
||||||
|
let cancellation = reservation.cancellation();
|
||||||
|
assert_eq!(
|
||||||
|
reservation.commit(
|
||||||
|
PreparedConnection::lifecycle_fixture(test_connect_request(info.clone())),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Some(owner),
|
||||||
|
),
|
||||||
|
ServiceResult::Accepted
|
||||||
|
);
|
||||||
|
let _ = task.events.try_recv().unwrap();
|
||||||
|
assert!(lifecycle.activate_attempt(0));
|
||||||
|
task.active = Some(ActiveAttempt {
|
||||||
|
attempt: 0,
|
||||||
|
session_id: Some(owner),
|
||||||
|
info: info.clone(),
|
||||||
|
allow_extend_session: false,
|
||||||
|
cancellation,
|
||||||
|
task: tokio::spawn(async {}),
|
||||||
|
failure: None,
|
||||||
|
reconnect_required: false,
|
||||||
|
tunnel_established: false,
|
||||||
|
});
|
||||||
|
if established {
|
||||||
|
task.establish_attempt(0, VpnSessionInfo::default());
|
||||||
|
assert!(matches!(*observed.borrow(), VpnState::Connected(_)));
|
||||||
|
}
|
||||||
|
task.send_state(VpnState::Connecting(Box::new(info)));
|
||||||
|
task.end_attempt(0).await;
|
||||||
|
if established {
|
||||||
|
assert!(matches!(
|
||||||
|
*observed.borrow(),
|
||||||
|
VpnState::UnexpectedDisconnect { attempt: 0, owner: actual, .. } if actual == owner
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
assert!(matches!(*observed.borrow(), VpnState::Disconnected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn abandoning_reconnect_cannot_end_an_admitted_replacement() {
|
||||||
|
let (state, mut observed) = watch::channel(VpnState::Disconnected);
|
||||||
|
let (_task, lifecycle) = VpnTask::new(state, false, registry());
|
||||||
|
let owner = Uuid::new_v4();
|
||||||
|
let restart = (7, owner);
|
||||||
|
lifecycle.admissions.lock().unwrap().restart = Some(restart);
|
||||||
|
|
||||||
|
lifecycle.abandon_reconnect(7, Uuid::new_v4());
|
||||||
|
assert!(!observed.has_changed().unwrap());
|
||||||
|
let replacement = lifecycle.reserve_connect(Some(restart)).unwrap();
|
||||||
|
lifecycle.abandon_reconnect(7, owner);
|
||||||
|
assert!(!observed.has_changed().unwrap());
|
||||||
|
|
||||||
|
drop(replacement);
|
||||||
|
assert!(matches!(
|
||||||
|
*observed.borrow_and_update(),
|
||||||
|
VpnState::UnexpectedDisconnect { attempt: 7, owner: actual, .. } if actual == owner
|
||||||
|
));
|
||||||
|
lifecycle.abandon_reconnect(7, owner);
|
||||||
|
assert!(!observed.has_changed().unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn abandoning_an_unclaimed_reconnect_reports_loss_and_rejects_late_admission() {
|
||||||
|
let (state, observed) = watch::channel(VpnState::Disconnected);
|
||||||
|
let (_task, lifecycle) = VpnTask::new(state, false, registry());
|
||||||
|
let owner = Uuid::new_v4();
|
||||||
|
lifecycle.admissions.lock().unwrap().restart = Some((7, owner));
|
||||||
|
|
||||||
|
lifecycle.abandon_reconnect(7, owner);
|
||||||
|
assert!(matches!(
|
||||||
|
*observed.borrow(),
|
||||||
|
VpnState::UnexpectedDisconnect { attempt: 7, owner: actual, .. } if actual == owner
|
||||||
|
));
|
||||||
|
assert!(lifecycle.reserve_connect(Some((7, owner))).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn established_replacement_settles_the_original_reconnect() {
|
||||||
|
let (state, observed) = watch::channel(VpnState::Disconnected);
|
||||||
|
let (mut task, lifecycle) = VpnTask::new(state, false, registry());
|
||||||
|
let owner = Uuid::new_v4();
|
||||||
|
let info = ConnectInfo::new(
|
||||||
|
"portal.example.com".into(),
|
||||||
|
gpapi::gateway::Gateway::new("vpn".into(), "vpn.example.com".into()),
|
||||||
|
vec![],
|
||||||
|
);
|
||||||
|
lifecycle.admissions.lock().unwrap().restart = Some((7, owner));
|
||||||
|
let replacement = lifecycle.reserve_connect(Some((7, owner))).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
replacement.commit(
|
||||||
|
PreparedConnection::lifecycle_fixture(test_connect_request(info.clone())),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
Some(owner),
|
||||||
|
),
|
||||||
|
ServiceResult::Accepted
|
||||||
|
);
|
||||||
|
assert!(lifecycle.activate_attempt(0));
|
||||||
|
task.publish_connected(0, info, SessionInfo::default());
|
||||||
|
lifecycle.abandon_reconnect(7, owner);
|
||||||
|
assert!(matches!(*observed.borrow(), VpnState::Connected(_)));
|
||||||
|
|
||||||
|
lifecycle.clear_attempt(0, Some(VpnState::Disconnected));
|
||||||
|
assert!(matches!(*observed.borrow(), VpnState::Disconnected));
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn disconnect_completion_waits_for_the_owned_attempt_task() {
|
async fn disconnect_completion_waits_for_the_owned_attempt_task() {
|
||||||
let (state, state_rx) = watch::channel(VpnState::Disconnected);
|
let (state, state_rx) = watch::channel(VpnState::Disconnected);
|
||||||
@@ -1122,6 +1284,7 @@ mod tests {
|
|||||||
task: worker,
|
task: worker,
|
||||||
failure: None,
|
failure: None,
|
||||||
reconnect_required: false,
|
reconnect_required: false,
|
||||||
|
tunnel_established: true,
|
||||||
});
|
});
|
||||||
assert_eq!(lifecycle.request_disconnect(), ServiceResult::Accepted);
|
assert_eq!(lifecycle.request_disconnect(), ServiceResult::Accepted);
|
||||||
let stop = task.events.recv().await.unwrap();
|
let stop = task.events.recv().await.unwrap();
|
||||||
@@ -1169,6 +1332,7 @@ mod tests {
|
|||||||
task: tokio::spawn(async {}),
|
task: tokio::spawn(async {}),
|
||||||
failure: None,
|
failure: None,
|
||||||
reconnect_required: false,
|
reconnect_required: false,
|
||||||
|
tunnel_established: false,
|
||||||
});
|
});
|
||||||
task.send_state(VpnState::Connecting(Box::new(
|
task.send_state(VpnState::Connecting(Box::new(
|
||||||
task.active.as_ref().unwrap().info.clone(),
|
task.active.as_ref().unwrap().info.clone(),
|
||||||
@@ -1220,7 +1384,7 @@ mod tests {
|
|||||||
fn late_established_event_is_ignored_after_disconnect_is_accepted() {
|
fn late_established_event_is_ignored_after_disconnect_is_accepted() {
|
||||||
let (vpn_state_tx, vpn_state_rx) = watch::channel(VpnState::Disconnected);
|
let (vpn_state_tx, vpn_state_rx) = watch::channel(VpnState::Disconnected);
|
||||||
let state_rx = vpn_state_rx.clone();
|
let state_rx = vpn_state_rx.clone();
|
||||||
let (task, lifecycle) = VpnTask::new(vpn_state_tx, false, registry());
|
let (mut task, lifecycle) = VpnTask::new(vpn_state_tx, false, registry());
|
||||||
let info = ConnectInfo::new(
|
let info = ConnectInfo::new(
|
||||||
"portal.example.com".to_string(),
|
"portal.example.com".to_string(),
|
||||||
gpapi::gateway::Gateway::new("vpn".to_string(), "vpn.example.com".to_string()),
|
gpapi::gateway::Gateway::new("vpn".to_string(), "vpn.example.com".to_string()),
|
||||||
@@ -1242,7 +1406,7 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn disconnect_waiter_completes_for_its_attempt_before_a_later_connect() {
|
async fn disconnect_waiter_completes_for_its_attempt_before_a_later_connect() {
|
||||||
let (vpn_state_tx, _vpn_state_rx) = watch::channel(VpnState::Disconnected);
|
let (vpn_state_tx, _vpn_state_rx) = watch::channel(VpnState::Disconnected);
|
||||||
let (task, lifecycle) = VpnTask::new(vpn_state_tx, false, registry());
|
let (_task, lifecycle) = VpnTask::new(vpn_state_tx, false, registry());
|
||||||
let request = || {
|
let request = || {
|
||||||
test_connect_request(ConnectInfo::new(
|
test_connect_request(ConnectInfo::new(
|
||||||
"portal.example.com".to_string(),
|
"portal.example.com".to_string(),
|
||||||
@@ -1261,7 +1425,7 @@ mod tests {
|
|||||||
tokio::task::yield_now().await;
|
tokio::task::yield_now().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
task.finish_attempt(0);
|
lifecycle.clear_attempt(0, Some(VpnState::Disconnected));
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
lifecycle.submit_test_connection(request(), None, None, None),
|
lifecycle.submit_test_connection(request(), None, None, None),
|
||||||
ServiceResult::Accepted
|
ServiceResult::Accepted
|
||||||
|
|||||||
@@ -733,7 +733,7 @@ mod tests {
|
|||||||
|
|
||||||
async fn watch_vpn_state(mut vpn_state_rx: watch::Receiver<VpnState>, ctx: Arc<WsServerContext>) {
|
async fn watch_vpn_state(mut vpn_state_rx: watch::Receiver<VpnState>, ctx: Arc<WsServerContext>) {
|
||||||
while vpn_state_rx.changed().await.is_ok() {
|
while vpn_state_rx.changed().await.is_ok() {
|
||||||
let vpn_state = vpn_state_rx.borrow().clone();
|
let vpn_state = vpn_state_rx.borrow_and_update().clone();
|
||||||
ctx.send_event(WsEvent::VpnState(vpn_state)).await;
|
ctx.send_event(WsEvent::VpnState(vpn_state)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 3.7.1
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Show a desktop notification on Windows, Linux, FreeBSD, and OpenBSD when the VPN disconnects unexpectedly and automatic reconnect fails.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Make the Native Shell Close button visible in light mode and give it a consistent appearance across Linux themes.
|
||||||
|
- Allow turning off Compatibility Graphics in the Tauri interface.
|
||||||
|
|
||||||
## 3.7.0
|
## 3.7.0
|
||||||
|
|
||||||
- Linux now opens Native Shell by default on supported systems, including Alpine. Upgrades keep your saved interface choice.
|
- Linux now opens Native Shell by default on supported systems, including Alpine. Upgrades keep your saved interface choice.
|
||||||
|
|||||||
@@ -427,6 +427,7 @@ pub enum WsRequest {
|
|||||||
SetWindowsPatchInterest { enabled: bool },
|
SetWindowsPatchInterest { enabled: bool },
|
||||||
RefreshWindowsPatches { after: Option<u64> },
|
RefreshWindowsPatches { after: Option<u64> },
|
||||||
Connect(Box<ConnectRequest>),
|
Connect(Box<ConnectRequest>),
|
||||||
|
AbandonReconnect { attempt: u64 },
|
||||||
Disconnect(DisconnectRequest),
|
Disconnect(DisconnectRequest),
|
||||||
StopNonTunnelAttachment { connection_id: uuid::Uuid },
|
StopNonTunnelAttachment { connection_id: uuid::Uuid },
|
||||||
StoreEditedHipReportChunk(StoreEditedHipReportChunkRequest),
|
StoreEditedHipReportChunk(StoreEditedHipReportChunkRequest),
|
||||||
|
|||||||
@@ -116,6 +116,11 @@ impl ConnectInfo {
|
|||||||
pub enum VpnState {
|
pub enum VpnState {
|
||||||
ReconnectRequired(Box<ReconnectRequest>),
|
ReconnectRequired(Box<ReconnectRequest>),
|
||||||
Disconnected,
|
Disconnected,
|
||||||
|
UnexpectedDisconnect {
|
||||||
|
attempt: u64,
|
||||||
|
owner: uuid::Uuid,
|
||||||
|
reason: Option<String>,
|
||||||
|
},
|
||||||
Failed(String),
|
Failed(String),
|
||||||
Connecting(Box<ConnectInfo>),
|
Connecting(Box<ConnectInfo>),
|
||||||
Connected(Box<ConnectedInfo>),
|
Connected(Box<ConnectedInfo>),
|
||||||
|
|||||||
Reference in new issue
Block a user