mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-17 13:46:27 -05:00
feat: add support for client version emulation and integrate OpenConnect submodule
This commit is contained in:
21 files changed
+273
-29
No files matched your search
@@ -54,6 +54,7 @@ jobs:
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.ref }}
|
||||
path: source/gp
|
||||
submodules: recursive
|
||||
|
||||
- name: Create tarball
|
||||
run: |
|
||||
@@ -194,6 +195,7 @@ jobs:
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.ref }}
|
||||
path: gpgui-source/gp
|
||||
submodules: recursive
|
||||
- name: Checkout gpgui@${{ github.ref_name }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -249,6 +251,7 @@ jobs:
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.ref }}
|
||||
path: gh-release/gp
|
||||
submodules: recursive
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "deps/openconnect"]
|
||||
path = deps/openconnect
|
||||
url = https://gitlab.com/openconnect/openconnect.git
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Mac",
|
||||
"includePath": ["/opt/homebrew/include"],
|
||||
"includePath": ["deps/openconnect"],
|
||||
"macFrameworkPath": ["/System/Library/Frameworks", "/Library/Frameworks"],
|
||||
"intelliSenseMode": "macos-clang-x64",
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
|
||||
Generated
+18
@@ -190,6 +190,15 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "autotools"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef941527c41b0fc0dd48511a8154cd5fc7e29200a0ff8b7203c5d777dbc795cf"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "axum"
|
||||
version = "0.8.6"
|
||||
@@ -1235,6 +1244,12 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fs_extra"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||
|
||||
[[package]]
|
||||
name = "futf"
|
||||
version = "0.1.5"
|
||||
@@ -2981,9 +2996,12 @@ dependencies = [
|
||||
name = "openconnect"
|
||||
version = "2.4.7"
|
||||
dependencies = [
|
||||
"autotools",
|
||||
"cc",
|
||||
"fs_extra",
|
||||
"is_executable",
|
||||
"log",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -6,7 +6,7 @@ INCLUDE_GUI ?= 0
|
||||
CARGO ?= cargo
|
||||
DISABLE_RUST_TOOLCHAIN ?= 0
|
||||
|
||||
VERSION = $(shell $(CARGO) metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
|
||||
VERSION = $(shell grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')
|
||||
REVISION ?= 1
|
||||
RPM_SOURCE ?= %{name}.tar.gz
|
||||
|
||||
|
||||
@@ -205,10 +205,11 @@ This project includes a devcontainer configuration that provides a consistent bu
|
||||
|
||||
#### Build Steps
|
||||
|
||||
1. Clone the repository:
|
||||
1. Clone the repository and submodules:
|
||||
```bash
|
||||
git clone https://github.com/yuezk/GlobalProtect-openconnect.git
|
||||
cd GlobalProtect-openconnect
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
2. Build the devcontainer image:
|
||||
@@ -216,12 +217,8 @@ This project includes a devcontainer configuration that provides a consistent bu
|
||||
docker build -t gpoc-devcontainer .devcontainer/
|
||||
```
|
||||
|
||||
3. Install `jq` in the container and build the project:
|
||||
3. Build the project:
|
||||
```bash
|
||||
docker run --privileged --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||
-v "$(pwd)":/workspace -w /workspace --user root gpoc-devcontainer \
|
||||
bash -c "apt-get update && apt-get install -y jq"
|
||||
|
||||
docker run --privileged --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||
-v "$(pwd)":/workspace -w /workspace gpoc-devcontainer \
|
||||
bash -c "export PATH=/usr/local/cargo/bin:\$PATH && make build"
|
||||
@@ -248,7 +245,7 @@ This project includes a devcontainer configuration that provides a consistent bu
|
||||
|
||||
- [Install Rust 1.85 or later](https://www.rust-lang.org/tools/install)
|
||||
- Install Tauri dependencies: https://tauri.app/start/prerequisites/
|
||||
- Install `perl` and `jq`
|
||||
- Install `perl`
|
||||
- Install `openconnect >= 8.20` and `libopenconnect-dev` (or `openconnect-devel` on RPM-based distributions)
|
||||
- Install `pkexec`, `gnome-keyring` (or `pam_kwallet` on KDE)
|
||||
- Install `nodejs` and `pnpm` (optional only if you downloaded the source tarball from the release page and run with the `BUILD_FE=0` flag, see below)
|
||||
|
||||
@@ -95,6 +95,9 @@ pub(crate) struct ConnectArgs {
|
||||
#[arg(long, help = "If not specified, it will be computed based on the --os option")]
|
||||
os_version: Option<String>,
|
||||
|
||||
#[arg(long, help = "The GP client version to emulate, e.g., '6.2.4-49'")]
|
||||
client_version: Option<String>,
|
||||
|
||||
#[arg(long, help = "Disable DTLS and ESP")]
|
||||
no_dtls: bool,
|
||||
|
||||
@@ -276,7 +279,11 @@ impl<'a> ConnectHandler<'a> {
|
||||
}
|
||||
};
|
||||
|
||||
self.connect_gateway(gateway, &cookie).await
|
||||
// Use the client version from the command line argument if specified, otherwise
|
||||
// use the version from the portal config if available
|
||||
let client_version = self.args.client_version.as_deref().or_else(|| portal_config.version());
|
||||
|
||||
self.connect_gateway(gateway, &cookie, client_version).await
|
||||
}
|
||||
|
||||
async fn connect_gateway_with_prelogin(&self, gateway: &str) -> anyhow::Result<()> {
|
||||
@@ -290,7 +297,10 @@ impl<'a> ConnectHandler<'a> {
|
||||
|
||||
let cookie = self.login_gateway(gateway, &cred, &gp_params).await?;
|
||||
|
||||
self.connect_gateway(gateway, &cookie).await
|
||||
// When logging in to a gateway directly, there is no portal config to get the client version from
|
||||
let client_version = self.args.client_version.as_deref();
|
||||
|
||||
self.connect_gateway(gateway, &cookie, client_version).await
|
||||
}
|
||||
|
||||
async fn login_gateway(&self, gateway: &str, cred: &Credential, gp_params: &GpParams) -> anyhow::Result<String> {
|
||||
@@ -310,7 +320,7 @@ impl<'a> ConnectHandler<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
async fn connect_gateway(&self, gateway: &str, cookie: &str) -> anyhow::Result<()> {
|
||||
async fn connect_gateway(&self, gateway: &str, cookie: &str, client_version: Option<&str>) -> anyhow::Result<()> {
|
||||
let mtu = self.args.mtu.unwrap_or(0);
|
||||
let csd_uid = get_csd_uid(&self.args.csd_user)?;
|
||||
let (hip, csd_wrapper) = if let Some(csd_wrapper) = &self.args.csd_wrapper {
|
||||
@@ -322,12 +332,14 @@ impl<'a> ConnectHandler<'a> {
|
||||
};
|
||||
|
||||
let os = ClientOs::from(&self.args.os).to_openconnect_os().to_string();
|
||||
let client_version = client_version.map(|s| s.to_owned());
|
||||
let vpn = Vpn::builder(gateway, cookie)
|
||||
.script(self.args.script.clone())
|
||||
.interface(self.args.interface.clone())
|
||||
.script_tun(self.args.script_tun)
|
||||
.user_agent(self.args.user_agent.clone())
|
||||
.os(Some(os))
|
||||
.client_version(client_version)
|
||||
.certificate(self.args.certificate.clone())
|
||||
.sslkey(self.args.sslkey.clone())
|
||||
.key_password(self.latest_key_password.borrow().clone())
|
||||
|
||||
@@ -42,6 +42,7 @@ impl VpnTaskContext {
|
||||
.script(args.vpnc_script())
|
||||
.user_agent(args.user_agent())
|
||||
.os(args.openconnect_os())
|
||||
.client_version(args.client_version())
|
||||
.certificate(args.certificate())
|
||||
.sslkey(args.sslkey())
|
||||
.key_password(args.key_password())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use anyhow::bail;
|
||||
use dns_lookup::lookup_addr;
|
||||
use log::{info, warn};
|
||||
use log::{debug, info, warn};
|
||||
use reqwest::{Client, StatusCode};
|
||||
use roxmltree::{Document, Node};
|
||||
use serde::Serialize;
|
||||
@@ -9,7 +9,7 @@ use specta::Type;
|
||||
use crate::{
|
||||
credential::{AuthCookieCredential, Credential},
|
||||
error::PortalError,
|
||||
gateway::{parse_gateways, Gateway},
|
||||
gateway::{Gateway, parse_gateways},
|
||||
gp_params::GpParams,
|
||||
utils::{normalize_server, parse_gp_response, remove_url_scheme, xml::NodeExt},
|
||||
};
|
||||
@@ -29,6 +29,10 @@ pub struct PortalConfig {
|
||||
* - Some(true): Internal host detection is supported and the user is connected to the internal network
|
||||
*/
|
||||
internal_host_detection: Option<bool>,
|
||||
/**
|
||||
* The version returned by the portal config, if any
|
||||
*/
|
||||
version: Option<String>,
|
||||
}
|
||||
|
||||
impl PortalConfig {
|
||||
@@ -52,6 +56,10 @@ impl PortalConfig {
|
||||
self.internal_host_detection
|
||||
}
|
||||
|
||||
pub fn version(&self) -> Option<&str> {
|
||||
self.version.as_deref()
|
||||
}
|
||||
|
||||
/// In-place sort the gateways by region
|
||||
pub fn sort_gateways(&mut self, region: &str) {
|
||||
let preferred_gateway = self.find_preferred_gateway(region);
|
||||
@@ -133,6 +141,7 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara
|
||||
bail!(PortalError::ConfigError("Empty portal config response".to_string()))
|
||||
}
|
||||
|
||||
debug!("Portal config response: {}", res_xml);
|
||||
let doc = Document::parse(&res_xml).map_err(|e| PortalError::ConfigError(e.to_string()))?;
|
||||
let root = doc.root();
|
||||
|
||||
@@ -158,6 +167,9 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara
|
||||
gateways.push(Gateway::new(server.to_string(), server.to_string()));
|
||||
}
|
||||
|
||||
let version = root.descendant_text("version").map(|s| s.to_string());
|
||||
info!("Detected portal version: {:?}", version);
|
||||
|
||||
Ok(PortalConfig {
|
||||
portal: server.to_string(),
|
||||
auth_cookie: AuthCookieCredential::new(cred.username(), user_auth_cookie, prelogon_user_auth_cookie),
|
||||
@@ -165,6 +177,7 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara
|
||||
gateways,
|
||||
config_digest: config_digest.map(|s| s.to_string()),
|
||||
internal_host_detection: if ihd_enabled { Some(prefer_internal) } else { None },
|
||||
version,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -31,14 +31,19 @@ impl LaunchGuiRequest {
|
||||
pub struct ConnectArgs {
|
||||
cookie: String,
|
||||
vpnc_script: Option<String>,
|
||||
|
||||
user_agent: Option<String>,
|
||||
os: Option<ClientOs>,
|
||||
client_version: Option<String>,
|
||||
|
||||
certificate: Option<String>,
|
||||
sslkey: Option<String>,
|
||||
key_password: Option<String>,
|
||||
|
||||
hip: bool,
|
||||
csd_uid: u32,
|
||||
csd_wrapper: Option<String>,
|
||||
|
||||
reconnect_timeout: u32,
|
||||
mtu: u32,
|
||||
disable_ipv6: bool,
|
||||
@@ -52,6 +57,7 @@ impl ConnectArgs {
|
||||
vpnc_script: None,
|
||||
user_agent: None,
|
||||
os: None,
|
||||
client_version: None,
|
||||
certificate: None,
|
||||
sslkey: None,
|
||||
key_password: None,
|
||||
@@ -81,6 +87,10 @@ impl ConnectArgs {
|
||||
self.os.as_ref().map(|os| os.to_openconnect_os().to_string())
|
||||
}
|
||||
|
||||
pub fn client_version(&self) -> Option<String> {
|
||||
self.client_version.clone()
|
||||
}
|
||||
|
||||
pub fn certificate(&self) -> Option<String> {
|
||||
self.certificate.clone()
|
||||
}
|
||||
@@ -166,6 +176,11 @@ impl ConnectRequest {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_client_version(mut self, client_version: &str) -> Self {
|
||||
self.args.client_version = Some(client_version.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_certificate<T: Into<Option<String>>>(mut self, certificate: T) -> Self {
|
||||
self.args.certificate = certificate.into();
|
||||
self
|
||||
|
||||
@@ -11,3 +11,6 @@ is_executable.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1"
|
||||
autotools = "0.2"
|
||||
pkg-config = "0.3"
|
||||
fs_extra = "1"
|
||||
@@ -1,14 +1,91 @@
|
||||
use std::{env, path::PathBuf, process::Command};
|
||||
|
||||
fn main() {
|
||||
// Link to the native openconnect library
|
||||
println!("cargo:rustc-link-lib=openconnect");
|
||||
println!("cargo:rustc-link-search=/opt/homebrew/lib"); // Homebrew path
|
||||
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
let deps_dir = PathBuf::from(&manifest_dir).join("../../deps");
|
||||
let openconnect_dir = deps_dir.join("openconnect");
|
||||
let gp_version_patch = deps_dir.join("patches/openconnect-gp-version.patch");
|
||||
|
||||
// The temporary location where we will build
|
||||
let build_src = out_dir.join("openconnect_build");
|
||||
|
||||
// Track changes so cargo rebuilds if patch or submodule changes
|
||||
println!("cargo:rerun-if-changed={}", openconnect_dir.display());
|
||||
println!("cargo:rerun-if-changed={}", gp_version_patch.display());
|
||||
|
||||
// Prepare the build directory
|
||||
// If the directory exists from a previous run, remove it to ensure a clean slate
|
||||
if build_src.exists() {
|
||||
std::fs::remove_dir_all(&build_src).unwrap();
|
||||
}
|
||||
std::fs::create_dir_all(&build_src).unwrap();
|
||||
|
||||
// Copy the source code to OUT_DIR
|
||||
// We use fs_extra options to copy contents recursively
|
||||
let mut options = fs_extra::dir::CopyOptions::new();
|
||||
options.overwrite = true;
|
||||
options.content_only = true; // Copy content of src into dest, not src folder itself
|
||||
|
||||
fs_extra::dir::copy(&openconnect_dir, &build_src, &options).expect("Failed to copy C source code to OUT_DIR");
|
||||
|
||||
// Apply the Patch
|
||||
// We use the system `patch` command.
|
||||
let status = Command::new("patch")
|
||||
.arg("-p1") // Strip one level of path (standard for git diffs)
|
||||
.arg("-i") // Input file
|
||||
.arg(&gp_version_patch)
|
||||
.current_dir(&build_src) // Run INSIDE the copied dir
|
||||
.status()
|
||||
.expect("Failed to execute patch command");
|
||||
|
||||
if !status.success() {
|
||||
panic!("Failed to apply patch file: {}", gp_version_patch.display());
|
||||
}
|
||||
|
||||
// Build the OpenConnect library using autotools
|
||||
// We explicitly enable static and disable shared to ensure we get a .a file.
|
||||
// .reconf("-ivf") is CRITICAL for git submodules because 'configure'
|
||||
// usually doesn't exist yet and needs to be generated.
|
||||
let dst = autotools::Config::new(&build_src)
|
||||
.reconf("-ivf")
|
||||
.enable_static()
|
||||
.disable_shared()
|
||||
.disable("nls", None) // disable translations to save space
|
||||
.disable("docs", None)
|
||||
.disable("dsa-tests", None)
|
||||
.without("libproxy", None)
|
||||
.without("stoken", None)
|
||||
.without("libpcsclite", None)
|
||||
.without("libpskc", None)
|
||||
.without("gssapi", None)
|
||||
.with("gnutls-tss2", Some("no"))
|
||||
.with("vpnc-script", Some("/etc/vpnc/vpnc-script")) // Specify vpnc-script, otherwise it will fail on macOS
|
||||
.build();
|
||||
|
||||
// Link the 'openconnect' static library
|
||||
println!("cargo:rustc-link-search=native={}/lib", dst.display());
|
||||
println!("cargo:rustc-link-lib=static=openconnect");
|
||||
|
||||
// Using pkg-config to find system deps
|
||||
pkg_config::probe_library("libxml-2.0").unwrap();
|
||||
pkg_config::probe_library("zlib").unwrap();
|
||||
pkg_config::probe_library("liblz4").unwrap();
|
||||
pkg_config::probe_library("gnutls").unwrap();
|
||||
|
||||
// Below are required by gnutls
|
||||
pkg_config::probe_library("p11-kit-1").unwrap();
|
||||
pkg_config::probe_library("hogweed").unwrap();
|
||||
pkg_config::probe_library("nettle").unwrap();
|
||||
pkg_config::probe_library("gmp").unwrap();
|
||||
|
||||
// Compile the vpn.c file
|
||||
println!("cargo:rerun-if-changed=src/ffi/vpn.c");
|
||||
println!("cargo:rerun-if-changed=src/ffi/vpn.h");
|
||||
|
||||
// Compile the vpn.c file
|
||||
cc::Build::new()
|
||||
.file("src/ffi/vpn.c")
|
||||
.include("src/ffi")
|
||||
.include("/opt/homebrew/include") // Homebrew path
|
||||
.include(&dst.join("include"))
|
||||
.compile("vpn");
|
||||
}
|
||||
@@ -2,6 +2,7 @@ use crate::Vpn;
|
||||
use log::{debug, info, trace, warn};
|
||||
use std::ffi::{c_char, c_int, c_void};
|
||||
|
||||
/// ConnectOptions struct for FFI, the field names and order must match the C definition.
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct ConnectOptions {
|
||||
@@ -9,12 +10,15 @@ pub(crate) struct ConnectOptions {
|
||||
|
||||
pub server: *const c_char,
|
||||
pub cookie: *const c_char,
|
||||
|
||||
pub user_agent: *const c_char,
|
||||
pub os: *const c_char,
|
||||
pub client_version: *const c_char,
|
||||
|
||||
pub script: *const c_char,
|
||||
pub interface: *const c_char,
|
||||
pub script_tun: u32,
|
||||
pub os: *const c_char,
|
||||
|
||||
pub certificate: *const c_char,
|
||||
pub sslkey: *const c_char,
|
||||
pub key_password: *const c_char,
|
||||
|
||||
@@ -58,7 +58,6 @@ static void setup_tun_handler(void *_vpninfo)
|
||||
/* Initialize VPN connection */
|
||||
int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
{
|
||||
INFO("openconnect version: %s", openconnect_get_version());
|
||||
struct openconnect_info *vpninfo;
|
||||
struct utsname utsbuf;
|
||||
|
||||
@@ -70,6 +69,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
|
||||
INFO("USER_AGENT: %s", options->user_agent);
|
||||
INFO("OS: %s", options->os);
|
||||
INFO("CLIENT_VERSION: %s", options->client_version);
|
||||
INFO("VPNC_SCRIPT: %s", options->script);
|
||||
INFO("SCRIPT_TUN: %d", g_script_tun);
|
||||
INFO("CSD_USER: %d", options->csd_uid);
|
||||
@@ -99,6 +99,11 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
openconnect_set_reported_os(vpninfo, options->os);
|
||||
}
|
||||
|
||||
if (options->client_version) {
|
||||
openconnect_set_gp_app_version(vpninfo,
|
||||
options->client_version);
|
||||
}
|
||||
|
||||
if (options->certificate) {
|
||||
INFO("Setting client certificate: %s", options->certificate);
|
||||
openconnect_set_client_cert(vpninfo, options->certificate,
|
||||
|
||||
@@ -7,14 +7,18 @@ typedef void (*vpn_connected_callback)(int cmd_pipe_fd, void *user_data);
|
||||
|
||||
typedef struct vpn_options {
|
||||
void *user_data;
|
||||
|
||||
const char *server;
|
||||
const char *cookie;
|
||||
|
||||
const char *user_agent;
|
||||
const char *os;
|
||||
const char *client_version;
|
||||
|
||||
const char *script;
|
||||
const char *interface;
|
||||
const int script_tun;
|
||||
const char *os;
|
||||
|
||||
const char *certificate;
|
||||
const char *sslkey;
|
||||
const char *key_password;
|
||||
|
||||
@@ -14,11 +14,15 @@ type OnConnectedCallback = Arc<RwLock<Option<Box<dyn FnOnce() + 'static + Send +
|
||||
pub struct Vpn {
|
||||
server: CString,
|
||||
cookie: CString,
|
||||
|
||||
user_agent: CString,
|
||||
os: CString,
|
||||
client_version: Option<CString>,
|
||||
|
||||
script: CString,
|
||||
interface: Option<CString>,
|
||||
script_tun: bool,
|
||||
os: CString,
|
||||
|
||||
certificate: Option<CString>,
|
||||
sslkey: Option<CString>,
|
||||
key_password: Option<CString>,
|
||||
@@ -67,11 +71,14 @@ impl Vpn {
|
||||
|
||||
server: self.server.as_ptr(),
|
||||
cookie: self.cookie.as_ptr(),
|
||||
|
||||
user_agent: self.user_agent.as_ptr(),
|
||||
os: self.os.as_ptr(),
|
||||
client_version: Self::option_to_ptr(&self.client_version),
|
||||
|
||||
script: self.script.as_ptr(),
|
||||
interface: Self::option_to_ptr(&self.interface),
|
||||
script_tun: self.script_tun as u32,
|
||||
os: self.os.as_ptr(),
|
||||
|
||||
certificate: Self::option_to_ptr(&self.certificate),
|
||||
sslkey: Self::option_to_ptr(&self.sslkey),
|
||||
@@ -125,6 +132,7 @@ pub struct VpnBuilder {
|
||||
|
||||
user_agent: Option<String>,
|
||||
os: Option<String>,
|
||||
client_version: Option<String>,
|
||||
|
||||
certificate: Option<String>,
|
||||
sslkey: Option<String>,
|
||||
@@ -153,6 +161,7 @@ impl VpnBuilder {
|
||||
|
||||
user_agent: None,
|
||||
os: None,
|
||||
client_version: None,
|
||||
|
||||
certificate: None,
|
||||
sslkey: None,
|
||||
@@ -195,6 +204,11 @@ impl VpnBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn client_version<T: Into<Option<String>>>(mut self, client_version: T) -> Self {
|
||||
self.client_version = client_version.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn certificate<T: Into<Option<String>>>(mut self, certificate: T) -> Self {
|
||||
self.certificate = certificate.into();
|
||||
self
|
||||
@@ -287,11 +301,14 @@ impl VpnBuilder {
|
||||
Ok(Vpn {
|
||||
server: Self::to_cstring(&self.server),
|
||||
cookie: Self::to_cstring(&self.cookie),
|
||||
|
||||
user_agent: Self::to_cstring(&user_agent),
|
||||
os: Self::to_cstring(&os),
|
||||
client_version: self.client_version.as_deref().map(Self::to_cstring),
|
||||
|
||||
script: Self::to_cstring(&script),
|
||||
interface: self.interface.as_deref().map(Self::to_cstring),
|
||||
script_tun: self.script_tun,
|
||||
os: Self::to_cstring(&os),
|
||||
|
||||
certificate: self.certificate.as_deref().map(Self::to_cstring),
|
||||
sslkey: self.sslkey.as_deref().map(Self::to_cstring),
|
||||
|
||||
+1
Submodule deps/openconnect added at 0dcdff87db.
+71
@@ -0,0 +1,71 @@
|
||||
diff --git a/gpst.c b/gpst.c
|
||||
index 244aaf04..205bec1d 100644
|
||||
--- a/gpst.c
|
||||
+++ b/gpst.c
|
||||
@@ -650,8 +650,11 @@ static int gpst_get_config(struct openconnect_info *vpninfo)
|
||||
|
||||
|
||||
/* submit getconfig request */
|
||||
+ char *app_version = vpninfo->csd_ticket ? : (vpninfo->gp_app_version ? : "6.3.0-33");
|
||||
+ vpn_progress(vpninfo, PRG_DEBUG, _("Using GlobalProtect app version: %s\n"), app_version);
|
||||
+
|
||||
buf_append(request_body, "client-type=1&protocol-version=p1&internal=no");
|
||||
- append_opt(request_body, "app-version", vpninfo->csd_ticket ? : "6.3.0-33");
|
||||
+ append_opt(request_body, "app-version", app_version);
|
||||
append_opt(request_body, "ipv6-support", vpninfo->disable_ipv6 ? "no" : "yes");
|
||||
append_opt(request_body, "clientos", gpst_os_name(vpninfo));
|
||||
append_opt(request_body, "os-version", vpninfo->platname);
|
||||
diff --git a/library.c b/library.c
|
||||
index b5e74e9b..fff28f77 100644
|
||||
--- a/library.c
|
||||
+++ b/library.c
|
||||
@@ -896,6 +896,7 @@ void openconnect_vpninfo_free(struct openconnect_info *vpninfo)
|
||||
|
||||
free(vpninfo->localname);
|
||||
free(vpninfo->useragent);
|
||||
+ free(vpninfo->gp_app_version);
|
||||
free(vpninfo->authgroup);
|
||||
#ifdef HAVE_LIBSTOKEN
|
||||
if (vpninfo->stoken_pin)
|
||||
@@ -1019,6 +1020,15 @@ int openconnect_set_useragent(struct openconnect_info *vpninfo,
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int openconnect_set_gp_app_version(struct openconnect_info *vpninfo,
|
||||
+ const char *gp_app_version)
|
||||
+{
|
||||
+ UTF8CHECK(gp_app_version);
|
||||
+
|
||||
+ STRDUP(vpninfo->gp_app_version, gp_app_version);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
int openconnect_set_urlpath(struct openconnect_info *vpninfo,
|
||||
const char *urlpath)
|
||||
{
|
||||
diff --git a/openconnect-internal.h b/openconnect-internal.h
|
||||
index abf45bbd..85933f4a 100644
|
||||
--- a/openconnect-internal.h
|
||||
+++ b/openconnect-internal.h
|
||||
@@ -786,6 +786,7 @@ struct openconnect_info {
|
||||
int is_dyndns; /* Attempt to redo DNS lookup on each CSTP reconnect */
|
||||
char *useragent;
|
||||
char *version_string;
|
||||
+ char *gp_app_version;
|
||||
|
||||
const char *quit_reason;
|
||||
const char *delay_tunnel_reason; /* If non-null, provides a reason why protocol is not yet ready for tunnel setup */
|
||||
diff --git a/openconnect.h b/openconnect.h
|
||||
index 136f181a..67fc1283 100644
|
||||
--- a/openconnect.h
|
||||
+++ b/openconnect.h
|
||||
@@ -470,6 +470,9 @@ int openconnect_set_http_proxy(struct openconnect_info *vpninfo,
|
||||
int openconnect_set_useragent(struct openconnect_info *vpninfo,
|
||||
const char *useragent);
|
||||
|
||||
+int openconnect_set_gp_app_version(struct openconnect_info *vpninfo,
|
||||
+ const char *gp_app_version);
|
||||
+
|
||||
int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo);
|
||||
int openconnect_obtain_cookie(struct openconnect_info *vpninfo);
|
||||
int openconnect_init_ssl(void);
|
||||
@@ -5,7 +5,6 @@ Maintainer: Kevin Yue <[email protected]>
|
||||
Standards-Version: 4.1.4
|
||||
Build-Depends: debhelper (>= 9),
|
||||
pkg-config,
|
||||
jq (>= 1),
|
||||
make (>= 4),
|
||||
libssl-dev,
|
||||
libsecret-1-0,
|
||||
|
||||
@@ -8,8 +8,10 @@ pkgdesc="A GUI for GlobalProtect VPN, based on OpenConnect, supports the SSO aut
|
||||
arch=('x86_64' 'aarch64')
|
||||
url="https://github.com/yuezk/GlobalProtect-openconnect"
|
||||
license=('GPL3')
|
||||
makedepends=('make' 'pkg-config' 'rust' 'cargo' 'jq' 'webkit2gtk-4.1' 'curl' 'wget' 'file' 'openssl' 'appmenu-gtk-module' 'libappindicator-gtk3' 'librsvg' 'openconnect' 'libsecret')
|
||||
depends=('openconnect>=8.20' webkit2gtk-4.1 libappindicator-gtk3 libsecret)
|
||||
makedepends=('make' 'pkg-config' 'rust' 'cargo' 'file')
|
||||
depends=('webkit2gtk-4.1' 'libappindicator-gtk3' 'librsvg' 'libsecret' 'openssl' 'appmenu-gtk-module'
|
||||
'gnutls' 'libxml2' 'vpnc' 'lz4' 'libp11-kit' 'nettle' 'xdg-utils'
|
||||
'openconnect>=8.20')
|
||||
optdepends=('wmctrl: for window management')
|
||||
|
||||
provides=('globalprotect-openconnect' 'gpclient' 'gpservice' 'gpauth' 'gpgui')
|
||||
|
||||
@@ -11,7 +11,6 @@ Source: @SOURCE@
|
||||
BuildRequires: make
|
||||
BuildRequires: rust
|
||||
BuildRequires: cargo
|
||||
BuildRequires: jq
|
||||
BuildRequires: pkg-config
|
||||
BuildRequires: openconnect-devel
|
||||
BuildRequires: (openssl-devel or libopenssl-devel)
|
||||
|
||||
Reference in new issue
Block a user