Skip to content

Commit d797c4f

Browse files
committed
feat: add HIP report generation functionality and related dependencies
1 parent f398cca commit d797c4f

File tree

24 files changed

+1266
-138
lines changed

24 files changed

+1266
-138
lines changed

Cargo.lock

Lines changed: 229 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ license = "GPL-3.0"
1919

2020
[workspace.dependencies]
2121
anyhow = "1.0"
22+
askama = "0.14"
2223
base64 = "0.22"
24+
chrono = "0.4"
2325
clap = { version = "4", features = ["derive"] }
2426
clap-verbosity-flag = "3"
2527
ctrlc = "3.4"
@@ -32,7 +34,7 @@ regex = "1"
3234
reqwest = { version = "0.12", features = ["native-tls", "json"] }
3335
openssl = "0.10"
3436
pem = "3"
35-
roxmltree = "0.21"
37+
xmltree = "0.12"
3638
serde = { version = "1.0", features = ["derive"] }
3739
serde_json = "1.0"
3840
# Use 0.36 as newer versions requires Rust 1.88+
@@ -54,6 +56,9 @@ serde_urlencoded = "0.7"
5456
md5 = "0.8"
5557
sha256 = "1"
5658
which = "8"
59+
uuid = "1"
60+
netdev = "0.39"
61+
machine-uid = "0.5"
5762

5863
# Tauri dependencies
5964
tauri = { version = "2" }

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ install:
136136
install -Dm755 .build/gpgui/gpgui_*/gpgui $(DESTDIR)/usr/bin/gpgui; \
137137
fi
138138

139+
# Install the HIP report script
140+
install -Dm755 packaging/files/usr/libexec/gpclient/hipreport.sh $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
141+
139142
# Install the disconnect hooks
140143
install -Dm755 packaging/files/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
141144
install -Dm755 packaging/files/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
@@ -156,6 +159,8 @@ uninstall:
156159
rm -f $(DESTDIR)/usr/bin/gpgui-helper
157160
rm -f $(DESTDIR)/usr/bin/gpgui
158161

162+
rm -f $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
163+
159164
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
160165
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
161166

apps/gpclient/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@ gpapi = { path = "../../crates/gpapi", features = ["clap"] }
1212
openconnect = { path = "../../crates/openconnect" }
1313

1414
anyhow.workspace = true
15+
askama.workspace = true
16+
chrono.workspace = true
1517
clap.workspace = true
1618
env_logger.workspace = true
1719
inquire = "0.9"
1820
log.workspace = true
1921
tokio = { workspace = true, features = ["rt-multi-thread"] }
2022
sysinfo.workspace = true
2123
serde_json.workspace = true
24+
serde_urlencoded.workspace = true
2225
whoami.workspace = true
2326
tempfile.workspace = true
2427
reqwest.workspace = true
2528
directories.workspace = true
2629
compile-time.workspace = true
30+
netdev.workspace = true
31+
xmltree.workspace = true
2732

2833
[features]
2934
default = ["webview-auth"]

apps/gpclient/src/cli.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{env::temp_dir, fs::File, str::FromStr};
33
use anyhow::bail;
44
use clap::{Parser, Subcommand};
55
use gpapi::{
6-
clap::{handle_error, Args, InfoLevelVerbosity},
6+
clap::{Args, InfoLevelVerbosity, handle_error},
77
utils::openssl,
88
};
99
use log::info;
@@ -12,10 +12,11 @@ use tempfile::NamedTempFile;
1212
use tokio::fs;
1313

1414
use crate::{
15+
GP_CLIENT_LOCK_FILE,
1516
connect::{ConnectArgs, ConnectHandler},
1617
disconnect::{DisconnectArgs, DisconnectHandler},
18+
hip::{HipArgs, HipHandler},
1719
launch_gui::{LaunchGuiArgs, LaunchGuiHandler},
18-
GP_CLIENT_LOCK_FILE,
1920
};
2021

2122
const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")");
@@ -34,6 +35,8 @@ enum CliCommand {
3435
Disconnect(DisconnectArgs),
3536
#[command(about = "Launch the GUI")]
3637
LaunchGui(LaunchGuiArgs),
38+
#[command(about = "Generate HIP report")]
39+
Hip(HipArgs),
3740
}
3841

3942
#[derive(Parser)]
@@ -132,6 +135,7 @@ impl Cli {
132135
CliCommand::Connect(args) => ConnectHandler::new(args, &shared_args).handle().await,
133136
CliCommand::Disconnect(args) => DisconnectHandler::new(args).handle().await,
134137
CliCommand::LaunchGui(args) => LaunchGuiHandler::new(args).handle().await,
138+
CliCommand::Hip(args) => HipHandler::new(args).handle().await,
135139
}
136140
}
137141
}

apps/gpclient/src/connect.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use gpapi::{
1515
auth_launcher::SamlAuthLauncher,
1616
users::{get_non_root_user, get_user_by_name},
1717
},
18-
utils::{request::RequestIdentityError, shutdown_signal},
18+
utils::{host_utils, request::RequestIdentityError, shutdown_signal},
1919
};
2020
use inquire::{Password, PasswordDisplayMode, Select, Text};
2121
use log::{info, warn};
@@ -130,18 +130,29 @@ pub(crate) struct ConnectArgs {
130130

131131
impl ConnectArgs {
132132
fn default_os() -> Os {
133-
if cfg!(target_os = "macos") { Os::Mac } else { Os::Linux }
133+
#[cfg(target_os = "macos")]
134+
{
135+
Os::Mac
136+
}
137+
#[cfg(target_os = "windows")]
138+
{
139+
Os::Windows
140+
}
141+
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
142+
{
143+
Os::Linux
144+
}
134145
}
135146

136-
fn os_version(&self) -> String {
147+
fn os_version(&self) -> &str {
137148
if let Some(os_version) = self.os_version.as_deref() {
138-
return os_version.to_string();
149+
return os_version;
139150
}
140151

141152
match self.os {
142-
Os::Linux => format!("Linux {}", whoami::distro()),
143-
Os::Windows => String::from("Microsoft Windows 11 Pro , 64-bit"),
144-
Os::Mac => String::from("Apple Mac OS X 13.4.0"),
153+
Os::Linux => host_utils::get_linux_os_string(),
154+
Os::Windows => host_utils::get_windows_os_string(),
155+
Os::Mac => host_utils::get_macos_os_string(),
145156
}
146157
}
147158
}
@@ -167,7 +178,7 @@ impl<'a> ConnectHandler<'a> {
167178
GpParams::builder()
168179
.user_agent(&self.args.user_agent)
169180
.client_os(ClientOs::from(&self.args.os))
170-
.os_version(self.args.os_version())
181+
.os_version(self.args.os_version().to_owned())
171182
.ignore_tls_errors(self.shared_args.ignore_tls_errors)
172183
.certificate(self.args.certificate.clone())
173184
.sslkey(self.args.sslkey.clone())

0 commit comments

Comments
 (0)