mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Update format
This commit is contained in:
@@ -5,8 +5,5 @@ fn main() {
|
||||
println!("cargo:rerun-if-changed=src/ffi/vpn.h");
|
||||
|
||||
// Compile the vpn.c file
|
||||
cc::Build::new()
|
||||
.file("src/ffi/vpn.c")
|
||||
.include("src/ffi")
|
||||
.compile("vpn");
|
||||
cc::Build::new().file("src/ffi/vpn.c").include("src/ffi").compile("vpn");
|
||||
}
|
||||
|
@@ -20,10 +20,7 @@ pub(crate) struct ConnectOptions {
|
||||
#[link(name = "vpn")]
|
||||
extern "C" {
|
||||
#[link_name = "vpn_connect"]
|
||||
fn vpn_connect(
|
||||
options: *const ConnectOptions,
|
||||
callback: extern "C" fn(i32, *mut c_void),
|
||||
) -> c_int;
|
||||
fn vpn_connect(options: *const ConnectOptions, callback: extern "C" fn(i32, *mut c_void)) -> c_int;
|
||||
|
||||
#[link_name = "vpn_disconnect"]
|
||||
fn vpn_disconnect();
|
||||
|
@@ -27,11 +27,7 @@ impl Vpn {
|
||||
}
|
||||
|
||||
pub fn connect(&self, on_connected: impl FnOnce() + 'static + Send + Sync) -> i32 {
|
||||
self
|
||||
.callback
|
||||
.write()
|
||||
.unwrap()
|
||||
.replace(Box::new(on_connected));
|
||||
self.callback.write().unwrap().replace(Box::new(on_connected));
|
||||
let options = self.build_connect_options();
|
||||
|
||||
ffi::connect(&options)
|
||||
@@ -107,10 +103,7 @@ impl VpnBuilder {
|
||||
|
||||
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();
|
||||
let script = self.script.or_else(find_default_vpnc_script).unwrap_or_default();
|
||||
let os = self.os.unwrap_or("linux".to_string());
|
||||
|
||||
Vpn {
|
||||
|
Reference in New Issue
Block a user