mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
feat: add the --reconnect-timeout
option
This commit is contained in:
@@ -32,10 +32,11 @@ pub struct ConnectArgs {
|
||||
cookie: String,
|
||||
vpnc_script: Option<String>,
|
||||
user_agent: Option<String>,
|
||||
os: Option<ClientOs>,
|
||||
csd_uid: u32,
|
||||
csd_wrapper: Option<String>,
|
||||
reconnect_timeout: u32,
|
||||
mtu: u32,
|
||||
os: Option<ClientOs>,
|
||||
disable_ipv6: bool,
|
||||
}
|
||||
|
||||
@@ -48,6 +49,7 @@ impl ConnectArgs {
|
||||
os: None,
|
||||
csd_uid: 0,
|
||||
csd_wrapper: None,
|
||||
reconnect_timeout: 300,
|
||||
mtu: 0,
|
||||
disable_ipv6: false,
|
||||
}
|
||||
@@ -77,6 +79,10 @@ impl ConnectArgs {
|
||||
self.csd_wrapper.clone()
|
||||
}
|
||||
|
||||
pub fn reconnect_timeout(&self) -> u32 {
|
||||
self.reconnect_timeout
|
||||
}
|
||||
|
||||
pub fn mtu(&self) -> u32 {
|
||||
self.mtu
|
||||
}
|
||||
@@ -125,6 +131,11 @@ impl ConnectRequest {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_reconnect_timeout(mut self, reconnect_timeout: u32) -> Self {
|
||||
self.args.reconnect_timeout = reconnect_timeout;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_mtu(mut self, mtu: u32) -> Self {
|
||||
self.args.mtu = mtu;
|
||||
self
|
||||
|
@@ -19,6 +19,7 @@ pub(crate) struct ConnectOptions {
|
||||
pub csd_uid: u32,
|
||||
pub csd_wrapper: *const c_char,
|
||||
|
||||
pub reconnect_timeout: u32,
|
||||
pub mtu: u32,
|
||||
pub disable_ipv6: u32,
|
||||
}
|
||||
|
@@ -63,6 +63,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
INFO("OS: %s", options->os);
|
||||
INFO("CSD_USER: %d", options->csd_uid);
|
||||
INFO("CSD_WRAPPER: %s", options->csd_wrapper);
|
||||
INFO("RECONNECT_TIMEOUT: %d", options->reconnect_timeout);
|
||||
INFO("MTU: %d", options->mtu);
|
||||
INFO("DISABLE_IPV6: %d", options->disable_ipv6);
|
||||
|
||||
@@ -137,7 +138,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
|
||||
while (1)
|
||||
{
|
||||
int ret = openconnect_mainloop(vpninfo, 300, 10);
|
||||
int ret = openconnect_mainloop(vpninfo, options->reconnect_timeout, 10);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
|
@@ -20,8 +20,8 @@ typedef struct vpn_options
|
||||
const uid_t csd_uid;
|
||||
const char *csd_wrapper;
|
||||
|
||||
const int reconnect_timeout;
|
||||
const int mtu;
|
||||
|
||||
const int disable_ipv6;
|
||||
} vpn_options;
|
||||
|
||||
|
@@ -23,6 +23,7 @@ pub struct Vpn {
|
||||
csd_uid: u32,
|
||||
csd_wrapper: Option<CString>,
|
||||
|
||||
reconnect_timeout: u32,
|
||||
mtu: u32,
|
||||
disable_ipv6: bool,
|
||||
|
||||
@@ -68,6 +69,7 @@ impl Vpn {
|
||||
csd_uid: self.csd_uid,
|
||||
csd_wrapper: Self::option_to_ptr(&self.csd_wrapper),
|
||||
|
||||
reconnect_timeout: self.reconnect_timeout,
|
||||
mtu: self.mtu,
|
||||
disable_ipv6: self.disable_ipv6 as u32,
|
||||
}
|
||||
@@ -111,6 +113,7 @@ pub struct VpnBuilder {
|
||||
csd_uid: u32,
|
||||
csd_wrapper: Option<String>,
|
||||
|
||||
reconnect_timeout: u32,
|
||||
mtu: u32,
|
||||
disable_ipv6: bool,
|
||||
}
|
||||
@@ -128,6 +131,7 @@ impl VpnBuilder {
|
||||
csd_uid: 0,
|
||||
csd_wrapper: None,
|
||||
|
||||
reconnect_timeout: 300,
|
||||
mtu: 0,
|
||||
disable_ipv6: false,
|
||||
}
|
||||
@@ -158,6 +162,11 @@ impl VpnBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn reconnect_timeout(mut self, reconnect_timeout: u32) -> Self {
|
||||
self.reconnect_timeout = reconnect_timeout;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn mtu(mut self, mtu: u32) -> Self {
|
||||
self.mtu = mtu;
|
||||
self
|
||||
@@ -196,6 +205,7 @@ impl VpnBuilder {
|
||||
csd_uid: self.csd_uid,
|
||||
csd_wrapper: self.csd_wrapper.as_deref().map(Self::to_cstring),
|
||||
|
||||
reconnect_timeout: self.reconnect_timeout,
|
||||
mtu: self.mtu,
|
||||
disable_ipv6: self.disable_ipv6,
|
||||
|
||||
|
Reference in New Issue
Block a user