mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 14:36:15 -05:00
Add GlobalProtect NLB integration (Phase 6)
Expose NLB session metadata through the Rust FFI, extend fake-gp-server with NLB mode for integration testing, wire NLB unit tests into Makefile.am, recognize AES-GCM algorithm strings in check_enc_algo, and add gp-nlb-auth-and-config to verify getconfig parsing.
This commit is contained in:
6 files changed
+198
No files matched your search
@@ -47,6 +47,8 @@ pub(crate) struct VpnSessionInfoRaw {
|
||||
pub user_expires: c_long,
|
||||
pub lifetime_warning_prior: c_int,
|
||||
pub lifetime_warning_message: *const c_char,
|
||||
pub nlb_enabled: c_int,
|
||||
pub nlb_connected_gw_ip: *const c_char,
|
||||
}
|
||||
|
||||
#[link(name = "vpn")]
|
||||
|
||||
@@ -59,6 +59,9 @@ static void setup_tun_handler(void *_vpninfo)
|
||||
openconnect_get_gp_lifetime_notify_prior(_vpninfo),
|
||||
.lifetime_warning_message =
|
||||
openconnect_get_gp_lifetime_notify_message(_vpninfo),
|
||||
.nlb_enabled = openconnect_get_gp_nlb_enabled(_vpninfo),
|
||||
.nlb_connected_gw_ip =
|
||||
openconnect_get_gp_nlb_connected_gw_ip(_vpninfo),
|
||||
};
|
||||
on_vpn_connected(g_cmd_pipe_fd, &session_info, g_user_data);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ typedef struct vpn_session_info {
|
||||
long user_expires;
|
||||
int lifetime_warning_prior;
|
||||
const char *lifetime_warning_message;
|
||||
int nlb_enabled;
|
||||
const char *nlb_connected_gw_ip;
|
||||
} vpn_session_info;
|
||||
|
||||
typedef void (*vpn_connected_callback)(int cmd_pipe_fd,
|
||||
|
||||
@@ -16,6 +16,8 @@ pub struct VpnSessionInfo {
|
||||
pub lifetime_secs: Option<u32>,
|
||||
pub user_expires: Option<u32>,
|
||||
pub lifetime_warning: Option<VpnSessionWarning>,
|
||||
pub nlb_enabled: bool,
|
||||
pub nlb_connected_gw_ip: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -41,6 +43,8 @@ pub(crate) fn session_info_from_raw(raw: *const ffi::VpnSessionInfoRaw) -> VpnSe
|
||||
(Some(prior_secs), Some(message)) => Some(VpnSessionWarning { prior_secs, message }),
|
||||
_ => None,
|
||||
},
|
||||
nlb_enabled: raw.nlb_enabled != 0,
|
||||
nlb_connected_gw_ip: unsafe { optional_c_string(raw.nlb_connected_gw_ip) },
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,12 +430,15 @@ mod tests {
|
||||
#[test]
|
||||
fn maps_session_info_from_callback_payload() {
|
||||
let message = CString::new("Session expires soon").unwrap();
|
||||
let connected_gw = CString::new("10.1.2.3").unwrap();
|
||||
let raw = ffi::VpnSessionInfoRaw {
|
||||
auth_expiration: 0,
|
||||
lifetime_secs: 43_200,
|
||||
user_expires: 1_776_828_409,
|
||||
lifetime_warning_prior: 1_800,
|
||||
lifetime_warning_message: message.as_ptr(),
|
||||
nlb_enabled: 1,
|
||||
nlb_connected_gw_ip: connected_gw.as_ptr(),
|
||||
};
|
||||
|
||||
let info = session_info_from_raw(&raw);
|
||||
@@ -445,6 +452,8 @@ mod tests {
|
||||
message: "Session expires soon".to_string(),
|
||||
})
|
||||
);
|
||||
assert!(info.nlb_enabled);
|
||||
assert_eq!(info.nlb_connected_gw_ip.as_deref(), Some("10.1.2.3"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -455,6 +464,8 @@ mod tests {
|
||||
user_expires: 0,
|
||||
lifetime_warning_prior: 0,
|
||||
lifetime_warning_message: std::ptr::null(),
|
||||
nlb_enabled: 0,
|
||||
nlb_connected_gw_ip: std::ptr::null(),
|
||||
};
|
||||
|
||||
let info = session_info_from_raw(&raw);
|
||||
|
||||
Reference in new issue
Block a user