mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 14:36:15 -05:00
feat: expose openconnect connection options
This commit is contained in:
7 files changed
+93
-6
No files matched your search
@@ -15,6 +15,7 @@ pub(crate) struct ConnectOptions {
|
||||
pub os: *const c_char,
|
||||
pub os_version: *const c_char,
|
||||
pub client_version: *const c_char,
|
||||
pub local_hostname: *const c_char,
|
||||
|
||||
pub script: *const c_char,
|
||||
pub interface: *const c_char,
|
||||
@@ -34,6 +35,7 @@ pub(crate) struct ConnectOptions {
|
||||
pub no_dtls: u32,
|
||||
|
||||
pub dpd_interval: u32,
|
||||
pub no_xmlpost: u32,
|
||||
}
|
||||
|
||||
#[link(name = "vpn")]
|
||||
|
||||
@@ -60,6 +60,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
{
|
||||
struct openconnect_info *vpninfo;
|
||||
struct utsname utsbuf;
|
||||
const char *effective_local_hostname = NULL;
|
||||
|
||||
g_user_data = options->user_data;
|
||||
g_vpnc_script = options->script;
|
||||
@@ -79,6 +80,7 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
INFO("DISABLE_IPV6: %d", options->disable_ipv6);
|
||||
INFO("NO_DTLS: %d", options->no_dtls);
|
||||
INFO("DPD_INTERVAL: %d", options->dpd_interval);
|
||||
INFO("NO_XMLPOST: %d", options->no_xmlpost);
|
||||
|
||||
vpninfo =
|
||||
openconnect_vpninfo_new(options->user_agent, validate_peer_cert,
|
||||
@@ -109,6 +111,17 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
options->client_version);
|
||||
}
|
||||
|
||||
effective_local_hostname = options->local_hostname;
|
||||
if (!effective_local_hostname && !uname(&utsbuf)) {
|
||||
effective_local_hostname = utsbuf.nodename;
|
||||
}
|
||||
if (effective_local_hostname) {
|
||||
openconnect_set_localname(vpninfo, effective_local_hostname);
|
||||
}
|
||||
|
||||
INFO("LOCAL_HOSTNAME: %s",
|
||||
effective_local_hostname ? effective_local_hostname : "(not set)");
|
||||
|
||||
if (options->certificate) {
|
||||
INFO("Setting client certificate: %s", options->certificate);
|
||||
openconnect_set_client_cert(vpninfo, options->certificate,
|
||||
@@ -119,6 +132,10 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
openconnect_set_key_password(vpninfo, options->key_password);
|
||||
}
|
||||
|
||||
if (options->no_xmlpost) {
|
||||
openconnect_set_xmlpost(vpninfo, 0);
|
||||
}
|
||||
|
||||
if (options->csd_wrapper) {
|
||||
openconnect_setup_csd(vpninfo, options->csd_uid, 1,
|
||||
options->csd_wrapper);
|
||||
@@ -143,10 +160,6 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!uname(&utsbuf)) {
|
||||
openconnect_set_localname(vpninfo, utsbuf.nodename);
|
||||
}
|
||||
|
||||
// Essential step
|
||||
if (openconnect_make_cstp_connection(vpninfo) != 0) {
|
||||
ERROR("openconnect_make_cstp_connection failed");
|
||||
|
||||
@@ -15,6 +15,7 @@ typedef struct vpn_options {
|
||||
const char *os;
|
||||
const char *os_version;
|
||||
const char *client_version;
|
||||
const char *local_hostname;
|
||||
|
||||
const char *script;
|
||||
const char *interface;
|
||||
@@ -34,6 +35,7 @@ typedef struct vpn_options {
|
||||
const int no_dtls;
|
||||
|
||||
const int dpd_interval;
|
||||
const int no_xmlpost;
|
||||
} vpn_options;
|
||||
|
||||
int vpn_connect(const vpn_options *options, vpn_connected_callback callback);
|
||||
|
||||
Reference in new issue
Block a user