mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
feat: improve platform integration and release packaging
This commit is contained in:
17 files changed
+357
-105
No files matched your search
@@ -1,3 +1,5 @@
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
|
||||
@@ -15,6 +17,7 @@ pub struct ConnectInfo {
|
||||
pub struct ConnectedInfo {
|
||||
info: Box<ConnectInfo>,
|
||||
session_info: Option<SessionInfo>,
|
||||
connected_at: u32,
|
||||
}
|
||||
|
||||
impl ConnectedInfo {
|
||||
@@ -22,6 +25,7 @@ impl ConnectedInfo {
|
||||
Self {
|
||||
info: Box::new(info),
|
||||
session_info,
|
||||
connected_at: unix_timestamp(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +36,17 @@ impl ConnectedInfo {
|
||||
pub fn session_info(&self) -> Option<&SessionInfo> {
|
||||
self.session_info.as_ref()
|
||||
}
|
||||
|
||||
pub fn connected_at(&self) -> u32 {
|
||||
self.connected_at
|
||||
}
|
||||
}
|
||||
|
||||
fn unix_timestamp() -> u32 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_secs() as u32
|
||||
}
|
||||
|
||||
impl ConnectInfo {
|
||||
@@ -79,5 +94,6 @@ mod tests {
|
||||
|
||||
assert_eq!(value["connected"]["sessionInfo"]["lifetimeSecs"], 43_200);
|
||||
assert_eq!(value["connected"]["sessionInfo"]["allowExtendSession"], true);
|
||||
assert!(value["connected"]["connectedAt"].as_u64().is_some());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user