mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Support specify csd-wrapper
This commit is contained in:
@@ -15,6 +15,9 @@ pub(crate) struct ConnectOptions {
|
||||
pub os: *const c_char,
|
||||
pub certificate: *const c_char,
|
||||
pub servercert: *const c_char,
|
||||
|
||||
pub csd_uid: u32,
|
||||
pub csd_wrapper: *const c_char,
|
||||
}
|
||||
|
||||
#[link(name = "vpn")]
|
||||
|
@@ -61,6 +61,8 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
INFO("User agent: %s", options->user_agent);
|
||||
INFO("VPNC script: %s", options->script);
|
||||
INFO("OS: %s", options->os);
|
||||
INFO("CSD_USER: %d", options->csd_uid);
|
||||
INFO("CSD_WRAPPER: %s", options->csd_wrapper);
|
||||
|
||||
vpninfo = openconnect_vpninfo_new(options->user_agent, validate_peer_cert, NULL, NULL, print_progress, NULL);
|
||||
|
||||
@@ -91,6 +93,10 @@ int vpn_connect(const vpn_options *options, vpn_connected_callback callback)
|
||||
openconnect_set_system_trust(vpninfo, 0);
|
||||
}
|
||||
|
||||
if (options->csd_wrapper) {
|
||||
openconnect_setup_csd(vpninfo, options->csd_uid, 1, options->csd_wrapper);
|
||||
}
|
||||
|
||||
g_cmd_pipe_fd = openconnect_setup_cmd_pipe(vpninfo);
|
||||
if (g_cmd_pipe_fd < 0)
|
||||
{
|
||||
|
@@ -16,6 +16,9 @@ typedef struct vpn_options
|
||||
const char *os;
|
||||
const char *certificate;
|
||||
const char *servercert;
|
||||
|
||||
const uid_t csd_uid;
|
||||
const char *csd_wrapper;
|
||||
} vpn_options;
|
||||
|
||||
int vpn_connect(const vpn_options *options, vpn_connected_callback callback);
|
||||
|
@@ -18,6 +18,9 @@ pub struct Vpn {
|
||||
certificate: Option<CString>,
|
||||
servercert: Option<CString>,
|
||||
|
||||
csd_uid: u32,
|
||||
csd_wrapper: Option<CString>,
|
||||
|
||||
callback: OnConnectedCallback,
|
||||
}
|
||||
|
||||
@@ -56,6 +59,9 @@ impl Vpn {
|
||||
os: self.os.as_ptr(),
|
||||
certificate: Self::option_to_ptr(&self.certificate),
|
||||
servercert: Self::option_to_ptr(&self.servercert),
|
||||
|
||||
csd_uid: self.csd_uid,
|
||||
csd_wrapper: Self::option_to_ptr(&self.csd_wrapper),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +79,9 @@ pub struct VpnBuilder {
|
||||
user_agent: Option<String>,
|
||||
script: Option<String>,
|
||||
os: Option<String>,
|
||||
|
||||
csd_uid: u32,
|
||||
csd_wrapper: Option<String>,
|
||||
}
|
||||
|
||||
impl VpnBuilder {
|
||||
@@ -83,6 +92,8 @@ impl VpnBuilder {
|
||||
user_agent: None,
|
||||
script: None,
|
||||
os: None,
|
||||
csd_uid: 0,
|
||||
csd_wrapper: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +112,16 @@ impl VpnBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn csd_uid(mut self, csd_uid: u32) -> Self {
|
||||
self.csd_uid = csd_uid;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn csd_wrapper<T: Into<Option<String>>>(mut self, csd_wrapper: T) -> Self {
|
||||
self.csd_wrapper = csd_wrapper.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> Vpn {
|
||||
let user_agent = self.user_agent.unwrap_or_default();
|
||||
let script = self.script.or_else(find_default_vpnc_script).unwrap_or_default();
|
||||
@@ -114,6 +135,10 @@ impl VpnBuilder {
|
||||
os: Self::to_cstring(&os),
|
||||
certificate: None,
|
||||
servercert: None,
|
||||
|
||||
csd_uid: self.csd_uid,
|
||||
csd_wrapper: self.csd_wrapper.as_deref().map(Self::to_cstring),
|
||||
|
||||
callback: Default::default(),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user