mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
refactor: remove unused iOS OpenConnect integration
Remove the iOS native-library build adapter and unused packet-endpoint builder and Rust/C FFI path. Keep the desktop build in build.rs with explicit macOS, Linux, FreeBSD and OpenBSD support. Preserve desktop device and script-tunnel behavior, shared protocol profiles, certificate pin checks and the pinned native conformance reference.
This commit is contained in:
7 files changed
+255
-339
No files matched your search
@@ -44,7 +44,6 @@ pub(crate) struct ConnectOptions {
|
||||
pub interface: *const c_char,
|
||||
pub script_tun: u32,
|
||||
pub script_tun_launch: *const ScriptTunLaunchRaw,
|
||||
pub packet_fd: c_int,
|
||||
|
||||
pub certificate: *const c_char,
|
||||
pub sslkey: *const c_char,
|
||||
|
||||
@@ -86,10 +86,7 @@ static void setup_tun_handler(void *private_data)
|
||||
struct openconnect_info *_vpninfo = context->vpninfo;
|
||||
const vpn_options *options = context->options;
|
||||
int ret;
|
||||
if (options->packet_fd >= 0) {
|
||||
int fd = dup(options->packet_fd);
|
||||
ret = fd < 0 ? -errno : openconnect_setup_tun_fd_with_config(_vpninfo, fd);
|
||||
} else if (options->script_tun) {
|
||||
if (options->script_tun) {
|
||||
const struct openconnect_script_tun_launch *launch = options->script_tun_launch;
|
||||
if (launch) {
|
||||
ret = openconnect_setup_tun_script_exec(_vpninfo, launch);
|
||||
|
||||
@@ -48,7 +48,6 @@ typedef struct vpn_options {
|
||||
const char *interface;
|
||||
const int script_tun;
|
||||
const struct openconnect_script_tun_launch *script_tun_launch;
|
||||
const int packet_fd;
|
||||
|
||||
const char *certificate;
|
||||
const char *sslkey;
|
||||
|
||||
@@ -151,7 +151,6 @@ pub struct Vpn {
|
||||
interface: Option<CString>,
|
||||
script_tun: bool,
|
||||
script_tun_launch: Option<ScriptTunLaunch>,
|
||||
packet_endpoint: Option<OwnedFd>,
|
||||
|
||||
certificate: Option<CString>,
|
||||
sslkey: Option<CString>,
|
||||
@@ -315,7 +314,6 @@ impl Vpn {
|
||||
interface: Self::option_to_ptr(&self.interface),
|
||||
script_tun: self.script_tun as u32,
|
||||
script_tun_launch: std::ptr::null(),
|
||||
packet_fd: self.packet_endpoint.as_ref().map_or(-1, AsRawFd::as_raw_fd),
|
||||
|
||||
certificate: Self::option_to_ptr(&self.certificate),
|
||||
sslkey: Self::option_to_ptr(&self.sslkey),
|
||||
@@ -384,7 +382,6 @@ pub struct VpnBuilder {
|
||||
interface: Option<String>,
|
||||
script_tun: bool,
|
||||
script_tun_launch: Option<ScriptTunLaunch>,
|
||||
packet_endpoint: Option<OwnedFd>,
|
||||
|
||||
user_agent: Option<String>,
|
||||
os: Option<String>,
|
||||
@@ -396,7 +393,6 @@ pub struct VpnBuilder {
|
||||
certificate: Option<String>,
|
||||
sslkey: Option<String>,
|
||||
key_password: Option<String>,
|
||||
servercert: Option<String>,
|
||||
|
||||
hip_source: Arc<HipSource>,
|
||||
|
||||
@@ -421,7 +417,6 @@ impl VpnBuilder {
|
||||
interface: None,
|
||||
script_tun: false,
|
||||
script_tun_launch: None,
|
||||
packet_endpoint: None,
|
||||
|
||||
user_agent: None,
|
||||
os: None,
|
||||
@@ -433,7 +428,6 @@ impl VpnBuilder {
|
||||
certificate: None,
|
||||
sslkey: None,
|
||||
key_password: None,
|
||||
servercert: None,
|
||||
|
||||
hip_source: Arc::new(HipSource::Disabled),
|
||||
|
||||
@@ -447,16 +441,6 @@ impl VpnBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/// Use an application-owned packet descriptor. OpenConnect borrows a duplicate
|
||||
/// during connect; this owner remains alive until the Vpn is dropped. Apple/BSD
|
||||
/// endpoints use the native four-byte, network-order address-family prefix.
|
||||
/// Requires callback configuration and a SHA-256 server public-key pin.
|
||||
pub fn packet_endpoint(mut self, endpoint: OwnedFd, server_pin: String) -> Self {
|
||||
self.packet_endpoint = Some(endpoint);
|
||||
self.servercert = Some(server_pin);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn script<T: Into<Option<String>>>(mut self, script: T) -> Self {
|
||||
self.script = script.into();
|
||||
self.script_is_path = false;
|
||||
@@ -634,24 +618,6 @@ impl VpnBuilder {
|
||||
}
|
||||
|
||||
pub fn build(self) -> Result<Vpn, VpnError> {
|
||||
if self.packet_endpoint.is_some() {
|
||||
let pin = self.servercert.as_deref().unwrap_or_default();
|
||||
if self.network_configuration_handler.is_none()
|
||||
|| self.interface.is_some()
|
||||
|| self.script.is_some()
|
||||
|| self.script_tun
|
||||
|| self.script_tun_launch.is_some()
|
||||
{
|
||||
return Err(VpnError::new(
|
||||
"Packet endpoint requires callback configuration and no device/script options".into(),
|
||||
));
|
||||
}
|
||||
if !pin.starts_with("pin-sha256:") || pin.len() != 55 || pin.contains('\0') {
|
||||
return Err(VpnError::new(
|
||||
"Packet endpoint requires a pin-sha256 server public-key fingerprint".into(),
|
||||
));
|
||||
}
|
||||
}
|
||||
if self.script_tun_launch.is_some() && !self.script_tun {
|
||||
return Err(VpnError::new("Child identity requires script-tun".into()));
|
||||
}
|
||||
@@ -677,12 +643,11 @@ impl VpnBuilder {
|
||||
interface: self.interface.as_deref().map(Self::to_cstring),
|
||||
script_tun: self.script_tun,
|
||||
script_tun_launch: self.script_tun_launch,
|
||||
packet_endpoint: self.packet_endpoint,
|
||||
|
||||
certificate: self.certificate.as_deref().map(Self::to_cstring),
|
||||
sslkey: self.sslkey.as_deref().map(Self::to_cstring),
|
||||
key_password: self.key_password.as_deref().map(Self::to_cstring),
|
||||
servercert: self.servercert.as_deref().map(Self::to_cstring),
|
||||
servercert: None,
|
||||
|
||||
hip_source: self.hip_source,
|
||||
|
||||
@@ -810,7 +775,6 @@ mod tests {
|
||||
interface: None,
|
||||
script_tun: false,
|
||||
script_tun_launch: None,
|
||||
packet_endpoint: None,
|
||||
certificate: None,
|
||||
sslkey: None,
|
||||
key_password: None,
|
||||
|
||||
Reference in new issue
Block a user