Compare commits

..

2 Commits

Author SHA1 Message Date
Kevin Yue
a7ad02acb6
Release 2.4.2 2025-01-20 20:57:57 +08:00
Kevin Yue
b188d61be1
fix: disconnect VPN when sleep 2025-01-20 19:29:22 +08:00
7 changed files with 27 additions and 16 deletions

16
Cargo.lock generated
View File

@ -176,7 +176,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]]
name = "auth"
version = "2.4.1"
version = "2.4.2"
dependencies = [
"anyhow",
"block2",
@ -642,7 +642,7 @@ dependencies = [
[[package]]
name = "common"
version = "2.4.1"
version = "2.4.2"
dependencies = [
"is_executable",
]
@ -1590,7 +1590,7 @@ dependencies = [
[[package]]
name = "gpapi"
version = "2.4.1"
version = "2.4.2"
dependencies = [
"anyhow",
"base64 0.22.1",
@ -1626,7 +1626,7 @@ dependencies = [
[[package]]
name = "gpauth"
version = "2.4.1"
version = "2.4.2"
dependencies = [
"anyhow",
"auth",
@ -1645,7 +1645,7 @@ dependencies = [
[[package]]
name = "gpclient"
version = "2.4.1"
version = "2.4.2"
dependencies = [
"anyhow",
"clap",
@ -1667,7 +1667,7 @@ dependencies = [
[[package]]
name = "gpgui-helper"
version = "2.4.1"
version = "2.4.2"
dependencies = [
"anyhow",
"clap",
@ -1685,7 +1685,7 @@ dependencies = [
[[package]]
name = "gpservice"
version = "2.4.1"
version = "2.4.2"
dependencies = [
"anyhow",
"axum",
@ -2951,7 +2951,7 @@ dependencies = [
[[package]]
name = "openconnect"
version = "2.4.1"
version = "2.4.2"
dependencies = [
"cc",
"common",

View File

@ -11,7 +11,7 @@ members = [
[workspace.package]
rust-version = "1.80"
version = "2.4.1"
version = "2.4.2"
authors = ["Kevin Yue <k3vinyue@gmail.com>"]
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
edition = "2021"

View File

@ -22,7 +22,7 @@ serde_json.workspace = true
whoami.workspace = true
tempfile.workspace = true
reqwest.workspace = true
directories = "5.0"
directories.workspace = true
compile-time.workspace = true
[features]

View File

@ -177,13 +177,14 @@ mod signals {
tokio::select! {
_ = user_sig1.recv() => {
info!("Received SIGUSR1 signal");
vpn_ctx.disconnect().await;
if vpn_ctx.disconnect().await {
// Write the PID to a dedicated file to indicate that the VPN task is disconnected via SIGUSR1
let pid = std::process::id();
if let Err(err) = tokio::fs::write(DISCONNECTED_PID_FILE, pid.to_string()).await {
warn!("Failed to write PID to file: {}", err);
}
}
}
_ = user_sig2.recv() => {
info!("Received SIGUSR2 signal");
ws_ctx.send_event(WsEvent::ResumeConnection).await;

View File

@ -90,7 +90,7 @@ impl VpnTaskContext {
});
}
pub async fn disconnect(&self) {
pub async fn disconnect(&self) -> bool {
if let Some(disconnect_rx) = self.disconnect_rx.write().await.take() {
info!("Disconnecting VPN...");
if let Some(vpn) = self.vpn_handle.read().await.as_ref() {
@ -101,9 +101,13 @@ impl VpnTaskContext {
// Wait for the VPN to be disconnected
disconnect_rx.await.ok();
info!("VPN disconnected");
true
} else {
info!("VPN is not connected, skip disconnect");
self.vpn_state_tx.send(VpnState::Disconnected).ok();
false
}
}
}

View File

@ -1,5 +1,9 @@
# Changelog
## 2.4.2 - 2025-01-20
- Disconnect the VPN when sleep (fix [#166](https://github.com/yuezk/GlobalProtect-openconnect/issues/166), [#267](https://github.com/yuezk/GlobalProtect-openconnect/issues/267))
## 2.4.1 - 2025-01-09
- Fix the network issue with OpenSSL < 3.0.4

2
rust-toolchain.toml Normal file
View File

@ -0,0 +1,2 @@
[toolchain]
channel = "1.80.1"