mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 14:36:15 -05:00
feat: generate HIP reports through OpenConnect callbacks
This commit is contained in:
46 files changed
+2511
-1184
No files matched your search
@@ -1,9 +1,12 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use clap::Args;
|
||||
use gpapi::{
|
||||
clap::args::Os,
|
||||
os_profile::{ClientOs, OsProfileBuilder},
|
||||
process::collection::CollectionBudget,
|
||||
};
|
||||
use gphip::{ReportContext, ReportInput, generate_report};
|
||||
use gphip::{ReportContext, ReportInput, generate_report_with_control};
|
||||
|
||||
#[derive(Args)]
|
||||
pub(crate) struct HipArgs {
|
||||
@@ -42,13 +45,17 @@ impl<'a> HipHandler<'a> {
|
||||
}
|
||||
|
||||
pub(crate) async fn handle(&self) -> anyhow::Result<()> {
|
||||
let budget = CollectionBudget::new(Duration::from_secs(60));
|
||||
let client_os = ClientOs::from(self.args.client_os);
|
||||
let mut builder = OsProfileBuilder::new(client_os).client_version(self.args.client_version.clone());
|
||||
if let Some(os_version) = self.args.os_version.as_deref() {
|
||||
builder = builder.os_version(os_version);
|
||||
}
|
||||
if let Some(host_id) = self.args.host_id.as_deref() {
|
||||
builder = builder.host_id_override(host_id);
|
||||
}
|
||||
let input = ReportInput {
|
||||
profile: builder.build(),
|
||||
profile: builder.build_with_control(&budget)?,
|
||||
context: ReportContext::Connected {
|
||||
cookie: self.args.cookie.clone(),
|
||||
client_ip: self.args.client_ip.clone(),
|
||||
@@ -56,7 +63,7 @@ impl<'a> HipHandler<'a> {
|
||||
md5: self.args.md5.clone(),
|
||||
},
|
||||
};
|
||||
println!("{}", generate_report(&input)?);
|
||||
println!("{}", generate_report_with_control(&input, &budget)?);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user