mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-17 13:46:27 -05:00
feat: add the --force-dpd option
gh-519
This commit is contained in:
5 files changed
+25
No files matched your search
@@ -96,6 +96,9 @@ pub(crate) struct ConnectArgs {
|
||||
#[arg(long, help = "Disable DTLS and ESP")]
|
||||
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")]
|
||||
#[arg(long, help = "The HiDPI mode, useful for high-resolution screens")]
|
||||
hidpi: bool,
|
||||
@@ -328,6 +331,7 @@ impl<'a> ConnectHandler<'a> {
|
||||
.mtu(mtu)
|
||||
.disable_ipv6(self.args.disable_ipv6)
|
||||
.no_dtls(self.args.no_dtls)
|
||||
.dpd_interval(self.args.dpd_interval.unwrap_or(0))
|
||||
.build()?;
|
||||
|
||||
let vpn = Arc::new(vpn);
|
||||
|
||||
@@ -26,6 +26,8 @@ pub(crate) struct ConnectOptions {
|
||||
pub mtu: u32,
|
||||
pub disable_ipv6: u32,
|
||||
pub no_dtls: u32,
|
||||
|
||||
pub dpd_interval: u32,
|
||||
}
|
||||
|
||||
#[link(name = "vpn")]
|
||||
|
||||
@@ -66,6 +66,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
INFO("MTU: %d", options->mtu);
|
||||
INFO("DISABLE_IPV6: %d", options->disable_ipv6);
|
||||
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);
|
||||
|
||||
@@ -106,6 +107,10 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
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);
|
||||
if (g_cmd_pipe_fd < 0) {
|
||||
ERROR("openconnect_setup_cmd_pipe failed");
|
||||
|
||||
@@ -27,6 +27,8 @@ typedef struct vpn_options
|
||||
const int mtu;
|
||||
const int disable_ipv6;
|
||||
const int no_dtls;
|
||||
|
||||
const int dpd_interval;
|
||||
} vpn_options;
|
||||
|
||||
int vpn_connect(const vpn_options *options, vpn_connected_callback callback);
|
||||
|
||||
@@ -31,6 +31,8 @@ pub struct Vpn {
|
||||
disable_ipv6: bool,
|
||||
no_dtls: bool,
|
||||
|
||||
dpd_interval: u32,
|
||||
|
||||
callback: OnConnectedCallback,
|
||||
}
|
||||
|
||||
@@ -81,6 +83,7 @@ impl Vpn {
|
||||
mtu: self.mtu,
|
||||
disable_ipv6: self.disable_ipv6 as u32,
|
||||
no_dtls: self.no_dtls as u32,
|
||||
dpd_interval: self.dpd_interval,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +134,8 @@ pub struct VpnBuilder {
|
||||
mtu: u32,
|
||||
disable_ipv6: bool,
|
||||
no_dtls: bool,
|
||||
|
||||
dpd_interval: u32,
|
||||
}
|
||||
|
||||
impl VpnBuilder {
|
||||
@@ -155,6 +160,7 @@ impl VpnBuilder {
|
||||
mtu: 0,
|
||||
disable_ipv6: false,
|
||||
no_dtls: false,
|
||||
dpd_interval: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +229,11 @@ impl VpnBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn dpd_interval(mut self, dpd_interval: u32) -> Self {
|
||||
self.dpd_interval = dpd_interval;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> Result<Vpn, VpnError> {
|
||||
let script = match self.script {
|
||||
Some(script) => {
|
||||
@@ -259,6 +270,7 @@ impl VpnBuilder {
|
||||
mtu: self.mtu,
|
||||
disable_ipv6: self.disable_ipv6,
|
||||
no_dtls: self.no_dtls,
|
||||
dpd_interval: self.dpd_interval,
|
||||
|
||||
callback: Default::default(),
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user