mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2aa875a626 | ||
|
|
e4fa429dcc | ||
|
|
5ba7bf2e18 | ||
|
|
11925a372d | ||
|
|
e1eb9e20f1 | ||
|
|
1d3aa889d5 | ||
|
|
c1ab26aef3 | ||
|
|
ea9819d161 |
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 8
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Always
|
||||||
|
ColumnLimit: 80
|
||||||
|
BreakBeforeBraces: Linux
|
||||||
@@ -8,5 +8,9 @@ end_of_line = lf
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[{*.c,*.h}]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 8
|
||||||
|
|
||||||
[{Makefile,Makefile.in}]
|
[{Makefile,Makefile.in}]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
# Set the matrix to include arm64 if the ref is a tag or is the dev branch
|
# Set the matrix to include arm64 if the ref is a tag or is the dev branch
|
||||||
if [[ "${{ github.ref }}" == "refs/tags/"* || "${{ github.ref }}" == "refs/heads/dev" ]]; then
|
if [[ "${{ github.ref }}" == "refs/tags/"* || "${{ github.ref }}" == "refs/heads/dev" ]]; then
|
||||||
echo 'matrix=[{"runner": "ubuntu-latest", "arch": "amd64"}, {"runner": "arm64", "arch": "arm64"}]' >> $GITHUB_OUTPUT
|
echo 'matrix=[{"runner": "ubuntu-latest", "arch": "amd64"}, {"runner": "ubuntu-24.04-arm", "arch": "ubuntu-24.04-arm"}]' >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo 'matrix=[{"runner": "ubuntu-latest", "arch": "amd64"}]' >> $GITHUB_OUTPUT
|
echo 'matrix=[{"runner": "ubuntu-latest", "arch": "amd64"}]' >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ jobs:
|
|||||||
const inputs = ${{ toJson(inputs) }}
|
const inputs = ${{ toJson(inputs) }}
|
||||||
const { arch } = inputs
|
const { arch } = inputs
|
||||||
const osMap = {
|
const osMap = {
|
||||||
"all": ["ubuntu-latest", "arm64"],
|
"all": ["ubuntu-latest", "ubuntu-24.04-arm"],
|
||||||
"x86_64": ["ubuntu-latest"],
|
"x86_64": ["ubuntu-latest"],
|
||||||
"arm64": ["arm64"]
|
"arm64": ["ubuntu-24.04-arm"]
|
||||||
}
|
}
|
||||||
|
|
||||||
const package = Object.entries(inputs)
|
const package = Object.entries(inputs)
|
||||||
|
|||||||
Generated
+8
-8
@@ -176,7 +176,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auth"
|
name = "auth"
|
||||||
version = "2.4.4"
|
version = "2.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"block2",
|
"block2",
|
||||||
@@ -642,7 +642,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "2.4.4"
|
version = "2.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"is_executable",
|
"is_executable",
|
||||||
]
|
]
|
||||||
@@ -1625,7 +1625,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpapi"
|
name = "gpapi"
|
||||||
version = "2.4.4"
|
version = "2.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
@@ -1662,7 +1662,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpauth"
|
name = "gpauth"
|
||||||
version = "2.4.4"
|
version = "2.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"auth",
|
"auth",
|
||||||
@@ -1681,7 +1681,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpclient"
|
name = "gpclient"
|
||||||
version = "2.4.4"
|
version = "2.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -1703,7 +1703,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpgui-helper"
|
name = "gpgui-helper"
|
||||||
version = "2.4.4"
|
version = "2.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -1721,7 +1721,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpservice"
|
name = "gpservice"
|
||||||
version = "2.4.4"
|
version = "2.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -2987,7 +2987,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openconnect"
|
name = "openconnect"
|
||||||
version = "2.4.4"
|
version = "2.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"common",
|
"common",
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ members = [
|
|||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
rust-version = "1.80"
|
rust-version = "1.80"
|
||||||
version = "2.4.4"
|
version = "2.4.5"
|
||||||
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 = "2021"
|
edition = "2021"
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ It is available via `guru` and `lamdness` overlays.
|
|||||||
```bash
|
```bash
|
||||||
sudo eselect repository enable guru
|
sudo eselect repository enable guru
|
||||||
sudo emerge -r guru sync
|
sudo emerge -r guru sync
|
||||||
sudo emerge -av net-vpn/globalprotect-openconnect
|
sudo emerge -av net-vpn/GlobalProtect-openconnect
|
||||||
```
|
```
|
||||||
|
|
||||||
### Other distributions
|
### Other distributions
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ pub(crate) struct ConnectArgs {
|
|||||||
#[arg(long, short, help = "The VPNC script to use")]
|
#[arg(long, short, help = "The VPNC script to use")]
|
||||||
script: Option<String>,
|
script: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, short, help = "The IFNAME for tunnel interface")]
|
||||||
|
interface: Option<String>,
|
||||||
|
|
||||||
#[arg(long, help = "Connect the server as a gateway, instead of a portal")]
|
#[arg(long, help = "Connect the server as a gateway, instead of a portal")]
|
||||||
as_gateway: bool,
|
as_gateway: bool,
|
||||||
|
|
||||||
@@ -93,6 +96,9 @@ pub(crate) struct ConnectArgs {
|
|||||||
#[arg(long, help = "Disable DTLS and ESP")]
|
#[arg(long, help = "Disable DTLS and ESP")]
|
||||||
no_dtls: bool,
|
no_dtls: bool,
|
||||||
|
|
||||||
|
#[arg(long = "force-dpd", help = "Same as the '--force-dpd' option in the openconnect command")]
|
||||||
|
dpd_interval: Option<u32>,
|
||||||
|
|
||||||
#[cfg(feature = "webview-auth")]
|
#[cfg(feature = "webview-auth")]
|
||||||
#[arg(long, help = "The HiDPI mode, useful for high-resolution screens")]
|
#[arg(long, help = "The HiDPI mode, useful for high-resolution screens")]
|
||||||
hidpi: bool,
|
hidpi: bool,
|
||||||
@@ -313,6 +319,7 @@ impl<'a> ConnectHandler<'a> {
|
|||||||
let os = ClientOs::from(&self.args.os).to_openconnect_os().to_string();
|
let os = ClientOs::from(&self.args.os).to_openconnect_os().to_string();
|
||||||
let vpn = Vpn::builder(gateway, cookie)
|
let vpn = Vpn::builder(gateway, cookie)
|
||||||
.script(self.args.script.clone())
|
.script(self.args.script.clone())
|
||||||
|
.interface(self.args.interface.clone())
|
||||||
.user_agent(self.args.user_agent.clone())
|
.user_agent(self.args.user_agent.clone())
|
||||||
.os(Some(os))
|
.os(Some(os))
|
||||||
.certificate(self.args.certificate.clone())
|
.certificate(self.args.certificate.clone())
|
||||||
@@ -324,6 +331,7 @@ impl<'a> ConnectHandler<'a> {
|
|||||||
.mtu(mtu)
|
.mtu(mtu)
|
||||||
.disable_ipv6(self.args.disable_ipv6)
|
.disable_ipv6(self.args.disable_ipv6)
|
||||||
.no_dtls(self.args.no_dtls)
|
.no_dtls(self.args.no_dtls)
|
||||||
|
.dpd_interval(self.args.dpd_interval.unwrap_or(0))
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let vpn = Arc::new(vpn);
|
let vpn = Arc::new(vpn);
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2.4.5 - 2025-07-16
|
||||||
|
|
||||||
|
- GUI/CLI: fix the issue that the custom port is not supported issue (fix [#404](https://github.com/yuezk/GlobalProtect-openconnect/issues/404))
|
||||||
|
- CLI: add the `--force-dpd` option to specify the interval for DPD (Dead Peer Detection).
|
||||||
|
- CLI: add the `-i/--interface` option to specify the interface to use.
|
||||||
|
|
||||||
## 2.4.4 - 2025-02-09
|
## 2.4.4 - 2025-02-09
|
||||||
|
|
||||||
- GUI: fix multiple tray icons issue (fix [#464](https://github.com/yuezk/GlobalProtect-openconnect/issues/464))
|
- GUI: fix multiple tray icons issue (fix [#464](https://github.com/yuezk/GlobalProtect-openconnect/issues/464))
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ pub(crate) struct ConnectOptions {
|
|||||||
pub user_agent: *const c_char,
|
pub user_agent: *const c_char,
|
||||||
|
|
||||||
pub script: *const c_char,
|
pub script: *const c_char,
|
||||||
|
pub interface: *const c_char,
|
||||||
pub os: *const c_char,
|
pub os: *const c_char,
|
||||||
pub certificate: *const c_char,
|
pub certificate: *const c_char,
|
||||||
pub sslkey: *const c_char,
|
pub sslkey: *const c_char,
|
||||||
@@ -25,6 +26,8 @@ pub(crate) struct ConnectOptions {
|
|||||||
pub mtu: u32,
|
pub mtu: u32,
|
||||||
pub disable_ipv6: u32,
|
pub disable_ipv6: u32,
|
||||||
pub no_dtls: u32,
|
pub no_dtls: u32,
|
||||||
|
|
||||||
|
pub dpd_interval: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[link(name = "vpn")]
|
#[link(name = "vpn")]
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
#include <openconnect.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <openconnect.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "vpn.h"
|
#include "vpn.h"
|
||||||
|
|
||||||
@@ -11,17 +11,20 @@ void *g_user_data;
|
|||||||
|
|
||||||
static int g_cmd_pipe_fd;
|
static int g_cmd_pipe_fd;
|
||||||
static const char *g_vpnc_script;
|
static const char *g_vpnc_script;
|
||||||
|
static const char *g_vpnc_interface;
|
||||||
static vpn_connected_callback on_vpn_connected;
|
static vpn_connected_callback on_vpn_connected;
|
||||||
|
|
||||||
/* Validate the peer certificate */
|
/* Validate the peer certificate */
|
||||||
static int validate_peer_cert(__attribute__((unused)) void *_vpninfo, const char *reason)
|
static int validate_peer_cert(__attribute__((unused)) void *_vpninfo,
|
||||||
|
const char *reason)
|
||||||
{
|
{
|
||||||
INFO("Accepting the server certificate though %s", reason);
|
INFO("Accepting the server certificate though %s", reason);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print progress messages */
|
/* Print progress messages */
|
||||||
static void print_progress(__attribute__((unused)) void *_vpninfo, int level, const char *format, ...)
|
static void print_progress(__attribute__((unused)) void *_vpninfo, int level,
|
||||||
|
const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
@@ -38,7 +41,8 @@ static void print_progress(__attribute__((unused)) void *_vpninfo, int level, co
|
|||||||
|
|
||||||
static void setup_tun_handler(void *_vpninfo)
|
static void setup_tun_handler(void *_vpninfo)
|
||||||
{
|
{
|
||||||
int ret = openconnect_setup_tun_device(_vpninfo, g_vpnc_script, NULL);
|
int ret = openconnect_setup_tun_device(_vpninfo, g_vpnc_script,
|
||||||
|
g_vpnc_interface);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
on_vpn_connected(g_cmd_pipe_fd, g_user_data);
|
on_vpn_connected(g_cmd_pipe_fd, g_user_data);
|
||||||
}
|
}
|
||||||
@@ -53,6 +57,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
|
|
||||||
g_user_data = options->user_data;
|
g_user_data = options->user_data;
|
||||||
g_vpnc_script = options->script;
|
g_vpnc_script = options->script;
|
||||||
|
g_vpnc_interface = options->interface;
|
||||||
on_vpn_connected = callback;
|
on_vpn_connected = callback;
|
||||||
|
|
||||||
INFO("User agent: %s", options->user_agent);
|
INFO("User agent: %s", options->user_agent);
|
||||||
@@ -64,8 +69,11 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
INFO("MTU: %d", options->mtu);
|
INFO("MTU: %d", options->mtu);
|
||||||
INFO("DISABLE_IPV6: %d", options->disable_ipv6);
|
INFO("DISABLE_IPV6: %d", options->disable_ipv6);
|
||||||
INFO("NO_DTLS: %d", options->no_dtls);
|
INFO("NO_DTLS: %d", options->no_dtls);
|
||||||
|
INFO("DPD_INTERVAL: %d", options->dpd_interval);
|
||||||
|
|
||||||
vpninfo = openconnect_vpninfo_new(options->user_agent, validate_peer_cert, NULL, NULL, print_progress, NULL);
|
vpninfo =
|
||||||
|
openconnect_vpninfo_new(options->user_agent, validate_peer_cert,
|
||||||
|
NULL, NULL, print_progress, NULL);
|
||||||
|
|
||||||
if (!vpninfo) {
|
if (!vpninfo) {
|
||||||
ERROR("openconnect_vpninfo_new failed");
|
ERROR("openconnect_vpninfo_new failed");
|
||||||
@@ -75,7 +83,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
openconnect_set_loglevel(vpninfo, PRG_TRACE);
|
openconnect_set_loglevel(vpninfo, PRG_TRACE);
|
||||||
openconnect_init_ssl();
|
openconnect_init_ssl();
|
||||||
openconnect_set_protocol(vpninfo, "gp");
|
openconnect_set_protocol(vpninfo, "gp");
|
||||||
openconnect_set_hostname(vpninfo, options->server);
|
openconnect_parse_url(vpninfo, options->server);
|
||||||
openconnect_set_cookie(vpninfo, options->cookie);
|
openconnect_set_cookie(vpninfo, options->cookie);
|
||||||
|
|
||||||
if (options->os) {
|
if (options->os) {
|
||||||
@@ -84,7 +92,8 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
|
|
||||||
if (options->certificate) {
|
if (options->certificate) {
|
||||||
INFO("Setting client certificate: %s", options->certificate);
|
INFO("Setting client certificate: %s", options->certificate);
|
||||||
openconnect_set_client_cert(vpninfo, options->certificate, options->sslkey);
|
openconnect_set_client_cert(vpninfo, options->certificate,
|
||||||
|
options->sslkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options->key_password) {
|
if (options->key_password) {
|
||||||
@@ -92,7 +101,8 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options->csd_wrapper) {
|
if (options->csd_wrapper) {
|
||||||
openconnect_setup_csd(vpninfo, options->csd_uid, 1, options->csd_wrapper);
|
openconnect_setup_csd(vpninfo, options->csd_uid, 1,
|
||||||
|
options->csd_wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options->mtu > 0) {
|
if (options->mtu > 0) {
|
||||||
@@ -104,6 +114,10 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
openconnect_disable_ipv6(vpninfo);
|
openconnect_disable_ipv6(vpninfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options->dpd_interval > 0) {
|
||||||
|
openconnect_set_dpd(vpninfo, options->dpd_interval);
|
||||||
|
}
|
||||||
|
|
||||||
g_cmd_pipe_fd = openconnect_setup_cmd_pipe(vpninfo);
|
g_cmd_pipe_fd = openconnect_setup_cmd_pipe(vpninfo);
|
||||||
if (g_cmd_pipe_fd < 0) {
|
if (g_cmd_pipe_fd < 0) {
|
||||||
ERROR("openconnect_setup_cmd_pipe failed");
|
ERROR("openconnect_setup_cmd_pipe failed");
|
||||||
@@ -128,7 +142,8 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
openconnect_set_setup_tun_handler(vpninfo, setup_tun_handler);
|
openconnect_set_setup_tun_handler(vpninfo, setup_tun_handler);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int ret = openconnect_mainloop(vpninfo, options->reconnect_timeout, 10);
|
int ret = openconnect_mainloop(vpninfo,
|
||||||
|
options->reconnect_timeout, 10);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
INFO("openconnect_mainloop returned %d, exiting", ret);
|
INFO("openconnect_mainloop returned %d, exiting", ret);
|
||||||
@@ -148,6 +163,7 @@ void vpn_disconnect()
|
|||||||
INFO("Stopping VPN connection: %d", g_cmd_pipe_fd);
|
INFO("Stopping VPN connection: %d", g_cmd_pipe_fd);
|
||||||
|
|
||||||
if (write(g_cmd_pipe_fd, &cmd, 1) < 0) {
|
if (write(g_cmd_pipe_fd, &cmd, 1) < 0) {
|
||||||
ERROR("Failed to write to command pipe, VPN connection may not be stopped");
|
ERROR("Failed to write to command pipe, VPN connection may not "
|
||||||
|
"be stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
|
#include <openconnect.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <openconnect.h>
|
|
||||||
|
|
||||||
typedef void (*vpn_connected_callback)(int cmd_pipe_fd, void *user_data);
|
typedef void (*vpn_connected_callback)(int cmd_pipe_fd, void *user_data);
|
||||||
|
|
||||||
typedef struct vpn_options
|
typedef struct vpn_options {
|
||||||
{
|
|
||||||
void *user_data;
|
void *user_data;
|
||||||
const char *server;
|
const char *server;
|
||||||
const char *cookie;
|
const char *cookie;
|
||||||
const char *user_agent;
|
const char *user_agent;
|
||||||
|
|
||||||
const char *script;
|
const char *script;
|
||||||
|
const char *interface;
|
||||||
const char *os;
|
const char *os;
|
||||||
const char *certificate;
|
const char *certificate;
|
||||||
const char *sslkey;
|
const char *sslkey;
|
||||||
@@ -26,6 +26,8 @@ typedef struct vpn_options
|
|||||||
const int mtu;
|
const int mtu;
|
||||||
const int disable_ipv6;
|
const int disable_ipv6;
|
||||||
const int no_dtls;
|
const int no_dtls;
|
||||||
|
|
||||||
|
const int dpd_interval;
|
||||||
} vpn_options;
|
} vpn_options;
|
||||||
|
|
||||||
int vpn_connect(const vpn_options *options, vpn_connected_callback callback);
|
int vpn_connect(const vpn_options *options, vpn_connected_callback callback);
|
||||||
@@ -41,8 +43,7 @@ static char *format_message(const char *format, va_list args)
|
|||||||
va_end(args_copy);
|
va_end(args_copy);
|
||||||
|
|
||||||
char *buffer = (char *)malloc(len + 1);
|
char *buffer = (char *)malloc(len + 1);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL) {
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,12 +61,9 @@ static void _log(int level, ...)
|
|||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (message == NULL)
|
if (message == NULL) {
|
||||||
{
|
|
||||||
vpn_log(PRG_ERR, "Failed to format log message");
|
vpn_log(PRG_ERR, "Failed to format log message");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
vpn_log(level, message);
|
vpn_log(level, message);
|
||||||
free(message);
|
free(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ pub struct Vpn {
|
|||||||
cookie: CString,
|
cookie: CString,
|
||||||
user_agent: CString,
|
user_agent: CString,
|
||||||
script: CString,
|
script: CString,
|
||||||
|
interface: Option<CString>,
|
||||||
os: CString,
|
os: CString,
|
||||||
certificate: Option<CString>,
|
certificate: Option<CString>,
|
||||||
sslkey: Option<CString>,
|
sslkey: Option<CString>,
|
||||||
@@ -30,6 +31,8 @@ pub struct Vpn {
|
|||||||
disable_ipv6: bool,
|
disable_ipv6: bool,
|
||||||
no_dtls: bool,
|
no_dtls: bool,
|
||||||
|
|
||||||
|
dpd_interval: u32,
|
||||||
|
|
||||||
callback: OnConnectedCallback,
|
callback: OnConnectedCallback,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +68,7 @@ impl Vpn {
|
|||||||
cookie: self.cookie.as_ptr(),
|
cookie: self.cookie.as_ptr(),
|
||||||
user_agent: self.user_agent.as_ptr(),
|
user_agent: self.user_agent.as_ptr(),
|
||||||
script: self.script.as_ptr(),
|
script: self.script.as_ptr(),
|
||||||
|
interface: Self::option_to_ptr(&self.interface),
|
||||||
os: self.os.as_ptr(),
|
os: self.os.as_ptr(),
|
||||||
|
|
||||||
certificate: Self::option_to_ptr(&self.certificate),
|
certificate: Self::option_to_ptr(&self.certificate),
|
||||||
@@ -79,6 +83,7 @@ impl Vpn {
|
|||||||
mtu: self.mtu,
|
mtu: self.mtu,
|
||||||
disable_ipv6: self.disable_ipv6 as u32,
|
disable_ipv6: self.disable_ipv6 as u32,
|
||||||
no_dtls: self.no_dtls as u32,
|
no_dtls: self.no_dtls as u32,
|
||||||
|
dpd_interval: self.dpd_interval,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +118,7 @@ pub struct VpnBuilder {
|
|||||||
server: String,
|
server: String,
|
||||||
cookie: String,
|
cookie: String,
|
||||||
script: Option<String>,
|
script: Option<String>,
|
||||||
|
interface: Option<String>,
|
||||||
|
|
||||||
user_agent: Option<String>,
|
user_agent: Option<String>,
|
||||||
os: Option<String>,
|
os: Option<String>,
|
||||||
@@ -128,6 +134,8 @@ pub struct VpnBuilder {
|
|||||||
mtu: u32,
|
mtu: u32,
|
||||||
disable_ipv6: bool,
|
disable_ipv6: bool,
|
||||||
no_dtls: bool,
|
no_dtls: bool,
|
||||||
|
|
||||||
|
dpd_interval: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VpnBuilder {
|
impl VpnBuilder {
|
||||||
@@ -136,6 +144,7 @@ impl VpnBuilder {
|
|||||||
server: server.to_string(),
|
server: server.to_string(),
|
||||||
cookie: cookie.to_string(),
|
cookie: cookie.to_string(),
|
||||||
script: None,
|
script: None,
|
||||||
|
interface: None,
|
||||||
|
|
||||||
user_agent: None,
|
user_agent: None,
|
||||||
os: None,
|
os: None,
|
||||||
@@ -151,6 +160,7 @@ impl VpnBuilder {
|
|||||||
mtu: 0,
|
mtu: 0,
|
||||||
disable_ipv6: false,
|
disable_ipv6: false,
|
||||||
no_dtls: false,
|
no_dtls: false,
|
||||||
|
dpd_interval: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +169,11 @@ impl VpnBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn interface<T: Into<Option<String>>>(mut self, interface: T) -> Self {
|
||||||
|
self.interface = interface.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn user_agent<T: Into<Option<String>>>(mut self, user_agent: T) -> Self {
|
pub fn user_agent<T: Into<Option<String>>>(mut self, user_agent: T) -> Self {
|
||||||
self.user_agent = user_agent.into();
|
self.user_agent = user_agent.into();
|
||||||
self
|
self
|
||||||
@@ -214,6 +229,11 @@ impl VpnBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dpd_interval(mut self, dpd_interval: u32) -> Self {
|
||||||
|
self.dpd_interval = dpd_interval;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build(self) -> Result<Vpn, VpnError> {
|
pub fn build(self) -> Result<Vpn, VpnError> {
|
||||||
let script = match self.script {
|
let script = match self.script {
|
||||||
Some(script) => {
|
Some(script) => {
|
||||||
@@ -235,6 +255,7 @@ impl VpnBuilder {
|
|||||||
cookie: Self::to_cstring(&self.cookie),
|
cookie: Self::to_cstring(&self.cookie),
|
||||||
user_agent: Self::to_cstring(&user_agent),
|
user_agent: Self::to_cstring(&user_agent),
|
||||||
script: Self::to_cstring(&script),
|
script: Self::to_cstring(&script),
|
||||||
|
interface: self.interface.as_deref().map(Self::to_cstring),
|
||||||
os: Self::to_cstring(&os),
|
os: Self::to_cstring(&os),
|
||||||
|
|
||||||
certificate: self.certificate.as_deref().map(Self::to_cstring),
|
certificate: self.certificate.as_deref().map(Self::to_cstring),
|
||||||
@@ -249,6 +270,7 @@ impl VpnBuilder {
|
|||||||
mtu: self.mtu,
|
mtu: self.mtu,
|
||||||
disable_ipv6: self.disable_ipv6,
|
disable_ipv6: self.disable_ipv6,
|
||||||
no_dtls: self.no_dtls,
|
no_dtls: self.no_dtls,
|
||||||
|
dpd_interval: self.dpd_interval,
|
||||||
|
|
||||||
callback: Default::default(),
|
callback: Default::default(),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user