feat: add support for client version emulation and integrate OpenConnect submodule

This commit is contained in:
Kevin Yue committed 2025-12-08 21:46:02 +08:00
1 parent a08ae655cf
commit e4701c1bd8
21 files changed
+273 -29

No files matched your search

+5 -1
View File
@@ -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,
+6 -1
View File
@@ -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,
+5 -1
View File
@@ -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;