fix: use portal policy for session extension

This commit is contained in:
Kevin Yue committed 2026-05-06 23:20:57 +08:00
1 parent 731a0d895c
commit fb6db0dc12
10 files changed
+164 -49

No files matched your search

@@ -2,7 +2,7 @@ diff --git a/gpst.c b/gpst.c
index 244aaf04..78c16d1c 100644
--- a/gpst.c
+++ b/gpst.c
@@ -438,8 +438,23 @@ static int gpst_parse_config_xml(struct openconnect_info *vpninfo, xmlNode *xml_
@@ -438,8 +438,19 @@ static int gpst_parse_config_xml(struct openconnect_info *vpninfo, xmlNode *xml_
new_ip_info.netmask = add_option_steal(&new_opts, "netmask", &s);
} else if (!xmlnode_get_val(xml_node, "mtu", &s))
new_ip_info.mtu = atoi(s);
@@ -19,10 +19,6 @@ index 244aaf04..78c16d1c 100644
+ free(vpninfo->gp_lifetime_notify_message);
+ vpninfo->gp_lifetime_notify_message = s;
+ s = NULL;
+ } else if (!xmlnode_get_val(xml_node, "allow-extend-session", &s)) {
+ vpninfo->gp_allow_extend_session = !strcasecmp(s, "yes") ||
+ !strcasecmp(s, "true") ||
+ !strcmp(s, "1");
+ }
else if (!xmlnode_get_val(xml_node, "quarantine", &s)) {
if (strcmp(s, "no"))
@@ -31,7 +27,7 @@ diff --git a/libopenconnect.map.in b/libopenconnect.map.in
index f036c071..44110486 100644
--- a/libopenconnect.map.in
+++ b/libopenconnect.map.in
@@ -113,6 +113,11 @@ OPENCONNECT_5_7 {
@@ -113,6 +113,10 @@ OPENCONNECT_5_7 {
openconnect_set_cookie;
openconnect_set_allow_insecure_crypto;
openconnect_get_auth_expiration;
@@ -39,7 +35,6 @@ index f036c071..44110486 100644
+ openconnect_get_gp_user_expires;
+ openconnect_get_gp_lifetime_notify_prior;
+ openconnect_get_gp_lifetime_notify_message;
+ openconnect_get_gp_allow_extend_session;
openconnect_disable_dtls;
openconnect_get_connect_url;
openconnect_set_webview_callback;
@@ -47,7 +42,7 @@ diff --git a/libopenconnect5.symbols b/libopenconnect5.symbols
index 7cb04d05..2c7af781 100644
--- a/libopenconnect5.symbols
+++ b/libopenconnect5.symbols
@@ -94,6 +94,11 @@ libopenconnect.so.5 libopenconnect5 #MINVER#
@@ -94,6 +94,10 @@ libopenconnect.so.5 libopenconnect5 #MINVER#
openconnect_set_cookie@OPENCONNECT_5_7 8.20
openconnect_set_allow_insecure_crypto@OPENCONNECT_5_7 8.20
openconnect_get_auth_expiration@OPENCONNECT_5_7 8.20
@@ -55,7 +50,6 @@ index 7cb04d05..2c7af781 100644
+ openconnect_get_gp_user_expires@OPENCONNECT_5_7 8.20
+ openconnect_get_gp_lifetime_notify_prior@OPENCONNECT_5_7 8.20
+ openconnect_get_gp_lifetime_notify_message@OPENCONNECT_5_7 8.20
+ openconnect_get_gp_allow_extend_session@OPENCONNECT_5_7 8.20
openconnect_disable_dtls@OPENCONNECT_5_7 8.20
openconnect_get_connect_url@OPENCONNECT_5_7 8.20
openconnect_set_webview_callback@OPENCONNECT_5_7 8.20
@@ -71,7 +65,7 @@ index b5e74e9b..03f47004 100644
#if defined(OPENCONNECT_OPENSSL)
free(vpninfo->cstp_cipher);
#if defined(HAVE_BIO_METH_FREE)
@@ -1137,6 +1138,31 @@ time_t openconnect_get_auth_expiration(struct openconnect_info *vpninfo)
@@ -1137,6 +1138,26 @@ time_t openconnect_get_auth_expiration(struct openconnect_info *vpninfo)
return vpninfo->auth_expiration;
}
@@ -94,11 +88,6 @@ index b5e74e9b..03f47004 100644
+{
+ return vpninfo->gp_lifetime_notify_message;
+}
+
+int openconnect_get_gp_allow_extend_session(struct openconnect_info *vpninfo)
+{
+ return vpninfo->gp_allow_extend_session;
+}
+
int openconnect_get_ip_info(struct openconnect_info *vpninfo,
const struct oc_ip_info **info,
@@ -107,7 +96,7 @@ diff --git a/openconnect-internal.h b/openconnect-internal.h
index abf45bbd..dd5507ca 100644
--- a/openconnect-internal.h
+++ b/openconnect-internal.h
@@ -647,6 +647,11 @@ struct openconnect_info {
@@ -647,6 +647,10 @@ struct openconnect_info {
int dtls_attempt_period;
int udp_probes_sent;
time_t auth_expiration;
@@ -115,7 +104,6 @@ index abf45bbd..dd5507ca 100644
+ time_t gp_user_expires;
+ int gp_lifetime_notify_prior;
+ char *gp_lifetime_notify_message;
+ int gp_allow_extend_session;
time_t new_dtls_started;
#if defined(OPENCONNECT_OPENSSL)
SSL_CTX *dtls_ctx;
@@ -123,7 +111,7 @@ diff --git a/openconnect.h b/openconnect.h
index 136f181a..febf15cc 100644
--- a/openconnect.h
+++ b/openconnect.h
@@ -655,6 +655,11 @@ void openconnect_set_dpd(struct openconnect_info *, int min_seconds);
@@ -655,6 +655,10 @@ void openconnect_set_dpd(struct openconnect_info *, int min_seconds);
void openconnect_set_trojan_interval(struct openconnect_info *, int seconds);
int openconnect_get_idle_timeout(struct openconnect_info *);
time_t openconnect_get_auth_expiration(struct openconnect_info *);
@@ -131,7 +119,6 @@ index 136f181a..febf15cc 100644
+time_t openconnect_get_gp_user_expires(struct openconnect_info *);
+int openconnect_get_gp_lifetime_notify_prior(struct openconnect_info *);
+const char *openconnect_get_gp_lifetime_notify_message(struct openconnect_info *);
+int openconnect_get_gp_allow_extend_session(struct openconnect_info *);
/* The returned structures are owned by the library and may be freed/replaced
due to rekey or reconnect. Assume that once the mainloop starts, the
-1
View File
@@ -46,7 +46,6 @@ pub(crate) struct VpnSessionInfoRaw {
pub user_expires: c_long,
pub lifetime_warning_prior: c_int,
pub lifetime_warning_message: *const c_char,
pub allow_extend_session: c_int,
}
#[link(name = "vpn")]
-2
View File
@@ -59,8 +59,6 @@ static void setup_tun_handler(void *_vpninfo)
openconnect_get_gp_lifetime_notify_prior(_vpninfo),
.lifetime_warning_message =
openconnect_get_gp_lifetime_notify_message(_vpninfo),
.allow_extend_session =
openconnect_get_gp_allow_extend_session(_vpninfo),
};
on_vpn_connected(g_cmd_pipe_fd, &session_info, g_user_data);
}
-1
View File
@@ -9,7 +9,6 @@ typedef struct vpn_session_info {
long user_expires;
int lifetime_warning_prior;
const char *lifetime_warning_message;
int allow_extend_session;
} vpn_session_info;
typedef void (*vpn_connected_callback)(int cmd_pipe_fd,
-6
View File
@@ -16,7 +16,6 @@ pub struct VpnSessionInfo {
pub lifetime_secs: Option<u32>,
pub user_expires: Option<u32>,
pub lifetime_warning: Option<VpnSessionWarning>,
pub allow_extend_session: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -42,7 +41,6 @@ pub(crate) fn session_info_from_raw(raw: *const ffi::VpnSessionInfoRaw) -> VpnSe
(Some(prior_secs), Some(message)) => Some(VpnSessionWarning { prior_secs, message }),
_ => None,
},
allow_extend_session: raw.allow_extend_session != 0,
}
}
@@ -424,7 +422,6 @@ mod tests {
user_expires: 1_776_828_409,
lifetime_warning_prior: 1_800,
lifetime_warning_message: message.as_ptr(),
allow_extend_session: 1,
};
let info = session_info_from_raw(&raw);
@@ -438,7 +435,6 @@ mod tests {
message: "Session expires soon".to_string(),
})
);
assert!(info.allow_extend_session);
}
#[test]
@@ -449,7 +445,6 @@ mod tests {
user_expires: 0,
lifetime_warning_prior: 0,
lifetime_warning_message: std::ptr::null(),
allow_extend_session: 0,
};
let info = session_info_from_raw(&raw);
@@ -457,6 +452,5 @@ mod tests {
assert_eq!(info.user_expires, Some(1_776_828_409));
assert_eq!(info.lifetime_secs, None);
assert_eq!(info.lifetime_warning, None);
assert!(!info.allow_extend_session);
}
}