mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
feat: support the --no-dtls
option
This commit is contained in:
parent
c578e35178
commit
c2a6a436a5
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -11,6 +11,7 @@
|
|||||||
"distro",
|
"distro",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
"dtls",
|
||||||
"getconfig",
|
"getconfig",
|
||||||
"globalprotect",
|
"globalprotect",
|
||||||
"globalprotectcallback",
|
"globalprotectcallback",
|
||||||
|
@ -86,6 +86,9 @@ pub(crate) struct ConnectArgs {
|
|||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
os_version: Option<String>,
|
os_version: Option<String>,
|
||||||
|
|
||||||
|
#[arg(long, help="Disable DTLS and ESP")]
|
||||||
|
no_dtls: bool,
|
||||||
|
|
||||||
#[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,
|
||||||
|
|
||||||
@ -294,6 +297,7 @@ impl<'a> ConnectHandler<'a> {
|
|||||||
.reconnect_timeout(self.args.reconnect_timeout)
|
.reconnect_timeout(self.args.reconnect_timeout)
|
||||||
.mtu(mtu)
|
.mtu(mtu)
|
||||||
.disable_ipv6(self.args.disable_ipv6)
|
.disable_ipv6(self.args.disable_ipv6)
|
||||||
|
.no_dtls(self.args.no_dtls)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let vpn = Arc::new(vpn);
|
let vpn = Arc::new(vpn);
|
||||||
|
@ -47,6 +47,7 @@ impl VpnTaskContext {
|
|||||||
.reconnect_timeout(args.reconnect_timeout())
|
.reconnect_timeout(args.reconnect_timeout())
|
||||||
.mtu(args.mtu())
|
.mtu(args.mtu())
|
||||||
.disable_ipv6(args.disable_ipv6())
|
.disable_ipv6(args.disable_ipv6())
|
||||||
|
.no_dtls(args.no_dtls())
|
||||||
.build()
|
.build()
|
||||||
{
|
{
|
||||||
Ok(vpn) => vpn,
|
Ok(vpn) => vpn,
|
||||||
|
@ -41,6 +41,7 @@ pub struct ConnectArgs {
|
|||||||
reconnect_timeout: u32,
|
reconnect_timeout: u32,
|
||||||
mtu: u32,
|
mtu: u32,
|
||||||
disable_ipv6: bool,
|
disable_ipv6: bool,
|
||||||
|
no_dtls: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConnectArgs {
|
impl ConnectArgs {
|
||||||
@ -58,6 +59,7 @@ impl ConnectArgs {
|
|||||||
reconnect_timeout: 300,
|
reconnect_timeout: 300,
|
||||||
mtu: 0,
|
mtu: 0,
|
||||||
disable_ipv6: false,
|
disable_ipv6: false,
|
||||||
|
no_dtls: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +110,10 @@ impl ConnectArgs {
|
|||||||
pub fn disable_ipv6(&self) -> bool {
|
pub fn disable_ipv6(&self) -> bool {
|
||||||
self.disable_ipv6
|
self.disable_ipv6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn no_dtls(&self) -> bool {
|
||||||
|
self.no_dtls
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Type)]
|
#[derive(Debug, Deserialize, Serialize, Type)]
|
||||||
@ -179,6 +185,11 @@ impl ConnectRequest {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_no_dtls(mut self, no_dtls: bool) -> Self {
|
||||||
|
self.args.no_dtls = no_dtls;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn gateway(&self) -> &Gateway {
|
pub fn gateway(&self) -> &Gateway {
|
||||||
self.info.gateway()
|
self.info.gateway()
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ pub(crate) struct ConnectOptions {
|
|||||||
pub reconnect_timeout: u32,
|
pub reconnect_timeout: u32,
|
||||||
pub mtu: u32,
|
pub mtu: u32,
|
||||||
pub disable_ipv6: u32,
|
pub disable_ipv6: u32,
|
||||||
|
pub no_dtls: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[link(name = "vpn")]
|
#[link(name = "vpn")]
|
||||||
|
@ -63,6 +63,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
INFO("RECONNECT_TIMEOUT: %d", options->reconnect_timeout);
|
INFO("RECONNECT_TIMEOUT: %d", options->reconnect_timeout);
|
||||||
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);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openconnect_setup_dtls(vpninfo, 60) != 0) {
|
if (options->no_dtls || openconnect_setup_dtls(vpninfo, 60) != 0) {
|
||||||
openconnect_disable_dtls(vpninfo);
|
openconnect_disable_dtls(vpninfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ typedef struct vpn_options
|
|||||||
const int reconnect_timeout;
|
const int reconnect_timeout;
|
||||||
const int mtu;
|
const int mtu;
|
||||||
const int disable_ipv6;
|
const int disable_ipv6;
|
||||||
|
const int no_dtls;
|
||||||
} 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);
|
||||||
|
@ -28,6 +28,7 @@ pub struct Vpn {
|
|||||||
reconnect_timeout: u32,
|
reconnect_timeout: u32,
|
||||||
mtu: u32,
|
mtu: u32,
|
||||||
disable_ipv6: bool,
|
disable_ipv6: bool,
|
||||||
|
no_dtls: bool,
|
||||||
|
|
||||||
callback: OnConnectedCallback,
|
callback: OnConnectedCallback,
|
||||||
}
|
}
|
||||||
@ -77,6 +78,7 @@ impl Vpn {
|
|||||||
reconnect_timeout: self.reconnect_timeout,
|
reconnect_timeout: self.reconnect_timeout,
|
||||||
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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +127,7 @@ pub struct VpnBuilder {
|
|||||||
reconnect_timeout: u32,
|
reconnect_timeout: u32,
|
||||||
mtu: u32,
|
mtu: u32,
|
||||||
disable_ipv6: bool,
|
disable_ipv6: bool,
|
||||||
|
no_dtls: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VpnBuilder {
|
impl VpnBuilder {
|
||||||
@ -147,6 +150,7 @@ impl VpnBuilder {
|
|||||||
reconnect_timeout: 300,
|
reconnect_timeout: 300,
|
||||||
mtu: 0,
|
mtu: 0,
|
||||||
disable_ipv6: false,
|
disable_ipv6: false,
|
||||||
|
no_dtls: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +209,11 @@ impl VpnBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn no_dtls(mut self, no_dtls: bool) -> Self {
|
||||||
|
self.no_dtls = no_dtls;
|
||||||
|
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) => {
|
||||||
@ -239,6 +248,7 @@ impl VpnBuilder {
|
|||||||
reconnect_timeout: self.reconnect_timeout,
|
reconnect_timeout: self.reconnect_timeout,
|
||||||
mtu: self.mtu,
|
mtu: self.mtu,
|
||||||
disable_ipv6: self.disable_ipv6,
|
disable_ipv6: self.disable_ipv6,
|
||||||
|
no_dtls: self.no_dtls,
|
||||||
|
|
||||||
callback: Default::default(),
|
callback: Default::default(),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user