mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 14:06:14 -05:00
Compare commits
4
Commits
v2.5.3
...
gpauth_windows
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee675b059b | ||
|
|
0669447aed | ||
|
|
d797c4f40e | ||
|
|
3175d1083a |
No files matched your search
Generated
+351
-27
@@ -119,6 +119,48 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16"
|
||||
|
||||
[[package]]
|
||||
name = "askama"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"
|
||||
dependencies = [
|
||||
"askama_derive",
|
||||
"itoa",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_derive"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"
|
||||
dependencies = [
|
||||
"askama_parser",
|
||||
"basic-toml",
|
||||
"memchr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_parser"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"winnow 0.7.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.89"
|
||||
@@ -174,6 +216,7 @@ dependencies = [
|
||||
"objc2-web-kit",
|
||||
"open",
|
||||
"regex",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tiny_http",
|
||||
"tokio",
|
||||
@@ -181,7 +224,10 @@ dependencies = [
|
||||
"uuid",
|
||||
"webbrowser",
|
||||
"webkit2gtk",
|
||||
"webview2-com 0.34.0",
|
||||
"which",
|
||||
"windows 0.58.0",
|
||||
"windows-core 0.58.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -266,6 +312,15 @@ version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "basic-toml"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
@@ -503,8 +558,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
"windows-link 0.2.1",
|
||||
]
|
||||
|
||||
@@ -964,6 +1021,17 @@ dependencies = [
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dlopen2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09b4f5f101177ff01b8ec4ecc81eead416a8aa42819a2869311b3420fa114ffa"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"once_cell",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dlopen2"
|
||||
version = "0.8.2"
|
||||
@@ -1622,13 +1690,14 @@ dependencies = [
|
||||
"gtk",
|
||||
"log",
|
||||
"log-reload",
|
||||
"machine-uid",
|
||||
"md5",
|
||||
"openssl",
|
||||
"os_info",
|
||||
"pem",
|
||||
"redact-engine",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"roxmltree",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
@@ -1640,9 +1709,11 @@ dependencies = [
|
||||
"tokio",
|
||||
"url",
|
||||
"urlencoding",
|
||||
"uuid",
|
||||
"uzers",
|
||||
"version-compare",
|
||||
"whoami",
|
||||
"xmltree",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1670,6 +1741,8 @@ name = "gpclient"
|
||||
version = "2.5.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"askama",
|
||||
"chrono",
|
||||
"clap",
|
||||
"common",
|
||||
"compile-time",
|
||||
@@ -1678,13 +1751,16 @@ dependencies = [
|
||||
"gpapi",
|
||||
"inquire",
|
||||
"log",
|
||||
"netdev",
|
||||
"openconnect",
|
||||
"reqwest",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"sysinfo",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"whoami",
|
||||
"xmltree",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2477,6 +2553,23 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
|
||||
|
||||
[[package]]
|
||||
name = "mac-addr"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3d25b0e0b648a86960ac23b7ad4abb9717601dec6f66c165f5b037f3f03065f"
|
||||
|
||||
[[package]]
|
||||
name = "machine-uid"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d7217d573cdb141d6da43113b098172e057d39915d79c4bdedbc3aacd46bd96"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-registry",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "markup5ever"
|
||||
version = "0.14.1"
|
||||
@@ -2631,12 +2724,74 @@ dependencies = [
|
||||
"jni-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "netdev"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35a703aa1a87cd885b9f674922445a42dbb0c0f4f1b28fef21b227ae32375d21"
|
||||
dependencies = [
|
||||
"dlopen2 0.5.0",
|
||||
"ipnet",
|
||||
"libc",
|
||||
"mac-addr",
|
||||
"netlink-packet-core",
|
||||
"netlink-packet-route",
|
||||
"netlink-sys",
|
||||
"once_cell",
|
||||
"system-configuration",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "netlink-packet-core"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3463cbb78394cb0141e2c926b93fc2197e473394b761986eca3b9da2c63ae0f4"
|
||||
dependencies = [
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "netlink-packet-route"
|
||||
version = "0.25.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ec2f5b6839be2a19d7fa5aab5bc444380f6311c2b693551cb80f45caaa7b5ef"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"libc",
|
||||
"log",
|
||||
"netlink-packet-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "netlink-sys"
|
||||
version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16c903aa70590cb93691bf97a767c8d1d6122d2cc9070433deb3bbf36ce8bd23"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"libc",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "new_debug_unreachable"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.30.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nodrop"
|
||||
version = "0.1.14"
|
||||
@@ -2792,6 +2947,16 @@ dependencies = [
|
||||
"objc2-foundation 0.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-core-location"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca347214e24bc973fc025fd0d36ebb179ff30536ed1f80252706db19ee452009"
|
||||
dependencies = [
|
||||
"objc2 0.6.3",
|
||||
"objc2-foundation 0.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-core-text"
|
||||
version = "0.3.2"
|
||||
@@ -2921,6 +3086,7 @@ checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"objc2 0.6.3",
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation 0.3.2",
|
||||
]
|
||||
|
||||
@@ -2942,8 +3108,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"block2 0.6.2",
|
||||
"objc2 0.6.3",
|
||||
"objc2-cloud-kit",
|
||||
"objc2-core-data",
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
"objc2-core-image",
|
||||
"objc2-core-location",
|
||||
"objc2-core-text",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-quartz-core 0.3.2",
|
||||
"objc2-user-notifications",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-user-notifications"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9df9128cbbfef73cda168416ccf7f837b62737d748333bfe9ab71c245d76613e"
|
||||
dependencies = [
|
||||
"objc2 0.6.3",
|
||||
"objc2-foundation 0.3.2",
|
||||
]
|
||||
|
||||
@@ -3036,6 +3221,15 @@ version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-src"
|
||||
version = "300.5.4+3.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a507b3792995dae9b0df8a1c1e3771e8418b7c2d9f0baeba32e6fe8b06c7cb72"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.111"
|
||||
@@ -3044,6 +3238,7 @@ checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"openssl-src",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
@@ -3054,6 +3249,21 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "os_info"
|
||||
version = "3.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c39b5918402d564846d5aba164c09a66cc88d232179dfd3e3c619a25a268392"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"log",
|
||||
"nix",
|
||||
"objc2 0.6.3",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-ui-kit",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pango"
|
||||
version = "0.18.3"
|
||||
@@ -3102,6 +3312,12 @@ dependencies = [
|
||||
"windows-link 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pathdiff"
|
||||
version = "0.2.3"
|
||||
@@ -3727,13 +3943,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "roxmltree"
|
||||
version = "0.21.1"
|
||||
name = "rustc-hash"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1964b10c76125c36f8afe190065a4bf9a87bf324842c05701330bba9f1cacbb"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
@@ -4130,6 +4343,12 @@ dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1_smol"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d"
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.9"
|
||||
@@ -4407,7 +4626,7 @@ dependencies = [
|
||||
"ntapi",
|
||||
"objc2-core-foundation",
|
||||
"objc2-io-kit",
|
||||
"windows",
|
||||
"windows 0.61.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4456,7 +4675,7 @@ dependencies = [
|
||||
"core-graphics",
|
||||
"crossbeam-channel",
|
||||
"dispatch",
|
||||
"dlopen2",
|
||||
"dlopen2 0.8.2",
|
||||
"dpi",
|
||||
"gdkwayland-sys",
|
||||
"gdkx11-sys",
|
||||
@@ -4478,7 +4697,7 @@ dependencies = [
|
||||
"tao-macros",
|
||||
"unicode-segmentation",
|
||||
"url",
|
||||
"windows",
|
||||
"windows 0.61.3",
|
||||
"windows-core 0.61.2",
|
||||
"windows-version",
|
||||
"x11-dl",
|
||||
@@ -4558,9 +4777,9 @@ dependencies = [
|
||||
"tray-icon",
|
||||
"url",
|
||||
"webkit2gtk",
|
||||
"webview2-com",
|
||||
"webview2-com 0.38.0",
|
||||
"window-vibrancy",
|
||||
"windows",
|
||||
"windows 0.61.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4647,8 +4866,8 @@ dependencies = [
|
||||
"thiserror 2.0.17",
|
||||
"url",
|
||||
"webkit2gtk",
|
||||
"webview2-com",
|
||||
"windows",
|
||||
"webview2-com 0.38.0",
|
||||
"windows 0.61.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4673,8 +4892,8 @@ dependencies = [
|
||||
"tauri-utils",
|
||||
"url",
|
||||
"webkit2gtk",
|
||||
"webview2-com",
|
||||
"windows",
|
||||
"webview2-com 0.38.0",
|
||||
"windows 0.61.3",
|
||||
"wry",
|
||||
]
|
||||
|
||||
@@ -5282,6 +5501,7 @@ dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"js-sys",
|
||||
"serde_core",
|
||||
"sha1_smol",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
@@ -5520,6 +5740,20 @@ dependencies = [
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webview2-com"
|
||||
version = "0.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "823e7ebcfaea51e78f72c87fc3b65a1e602c321f407a0b36dbb327d7bb7cd921"
|
||||
dependencies = [
|
||||
"webview2-com-macros",
|
||||
"webview2-com-sys 0.34.0",
|
||||
"windows 0.58.0",
|
||||
"windows-core 0.58.0",
|
||||
"windows-implement 0.58.0",
|
||||
"windows-interface 0.58.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webview2-com"
|
||||
version = "0.38.0"
|
||||
@@ -5527,11 +5761,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4ba622a989277ef3886dd5afb3e280e3dd6d974b766118950a08f8f678ad6a4"
|
||||
dependencies = [
|
||||
"webview2-com-macros",
|
||||
"webview2-com-sys",
|
||||
"windows",
|
||||
"webview2-com-sys 0.38.0",
|
||||
"windows 0.61.3",
|
||||
"windows-core 0.61.2",
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-implement 0.60.2",
|
||||
"windows-interface 0.59.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5545,6 +5779,17 @@ dependencies = [
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webview2-com-sys"
|
||||
version = "0.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a82bce72db6e5ee83c68b5de1e2cd6ea195b9fbff91cb37df5884cbe3222df4"
|
||||
dependencies = [
|
||||
"thiserror 1.0.69",
|
||||
"windows 0.58.0",
|
||||
"windows-core 0.58.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webview2-com-sys"
|
||||
version = "0.38.0"
|
||||
@@ -5552,7 +5797,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36695906a1b53a3bf5c4289621efedac12b73eeb0b89e7e1a89b517302d5d75c"
|
||||
dependencies = [
|
||||
"thiserror 2.0.17",
|
||||
"windows",
|
||||
"windows 0.61.3",
|
||||
"windows-core 0.61.2",
|
||||
]
|
||||
|
||||
@@ -5624,6 +5869,16 @@ dependencies = [
|
||||
"windows-version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.58.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
|
||||
dependencies = [
|
||||
"windows-core 0.58.0",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.61.3"
|
||||
@@ -5646,14 +5901,27 @@ dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.58.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
|
||||
dependencies = [
|
||||
"windows-implement 0.58.0",
|
||||
"windows-interface 0.58.0",
|
||||
"windows-result 0.2.0",
|
||||
"windows-strings 0.1.0",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-implement 0.60.2",
|
||||
"windows-interface 0.59.3",
|
||||
"windows-link 0.1.3",
|
||||
"windows-result 0.3.4",
|
||||
"windows-strings 0.4.2",
|
||||
@@ -5665,8 +5933,8 @@ version = "0.62.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-implement 0.60.2",
|
||||
"windows-interface 0.59.3",
|
||||
"windows-link 0.2.1",
|
||||
"windows-result 0.4.1",
|
||||
"windows-strings 0.5.1",
|
||||
@@ -5683,6 +5951,17 @@ dependencies = [
|
||||
"windows-threading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.58.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.60.2"
|
||||
@@ -5694,6 +5973,17 @@ dependencies = [
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.58.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.59.3"
|
||||
@@ -5738,6 +6028,15 @@ dependencies = [
|
||||
"windows-strings 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.3.4"
|
||||
@@ -5756,6 +6055,16 @@ dependencies = [
|
||||
"windows-link 0.2.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
||||
dependencies = [
|
||||
"windows-result 0.2.0",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.4.2"
|
||||
@@ -6107,8 +6416,8 @@ dependencies = [
|
||||
"url",
|
||||
"webkit2gtk",
|
||||
"webkit2gtk-sys",
|
||||
"webview2-com",
|
||||
"windows",
|
||||
"webview2-com 0.38.0",
|
||||
"windows 0.61.3",
|
||||
"windows-core 0.61.2",
|
||||
"windows-version",
|
||||
"x11-dl",
|
||||
@@ -6145,6 +6454,21 @@ dependencies = [
|
||||
"rustix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xml"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2df5825faced2427b2da74d9100f1e2e93c533fff063506a81ede1cf517b2e7e"
|
||||
|
||||
[[package]]
|
||||
name = "xmltree"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbc04313cab124e498ab1724e739720807b6dc405b9ed0edc5860164d2e4ff70"
|
||||
dependencies = [
|
||||
"xml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xz2"
|
||||
version = "0.1.7"
|
||||
|
||||
+6
-1
@@ -19,7 +19,9 @@ license = "GPL-3.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
anyhow = "1.0"
|
||||
askama = "0.14"
|
||||
base64 = "0.22"
|
||||
chrono = "0.4"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
clap-verbosity-flag = "3"
|
||||
ctrlc = "3.4"
|
||||
@@ -32,7 +34,7 @@ regex = "1"
|
||||
reqwest = { version = "0.12", features = ["native-tls", "json"] }
|
||||
openssl = "0.10"
|
||||
pem = "3"
|
||||
roxmltree = "0.21"
|
||||
xmltree = "0.12"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
# Use 0.36 as newer versions requires Rust 1.88+
|
||||
@@ -54,6 +56,9 @@ serde_urlencoded = "0.7"
|
||||
md5 = "0.8"
|
||||
sha256 = "1"
|
||||
which = "8"
|
||||
uuid = "1"
|
||||
netdev = "0.39"
|
||||
machine-uid = "0.5"
|
||||
|
||||
# Tauri dependencies
|
||||
tauri = { version = "2" }
|
||||
|
||||
@@ -136,6 +136,9 @@ install:
|
||||
install -Dm755 .build/gpgui/gpgui_*/gpgui $(DESTDIR)/usr/bin/gpgui; \
|
||||
fi
|
||||
|
||||
# Install the HIP report script
|
||||
install -Dm755 packaging/files/usr/libexec/gpclient/hipreport.sh $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
|
||||
|
||||
# Install the disconnect hooks
|
||||
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
|
||||
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:
|
||||
rm -f $(DESTDIR)/usr/bin/gpgui-helper
|
||||
rm -f $(DESTDIR)/usr/bin/gpgui
|
||||
|
||||
rm -f $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
|
||||
|
||||
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
|
||||
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ gpapi = { path = "../../crates/gpapi", features = ["clap"] }
|
||||
openconnect = { path = "../../crates/openconnect" }
|
||||
|
||||
anyhow.workspace = true
|
||||
askama.workspace = true
|
||||
chrono.workspace = true
|
||||
clap.workspace = true
|
||||
env_logger.workspace = true
|
||||
inquire = "0.9"
|
||||
@@ -19,11 +21,19 @@ log.workspace = true
|
||||
tokio = { workspace = true, features = ["rt-multi-thread"] }
|
||||
sysinfo.workspace = true
|
||||
serde_json.workspace = true
|
||||
serde_urlencoded.workspace = true
|
||||
whoami.workspace = true
|
||||
tempfile.workspace = true
|
||||
reqwest.workspace = true
|
||||
directories.workspace = true
|
||||
compile-time.workspace = true
|
||||
netdev.workspace = true
|
||||
xmltree.workspace = true
|
||||
|
||||
[target.'cfg(target_os="windows")'.dependencies]
|
||||
reqwest = { workspace = true, features = ["native-tls-vendored", "json"] }
|
||||
|
||||
[target.'cfg(target_family="unix")'.dependencies]
|
||||
reqwest.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["webview-auth"]
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{env::temp_dir, fs::File, str::FromStr};
|
||||
use anyhow::bail;
|
||||
use clap::{Parser, Subcommand};
|
||||
use gpapi::{
|
||||
clap::{handle_error, Args, InfoLevelVerbosity},
|
||||
clap::{Args, InfoLevelVerbosity, handle_error},
|
||||
utils::openssl,
|
||||
};
|
||||
use log::info;
|
||||
@@ -12,10 +12,11 @@ use tempfile::NamedTempFile;
|
||||
use tokio::fs;
|
||||
|
||||
use crate::{
|
||||
GP_CLIENT_LOCK_FILE,
|
||||
connect::{ConnectArgs, ConnectHandler},
|
||||
disconnect::{DisconnectArgs, DisconnectHandler},
|
||||
hip::{HipArgs, HipHandler},
|
||||
launch_gui::{LaunchGuiArgs, LaunchGuiHandler},
|
||||
GP_CLIENT_LOCK_FILE,
|
||||
};
|
||||
|
||||
const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")");
|
||||
@@ -34,6 +35,8 @@ enum CliCommand {
|
||||
Disconnect(DisconnectArgs),
|
||||
#[command(about = "Launch the GUI")]
|
||||
LaunchGui(LaunchGuiArgs),
|
||||
#[command(about = "Generate HIP report")]
|
||||
Hip(HipArgs),
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
@@ -132,6 +135,7 @@ impl Cli {
|
||||
CliCommand::Connect(args) => ConnectHandler::new(args, &shared_args).handle().await,
|
||||
CliCommand::Disconnect(args) => DisconnectHandler::new(args).handle().await,
|
||||
CliCommand::LaunchGui(args) => LaunchGuiHandler::new(args).handle().await,
|
||||
CliCommand::Hip(args) => HipHandler::new(args).handle().await,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use gpapi::{
|
||||
auth_launcher::SamlAuthLauncher,
|
||||
users::{get_non_root_user, get_user_by_name},
|
||||
},
|
||||
utils::{request::RequestIdentityError, shutdown_signal},
|
||||
utils::{host_utils, request::RequestIdentityError, shutdown_signal},
|
||||
};
|
||||
use inquire::{Password, PasswordDisplayMode, Select, Text};
|
||||
use log::{info, warn};
|
||||
@@ -130,18 +130,29 @@ pub(crate) struct ConnectArgs {
|
||||
|
||||
impl ConnectArgs {
|
||||
fn default_os() -> Os {
|
||||
if cfg!(target_os = "macos") { Os::Mac } else { Os::Linux }
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
Os::Mac
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
Os::Windows
|
||||
}
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
{
|
||||
Os::Linux
|
||||
}
|
||||
}
|
||||
|
||||
fn os_version(&self) -> String {
|
||||
fn os_version(&self) -> &str {
|
||||
if let Some(os_version) = self.os_version.as_deref() {
|
||||
return os_version.to_string();
|
||||
return os_version;
|
||||
}
|
||||
|
||||
match self.os {
|
||||
Os::Linux => format!("Linux {}", whoami::distro()),
|
||||
Os::Windows => String::from("Microsoft Windows 11 Pro , 64-bit"),
|
||||
Os::Mac => String::from("Apple Mac OS X 13.4.0"),
|
||||
Os::Linux => host_utils::get_linux_os_string(),
|
||||
Os::Windows => host_utils::get_windows_os_string(),
|
||||
Os::Mac => host_utils::get_macos_os_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,7 +178,7 @@ impl<'a> ConnectHandler<'a> {
|
||||
GpParams::builder()
|
||||
.user_agent(&self.args.user_agent)
|
||||
.client_os(ClientOs::from(&self.args.os))
|
||||
.os_version(self.args.os_version())
|
||||
.os_version(self.args.os_version().to_owned())
|
||||
.ignore_tls_errors(self.shared_args.ignore_tls_errors)
|
||||
.certificate(self.args.certificate.clone())
|
||||
.sslkey(self.args.sslkey.clone())
|
||||
|
||||
@@ -0,0 +1,381 @@
|
||||
use askama::Template;
|
||||
use clap::Args;
|
||||
use gpapi::utils::host_utils;
|
||||
use log::debug;
|
||||
use std::collections::HashMap;
|
||||
use xmltree::Element;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "hip_report.xml")]
|
||||
struct HipReportTemplate<'a> {
|
||||
client_version: &'a str,
|
||||
generate_time: String,
|
||||
day: String,
|
||||
month: String,
|
||||
year: String,
|
||||
md5: &'a str,
|
||||
user_name: &'a str,
|
||||
host_info: HostInfo,
|
||||
}
|
||||
|
||||
/// Host information for HIP reporting
|
||||
struct HostInfo {
|
||||
/// Only for macOS and Windows
|
||||
host_id: String,
|
||||
/// Common for all OSes
|
||||
host_name: String,
|
||||
os: &'static str,
|
||||
/// Only for macOS and Windows
|
||||
os_version: &'static str,
|
||||
os_vendor: &'static str,
|
||||
domain: String,
|
||||
network_interfaces: Vec<NetworkInterface>,
|
||||
}
|
||||
|
||||
impl HostInfo {
|
||||
/// Get the first available IPv4 address from network interfaces
|
||||
pub fn default_ipv4(&self) -> &str {
|
||||
self
|
||||
.network_interfaces
|
||||
.first()
|
||||
.and_then(|iface| iface.ipv4.as_deref())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Get the first available IPv6 address from network interfaces
|
||||
pub fn default_ipv6(&self) -> &str {
|
||||
self
|
||||
.network_interfaces
|
||||
.first()
|
||||
.and_then(|iface| iface.ipv6.as_deref())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Network interface information
|
||||
#[derive(Clone)]
|
||||
struct NetworkInterface {
|
||||
name: String,
|
||||
description: String,
|
||||
mac_address: Option<String>,
|
||||
ipv4: Option<String>,
|
||||
ipv6: Option<String>,
|
||||
}
|
||||
|
||||
impl NetworkInterface {
|
||||
/// Create a new network interface with basic information
|
||||
fn new(name: String, description: String) -> Self {
|
||||
Self {
|
||||
name,
|
||||
description,
|
||||
mac_address: None,
|
||||
ipv4: None,
|
||||
ipv6: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Set MAC address
|
||||
fn with_mac(mut self, mac: Option<String>) -> Self {
|
||||
self.mac_address = mac;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set IPv4 address
|
||||
fn with_ipv4(mut self, ipv4: Option<String>) -> Self {
|
||||
self.ipv4 = ipv4;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set IPv6 address
|
||||
fn with_ipv6(mut self, ipv6: Option<String>) -> Self {
|
||||
self.ipv6 = ipv6;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
pub(crate) struct HipArgs {
|
||||
#[arg(long, help = "The authentication cookie")]
|
||||
cookie: String,
|
||||
|
||||
#[arg(long, help = "The client IPv4 address")]
|
||||
client_ip: Option<String>,
|
||||
|
||||
#[arg(long, help = "The client IPv6 address")]
|
||||
client_ipv6: Option<String>,
|
||||
|
||||
#[arg(long, help = "The MD5 digest to encode into the HIP report")]
|
||||
md5: String,
|
||||
|
||||
#[arg(long, default_value = "Windows", help = "The client OS (Linux, Mac, or Windows)")]
|
||||
client_os: String,
|
||||
|
||||
#[arg(long, default_value = "", help = "The client software version")]
|
||||
client_version: String,
|
||||
}
|
||||
|
||||
pub(crate) struct HipHandler<'a> {
|
||||
args: &'a HipArgs,
|
||||
}
|
||||
|
||||
impl<'a> HipHandler<'a> {
|
||||
pub(crate) fn new(args: &'a HipArgs) -> Self {
|
||||
Self { args }
|
||||
}
|
||||
|
||||
pub(crate) async fn handle(&self) -> anyhow::Result<()> {
|
||||
self.validate_args()?;
|
||||
let cookie_params = self.parse_cookie();
|
||||
let report = self.generate_hip_report(&cookie_params)?;
|
||||
|
||||
debug!("Generated HIP report:\n{}", report);
|
||||
println!("{}", report);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Validate that at least one IP address is provided
|
||||
fn validate_args(&self) -> anyhow::Result<()> {
|
||||
if self.args.client_ip.is_none() && self.args.client_ipv6.is_none() {
|
||||
anyhow::bail!("At least one of --client-ip or --client-ipv6 must be provided");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_cookie(&self) -> HashMap<String, String> {
|
||||
// Parse URL-encoded cookie string using serde_urlencoded
|
||||
serde_urlencoded::from_str(&self.args.cookie).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Generate the complete HIP report XML
|
||||
fn generate_hip_report(&self, cookie_params: &HashMap<String, String>) -> anyhow::Result<String> {
|
||||
let (generate_time, day, month, year) = get_current_time_components();
|
||||
let user_name = cookie_params.get("user").map(|s| s.as_str()).unwrap_or("");
|
||||
let host_info = self.collect_host_info(cookie_params);
|
||||
let client_version = std::env::var("APP_VERSION")
|
||||
.map(|v| v.leak() as &'a str)
|
||||
.unwrap_or(&self.args.client_version);
|
||||
|
||||
let template = HipReportTemplate {
|
||||
client_version,
|
||||
generate_time,
|
||||
day,
|
||||
month,
|
||||
year,
|
||||
md5: &self.args.md5,
|
||||
user_name,
|
||||
host_info,
|
||||
};
|
||||
|
||||
let report = template.render()?;
|
||||
format_xml(&report)
|
||||
}
|
||||
|
||||
/// Collect host information based on the client OS
|
||||
fn collect_host_info(&self, cookie_params: &HashMap<String, String>) -> HostInfo {
|
||||
let collector = HostInfoCollector::new(self.args, cookie_params);
|
||||
|
||||
match self.args.client_os.as_str() {
|
||||
"Linux" => collector.collect_linux(),
|
||||
"Mac" => collector.collect_macos(),
|
||||
_ => collector.collect_windows(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Host Information Collector
|
||||
// ============================================================================
|
||||
|
||||
/// Helper struct for collecting host information
|
||||
struct HostInfoCollector<'a> {
|
||||
args: &'a HipArgs,
|
||||
cookie_params: &'a HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl<'a> HostInfoCollector<'a> {
|
||||
fn new(args: &'a HipArgs, cookie_params: &'a HashMap<String, String>) -> Self {
|
||||
Self { args, cookie_params }
|
||||
}
|
||||
|
||||
/// Get domain from cookie parameters
|
||||
fn get_domain(&self) -> String {
|
||||
self
|
||||
.cookie_params
|
||||
.get("domain")
|
||||
.map(|s| s.to_string())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Collect network interface information with fallback
|
||||
fn collect_network_interface(&self) -> NetworkInterface {
|
||||
match netdev::get_default_interface() {
|
||||
Ok(iface) => NetworkInterface::new(
|
||||
iface.name.clone(),
|
||||
iface.description.unwrap_or_else(|| iface.name.clone()),
|
||||
)
|
||||
.with_mac(iface.mac_addr.map(|mac| mac.address()))
|
||||
.with_ipv4(iface.ipv4.first().map(|ip| ip.addr().to_string()))
|
||||
.with_ipv6(iface.ipv6.first().map(|ip| ip.addr().to_string())),
|
||||
|
||||
Err(_) => NetworkInterface::new("unknown".to_string(), "unknown".to_string())
|
||||
.with_ipv4(self.args.client_ip.clone())
|
||||
.with_ipv6(self.args.client_ipv6.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Collect Linux-specific host information
|
||||
fn collect_linux(&self) -> HostInfo {
|
||||
let iface = self.collect_network_interface();
|
||||
|
||||
// Use the fixed interface name enp1s0f0 for Linux if it is not on Linux
|
||||
let iface = NetworkInterface {
|
||||
#[cfg(target_os = "linux")]
|
||||
name: iface.name,
|
||||
#[cfg(target_os = "linux")]
|
||||
description: iface.description,
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
name: "enp1s0f0".to_string(),
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
description: "enp1s0f0".to_string(),
|
||||
|
||||
mac_address: iface.mac_address,
|
||||
ipv4: iface.ipv4,
|
||||
ipv6: iface.ipv6,
|
||||
};
|
||||
|
||||
HostInfo {
|
||||
os_vendor: "Linux",
|
||||
host_id: host_utils::derive_uuid(&[]),
|
||||
os: host_utils::get_linux_os_string(),
|
||||
host_name: whoami::devicename(),
|
||||
os_version: "",
|
||||
domain: String::new(),
|
||||
network_interfaces: vec![iface],
|
||||
}
|
||||
}
|
||||
|
||||
/// Collect macOS-specific host information
|
||||
fn collect_macos(&self) -> HostInfo {
|
||||
let iface = self.collect_network_interface();
|
||||
// macOS use the mac address as host ID
|
||||
let host_id = iface
|
||||
.mac_address
|
||||
.as_ref()
|
||||
.map(|s| s.to_string())
|
||||
.unwrap_or_else(|| "00:00:00:00:00:00".to_string());
|
||||
|
||||
// Use the fixed interface name en0 for macOS if it is not on macOS
|
||||
let iface = NetworkInterface {
|
||||
#[cfg(target_os = "macos")]
|
||||
name: iface.name,
|
||||
#[cfg(target_os = "macos")]
|
||||
description: iface.description,
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
name: "en0".to_string(),
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
description: "en0".to_string(),
|
||||
|
||||
mac_address: iface.mac_address,
|
||||
ipv4: iface.ipv4,
|
||||
ipv6: iface.ipv6,
|
||||
};
|
||||
|
||||
HostInfo {
|
||||
os_vendor: "Apple",
|
||||
host_id,
|
||||
os: host_utils::get_macos_os_string(),
|
||||
host_name: whoami::devicename(),
|
||||
os_version: host_utils::get_macos_version(),
|
||||
domain: self.get_domain(),
|
||||
network_interfaces: vec![iface],
|
||||
}
|
||||
}
|
||||
|
||||
/// Collect Windows-specific host information
|
||||
fn collect_windows(&self) -> HostInfo {
|
||||
// Use the actual machine ID on Windows
|
||||
#[cfg(target_os = "windows")]
|
||||
let host_id = host_utils::get_machine_id().to_string();
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let host_id = host_utils::derive_uuid(&[]);
|
||||
|
||||
let iface = self.collect_network_interface();
|
||||
|
||||
// Use the fixed interface name if it is not on Windows
|
||||
let iface = NetworkInterface {
|
||||
#[cfg(target_os = "windows")]
|
||||
name: iface.name,
|
||||
#[cfg(target_os = "windows")]
|
||||
description: iface.description,
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
name: derive_windows_network_name(&iface),
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
description: "PANGP Virtual Ethernet Adapter Secure".to_string(),
|
||||
|
||||
// mac address on windows should replace ':' with '-'
|
||||
mac_address: iface.mac_address.map(|mac| mac.replace(':', "-")),
|
||||
ipv4: iface.ipv4,
|
||||
ipv6: iface.ipv6,
|
||||
};
|
||||
|
||||
// Add the local loopback interface
|
||||
let loopback_iface = NetworkInterface {
|
||||
name: derive_windows_network_name(&iface),
|
||||
description: "Software Loopback Interface 1".to_string(),
|
||||
mac_address: Some(String::new()),
|
||||
ipv4: Some("127.0.0.1".to_string()),
|
||||
ipv6: Some("::1".to_string()),
|
||||
};
|
||||
|
||||
let ifaces = vec![iface, loopback_iface];
|
||||
|
||||
HostInfo {
|
||||
os_vendor: "Microsoft",
|
||||
host_id,
|
||||
os: host_utils::get_windows_os_string(),
|
||||
host_name: whoami::devicename(),
|
||||
os_version: host_utils::get_windows_version(),
|
||||
domain: self.get_domain(),
|
||||
network_interfaces: ifaces,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Utility Functions
|
||||
// ============================================================================
|
||||
|
||||
/// Get current time components for HIP report
|
||||
fn get_current_time_components() -> (String, String, String, String) {
|
||||
let now = chrono::Local::now();
|
||||
(
|
||||
now.format("%m/%d/%Y %H:%M:%S").to_string(),
|
||||
now.format("%d").to_string(),
|
||||
now.format("%m").to_string(),
|
||||
now.format("%Y").to_string(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Format XML string with proper indentation
|
||||
fn format_xml(xml_str: &str) -> anyhow::Result<String> {
|
||||
let xml = Element::parse(xml_str.as_bytes())?;
|
||||
|
||||
let config = xmltree::EmitterConfig::new().perform_indent(true);
|
||||
let mut xml_buf = Vec::new();
|
||||
xml.write_with_config(&mut xml_buf, config)?;
|
||||
|
||||
Ok(String::from_utf8(xml_buf)?)
|
||||
}
|
||||
|
||||
fn derive_windows_network_name(iface: &NetworkInterface) -> String {
|
||||
let seeds = [
|
||||
iface.mac_address.as_deref().unwrap_or("00:00:00:00:00:00"),
|
||||
iface.name.as_str(),
|
||||
];
|
||||
|
||||
format!("{{{}}}", host_utils::derive_uuid(&seeds).to_uppercase())
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
mod cli;
|
||||
mod connect;
|
||||
mod disconnect;
|
||||
mod hip;
|
||||
mod launch_gui;
|
||||
|
||||
pub(crate) const GP_CLIENT_LOCK_FILE: &str = "/var/run/gpclient.lock";
|
||||
|
||||
@@ -0,0 +1,277 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<hip-report name="hip-report">
|
||||
<md5-sum>{{ md5 }}</md5-sum>
|
||||
<user-name>{{ user_name }}</user-name>
|
||||
<domain>{{ host_info.domain }}.internal</domain>
|
||||
<host-name>{{ host_info.host_name }}</host-name>
|
||||
<host-id>{{ host_info.host_id }}</host-id>
|
||||
<ip-address>{{ host_info.default_ipv4() }}</ip-address>
|
||||
<ipv6-address>{{ host_info.default_ipv6() }}</ipv6-address>
|
||||
<generate-time>{{ generate_time }}</generate-time>
|
||||
<hip-report-version>4</hip-report-version>
|
||||
<categories>
|
||||
<entry name="host-info">
|
||||
<client-version>{{ client_version }}</client-version>
|
||||
<os>{{ host_info.os }}</os>
|
||||
<os-vendor>{{ host_info.os_vendor }}</os-vendor>
|
||||
<domain>{{ host_info.domain }}.internal</domain>
|
||||
<host-name>{{ host_info.host_name }}</host-name>
|
||||
<host-id>{{ host_info.host_id }}</host-id>
|
||||
<network-interface>
|
||||
{% for iface in host_info.network_interfaces.iter() -%}
|
||||
<entry name="{{ iface.name }}">
|
||||
<description>{{ iface.description }}</description>
|
||||
{% if let Some(mac) = iface.mac_address -%}
|
||||
<mac-address>{{ mac }}</mac-address>
|
||||
{% endif -%}
|
||||
{% if let Some(ipv4) = iface.ipv4 -%}
|
||||
<ip-address>
|
||||
<entry name="{{ ipv4 }}"/>
|
||||
</ip-address>
|
||||
{% endif -%}
|
||||
{% if let Some(ipv6) = iface.ipv6 -%}
|
||||
<ipv6-address>
|
||||
<entry name="{{ ipv6 }}"/>
|
||||
</ipv6-address>
|
||||
{% endif -%}
|
||||
</entry>
|
||||
{% endfor -%}
|
||||
</network-interface>
|
||||
</entry>
|
||||
{% if host_info.os_vendor == "Microsoft" -%}
|
||||
<entry name="antivirus">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="McAfee VirusScan Enterprise" version="8.8.0.1804" defver="8682.0" prodType="1" engver="5900.7806" osType="1" vendor="McAfee, Inc." dateday="{{ day }}" dateyear="{{ year }}" datemon="{{ month }}">
|
||||
</Prod>
|
||||
<real-time-protection>yes</real-time-protection>
|
||||
<last-full-scan-time>{{ generate_time }}</last-full-scan-time>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="Windows Defender" version="4.11.15063.332" defver="1.245.683.0" prodType="1" engver="1.1.13804.0" osType="1" vendor="Microsoft Corp." dateday="{{ day }}" dateyear="{{ year }}" datemon="{{ month }}">
|
||||
</Prod>
|
||||
<real-time-protection>no</real-time-protection>
|
||||
<last-full-scan-time>n/a</last-full-scan-time>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="anti-spyware">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="McAfee VirusScan Enterprise" version="8.8.0.1804" defver="8682.0" prodType="2" engver="5900.7806" osType="1" vendor="McAfee, Inc." dateday="{{ day }}" dateyear="{{ year }}" datemon="{{ month }}">
|
||||
</Prod>
|
||||
<real-time-protection>yes</real-time-protection>
|
||||
<last-full-scan-time>{{ generate_time }}</last-full-scan-time>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="Windows Defender" version="4.11.15063.332" defver="1.245.683.0" prodType="2" engver="1.1.13804.0" osType="1" vendor="Microsoft Corp." dateday="{{ day }}" dateyear="{{ year }}" datemon="{{ month }}">
|
||||
</Prod>
|
||||
<real-time-protection>no</real-time-protection>
|
||||
<last-full-scan-time>n/a</last-full-scan-time>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="disk-backup">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="Windows Backup and Restore" version="{{ host_info.os_version }}" vendor="Microsoft Corp.">
|
||||
</Prod>
|
||||
<last-backup-time>n/a</last-backup-time>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="disk-encryption">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="Windows Drive Encryption" version="{{ host_info.os_version }}" vendor="Microsoft Corp.">
|
||||
</Prod>
|
||||
<drives>
|
||||
<entry>
|
||||
<drive-name>C:\\</drive-name>
|
||||
<enc-state>full</enc-state>
|
||||
</entry>
|
||||
</drives>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="firewall">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="Microsoft Windows Firewall" version="10.0" vendor="Microsoft Corp.">
|
||||
</Prod>
|
||||
<is-enabled>yes</is-enabled>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="patch-management">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="McAfee ePolicy Orchestrator Agent" version="5.0.5.658" vendor="McAfee, Inc.">
|
||||
</Prod>
|
||||
<is-enabled>yes</is-enabled>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="Microsoft Windows Update Agent" version="{{ host_info.os_version }}" vendor="Microsoft Corp.">
|
||||
</Prod>
|
||||
<is-enabled>yes</is-enabled>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
<missing-patches/>
|
||||
</entry>
|
||||
{% elif host_info.os_vendor == "Apple" -%}
|
||||
<entry name="anti-malware">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod vendor="Apple Inc." name="Xprotect" version="2167" defver="235000000000000" engver="" datemon="{{ month }}" dateday="{{ day }}" dateyear="{{ year }}" prodType="3" osType="4"/>
|
||||
<real-time-protection>yes</real-time-protection>
|
||||
<last-full-scan-time>n/a</last-full-scan-time>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod vendor="Apple Inc." name="Gatekeeper" version="{{ host_info.os_version }}" defver="" engver="" datemon="{{ month }}" dateday="{{ day }}" dateyear="{{ year }}" prodType="3" osType="4"/>
|
||||
<real-time-protection>yes</real-time-protection>
|
||||
<last-full-scan-time>n/a</last-full-scan-time>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="disk-backup">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod vendor="Apple Inc." name="Time Machine" version="1.3"/>
|
||||
<last-backup-time>n/a</last-backup-time>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="disk-encryption">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod vendor="Apple Inc." name="FileVault" version="{{ host_info.os_version }}"/>
|
||||
<drives>
|
||||
<entry>
|
||||
<drive-name>Macintosh HD</drive-name>
|
||||
<enc-state>encrypted</enc-state>
|
||||
</entry>
|
||||
<entry>
|
||||
<drive-name>Data</drive-name>
|
||||
<enc-state>encrypted</enc-state>
|
||||
</entry>
|
||||
<entry>
|
||||
<drive-name>All</drive-name>
|
||||
<enc-state>encrypted</enc-state>
|
||||
</entry>
|
||||
</drives>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="firewall">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod vendor="Apple Inc." name="Mac OS X Builtin Firewall" version="{{ host_info.os_version }}"/>
|
||||
<is-enabled>yes</is-enabled>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod vendor="OpenBSD" name="Packet Filter" version="{{ host_info.os_version }}"/>
|
||||
<is-enabled>no</is-enabled>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="patch-management">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod vendor="Apple Inc." name="Software Update" version="3.0"/>
|
||||
<is-enabled>yes</is-enabled>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
<missing-patches>
|
||||
</missing-patches>
|
||||
</entry>
|
||||
{% elif host_info.os_vendor == "Linux" -%}
|
||||
<entry name="anti-malware">
|
||||
<list/>
|
||||
</entry>
|
||||
<entry name="disk-backup">
|
||||
<list/>
|
||||
</entry>
|
||||
<entry name="disk-encryption">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="cryptsetup" version="2.3.3" vendor="GitLab Inc.">
|
||||
</Prod>
|
||||
<drives>
|
||||
<entry>
|
||||
<drive-name>/</drive-name>
|
||||
<enc-state>encrypted</enc-state>
|
||||
</entry>
|
||||
</drives>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="firewall">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="IPTables" version="1.8.4" vendor="IPTables">
|
||||
</Prod>
|
||||
<is-enabled>no</is-enabled>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="nftables" version="0.9.3" vendor="The Netfilter Project">
|
||||
</Prod>
|
||||
<is-enabled>n/a</is-enabled>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
</entry>
|
||||
<entry name="patch-management">
|
||||
<list>
|
||||
<entry>
|
||||
<ProductInfo>
|
||||
<Prod name="Dandified Yum" version="4.2.23" vendor="Red Hat, Inc.">
|
||||
</Prod>
|
||||
<is-enabled>yes</is-enabled>
|
||||
</ProductInfo>
|
||||
</entry>
|
||||
</list>
|
||||
<missing-patches/>
|
||||
</entry>
|
||||
{% endif -%}
|
||||
<entry name="data-loss-prevention">
|
||||
<list/>
|
||||
</entry>
|
||||
</categories>
|
||||
</hip-report>
|
||||
@@ -21,7 +21,12 @@ compile-time.workspace = true
|
||||
env_logger.workspace = true
|
||||
futures-util.workspace = true
|
||||
tempfile.workspace = true
|
||||
reqwest = { workspace = true, features = ["stream"] }
|
||||
|
||||
[target.'cfg(target_os="windows")'.dependencies]
|
||||
reqwest = { workspace = true, features = ["native-tls-vendored", "stream"] }
|
||||
|
||||
[target.'cfg(target_family="unix")'.dependencies]
|
||||
reqwest = { workspace = true, features = ["native-tls", "stream"] }
|
||||
|
||||
[features]
|
||||
default = ["tauri/custom-protocol"]
|
||||
+12
-2
@@ -29,15 +29,21 @@ regex = { workspace = true, optional = true }
|
||||
tokio-util = { workspace = true, optional = true }
|
||||
html-escape = { version = "0.2.13", optional = true }
|
||||
|
||||
[target.'cfg(not(target_os = "macos"))'.dependencies]
|
||||
[target.'cfg(not(any(target_os="macos", target_os="windows")))'.dependencies]
|
||||
webkit2gtk = { version = "2", optional = true }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
[target.'cfg(target_os="macos")'.dependencies]
|
||||
block2 = { version = "0.6", optional = true }
|
||||
objc2 = { version = "0.6", optional = true }
|
||||
objc2-foundation = { version = "0.3", optional = true }
|
||||
objc2-web-kit = { version = "0.3", optional = true }
|
||||
|
||||
[target.'cfg(target_os="windows")'.dependencies]
|
||||
webview2-com = { version = "0.34", optional = true }
|
||||
windows-core = { version = "0.58", optional = true }
|
||||
windows = { version = "0.58", optional = true }
|
||||
serde_json = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
browser-auth = [
|
||||
"dep:webbrowser",
|
||||
@@ -57,4 +63,8 @@ webview-auth = [
|
||||
"dep:objc2",
|
||||
"dep:objc2-foundation",
|
||||
"dep:objc2-web-kit",
|
||||
"dep:webview2-com",
|
||||
"dep:windows-core",
|
||||
"dep:windows",
|
||||
"dep:serde_json",
|
||||
]
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{env::temp_dir, fs, os::unix::fs::PermissionsExt};
|
||||
use std::{env::temp_dir, fs};
|
||||
|
||||
use common::constants::GP_CALLBACK_PORT_FILENAME;
|
||||
use gpapi::auth::SamlAuthData;
|
||||
@@ -145,7 +145,11 @@ async fn wait_auth_data() -> anyhow::Result<SamlAuthData> {
|
||||
|
||||
// Write the port to a file
|
||||
fs::write(&port_file, port.to_string())?;
|
||||
fs::set_permissions(&port_file, fs::Permissions::from_mode(0o600))?;
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use os::unix::fs::PermissionsExt;
|
||||
fs::set_permissions(&port_file, fs::Permissions::from_mode(0o600))?;
|
||||
}
|
||||
|
||||
// Remove the previous log file
|
||||
let callback_log = temp_dir().join("gpcallback.log");
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
mod auth_messenger;
|
||||
mod webview_auth;
|
||||
|
||||
#[cfg_attr(not(target_os = "macos"), path = "webview/unix.rs")]
|
||||
#[cfg_attr(not(any(target_os = "macos", target_os = "windows")), path = "webview/unix.rs")]
|
||||
#[cfg_attr(target_os = "macos", path = "webview/macos.rs")]
|
||||
#[cfg_attr(windows, path = "webview/windows.rs")]
|
||||
mod platform_impl;
|
||||
|
||||
pub use webview_auth::WebviewAuthenticator;
|
||||
@@ -15,7 +15,7 @@ pub(crate) enum AuthDataLocation {
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum AuthError {
|
||||
/// Failed to load page due to TLS error
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
TlsError,
|
||||
/// 1. Found auth data in headers/body but it's invalid
|
||||
/// 2. Loaded an empty page, failed to load page. etc.
|
||||
|
||||
@@ -116,7 +116,7 @@ impl<'a> WebviewAuthenticator<'a> {
|
||||
match auth_messenger.subscribe().await? {
|
||||
AuthEvent::Close => bail!("Authentication cancelled"),
|
||||
AuthEvent::RaiseWindow => self.raise_window(&auth_window),
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
AuthEvent::Error(AuthError::TlsError) => bail!(gpapi::error::PortalError::TlsError),
|
||||
AuthEvent::Error(AuthError::NotFound(location)) => {
|
||||
info!(
|
||||
@@ -262,10 +262,10 @@ impl<'a> WebviewAuthenticator<'a> {
|
||||
|
||||
info!("Raising auth window...");
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
let result = auth_window.show();
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
let result = {
|
||||
use gpapi::utils::window::WindowExt;
|
||||
auth_window.raise()
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
use log::warn;
|
||||
use tauri::webview::PlatformWebview;
|
||||
use webview2_com::{
|
||||
pwstr_from_str, take_pwstr, ExecuteScriptCompletedHandler,
|
||||
Microsoft::Web::WebView2::Win32::{
|
||||
ICoreWebView2WebResourceResponseView, ICoreWebView2_14, ICoreWebView2_2,
|
||||
COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_ALWAYS_ALLOW,
|
||||
},
|
||||
ServerCertificateErrorDetectedEventHandler, WebResourceResponseReceivedEventHandler,
|
||||
};
|
||||
use windows_core::{Interface, PWSTR};
|
||||
|
||||
use super::{
|
||||
auth_messenger::AuthError,
|
||||
webview_auth::{GetHeader, PlatformWebviewExt},
|
||||
};
|
||||
|
||||
impl PlatformWebviewExt for PlatformWebview {
|
||||
fn ignore_tls_errors(&self) -> anyhow::Result<()> {
|
||||
unsafe {
|
||||
let wv = self.controller().CoreWebView2()?.cast::<ICoreWebView2_14>()?;
|
||||
let handler = ServerCertificateErrorDetectedEventHandler::create(Box::new(|_, e| {
|
||||
if let Some(e) = e {
|
||||
let _ = e.SetAction(COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_ALWAYS_ALLOW);
|
||||
}
|
||||
Ok(())
|
||||
}));
|
||||
|
||||
wv.add_ServerCertificateErrorDetected(&handler, &mut Default::default())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn load_url(&self, url: &str) -> anyhow::Result<()> {
|
||||
let url = pwstr_from_str(url);
|
||||
|
||||
unsafe { self.controller().CoreWebView2()?.Navigate(url)? }
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn load_html(&self, html: &str) -> anyhow::Result<()> {
|
||||
let html = pwstr_from_str(html);
|
||||
|
||||
unsafe { self.controller().CoreWebView2()?.NavigateToString(html)? }
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_html(&self, callback: Box<dyn Fn(anyhow::Result<String>) + 'static>) {
|
||||
unsafe {
|
||||
match self.controller().CoreWebView2() {
|
||||
Ok(wv) => {
|
||||
let js = "document.documentElement.outerHTML";
|
||||
let js = pwstr_from_str(js);
|
||||
|
||||
let handler = ExecuteScriptCompletedHandler::create(Box::new(move |err, html| {
|
||||
if let Err(err) = err {
|
||||
callback(Err(anyhow::anyhow!(err)));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// The returned HTML is JSON.stringify'd string, so we need to parse it
|
||||
let res = match serde_json::from_str(&html) {
|
||||
Ok(Some(html)) => Ok(html),
|
||||
Ok(None) => Err(anyhow::anyhow!("No HTML returned")),
|
||||
Err(err) => Err(anyhow::anyhow!(err)),
|
||||
};
|
||||
callback(res);
|
||||
|
||||
Ok(())
|
||||
}));
|
||||
|
||||
if let Err(err) = wv.ExecuteScript(js, &handler) {
|
||||
warn!("Failed to execute script: {}", err);
|
||||
}
|
||||
}
|
||||
Err(err) => callback(Err(anyhow::anyhow!(err))),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GetHeader for ICoreWebView2WebResourceResponseView {
|
||||
fn get_header(&self, key: &str) -> Option<String> {
|
||||
unsafe {
|
||||
let headers = self.Headers().ok()?;
|
||||
let key = pwstr_from_str(key);
|
||||
|
||||
let mut contains = Default::default();
|
||||
headers.Contains(key, &mut contains).ok()?;
|
||||
|
||||
if contains.as_bool() {
|
||||
let mut value = PWSTR::null();
|
||||
headers.GetHeader(key, &mut value).ok()?;
|
||||
let value = take_pwstr(value);
|
||||
|
||||
Some(value)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PlatformWebviewOnResponse {
|
||||
fn on_response(
|
||||
&self,
|
||||
callback: Box<dyn Fn(anyhow::Result<ICoreWebView2WebResourceResponseView, AuthError>) + 'static>,
|
||||
);
|
||||
}
|
||||
|
||||
impl PlatformWebviewOnResponse for PlatformWebview {
|
||||
fn on_response(
|
||||
&self,
|
||||
callback: Box<dyn Fn(anyhow::Result<ICoreWebView2WebResourceResponseView, AuthError>) + 'static>,
|
||||
) {
|
||||
unsafe {
|
||||
let _ = self
|
||||
.controller()
|
||||
.CoreWebView2()
|
||||
.and_then(|wv| wv.cast::<ICoreWebView2_2>())
|
||||
.map(|wv| {
|
||||
let handler = WebResourceResponseReceivedEventHandler::create(Box::new(move |_, e| {
|
||||
let Some(e) = e else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
match e.Response() {
|
||||
Ok(res) => callback(Ok(res)),
|
||||
Err(err) => warn!("Failed to get response: {}", err),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}));
|
||||
|
||||
let _ = wv.add_WebResourceResponseReceived(&handler, &mut Default::default());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
pub const GP_USER_AGENT: &str = "PAN GlobalProtect";
|
||||
pub const GP_CLIENT_VERSION: &str = "6.3.0-33";
|
||||
pub const GP_SERVICE_LOCK_FILE: &str = "/var/run/gpservice.lock";
|
||||
pub const GP_CALLBACK_PORT_FILENAME: &str = "gpcallback.port";
|
||||
|
||||
|
||||
+20
-4
@@ -11,11 +11,9 @@ anyhow.workspace = true
|
||||
base64.workspace = true
|
||||
dns-lookup.workspace = true
|
||||
log.workspace = true
|
||||
reqwest.workspace = true
|
||||
openssl.workspace = true
|
||||
version-compare = "0.2"
|
||||
pem.workspace = true
|
||||
roxmltree.workspace = true
|
||||
xmltree.workspace = true
|
||||
serde.workspace = true
|
||||
specta = { workspace = true, features = ["derive"] }
|
||||
urlencoding.workspace = true
|
||||
@@ -28,11 +26,14 @@ chacha20poly1305 = { version = "0.10", features = ["std"] }
|
||||
redact-engine.workspace = true
|
||||
url.workspace = true
|
||||
regex.workspace = true
|
||||
uzers.workspace = true
|
||||
|
||||
serde_urlencoded.workspace = true
|
||||
md5.workspace = true
|
||||
sha256.workspace = true
|
||||
machine-uid.workspace = true
|
||||
uuid = { workspace = true, features = ["v5"] }
|
||||
|
||||
# Optional dependencies for features
|
||||
tauri = { workspace = true, optional = true }
|
||||
clap = { workspace = true, optional = true }
|
||||
clap-verbosity-flag = { workspace = true, optional = true }
|
||||
@@ -40,9 +41,24 @@ clap-verbosity-flag = { workspace = true, optional = true }
|
||||
env_logger = { workspace = true, optional = true }
|
||||
log-reload = { version = "0.1", optional = true }
|
||||
|
||||
# Dependencies for macOS and Windows only
|
||||
[target.'cfg(any(target_os="macos", target_os="windows"))'.dependencies]
|
||||
os_info = { version = "3", default-features = false }
|
||||
|
||||
# Dependencies for Linux and other OSes only
|
||||
[target.'cfg(not(any(target_os="macos", target_os="windows")))'.dependencies]
|
||||
gtk = "0.18"
|
||||
|
||||
[target.'cfg(target_os="windows")'.dependencies]
|
||||
reqwest = { workspace = true, features = ["native-tls-vendored", "json"] }
|
||||
openssl = { workspace = true, features = ["vendored"] }
|
||||
|
||||
# Dependencies for Unix-like systems only
|
||||
[target.'cfg(target_family="unix")'.dependencies]
|
||||
reqwest.workspace = true
|
||||
openssl.workspace = true
|
||||
uzers.workspace = true
|
||||
|
||||
[features]
|
||||
tauri = ["dep:tauri"]
|
||||
clap = ["dep:clap", "dep:clap-verbosity-flag"]
|
||||
|
||||
@@ -104,7 +104,7 @@ impl SamlAuthData {
|
||||
}
|
||||
|
||||
let auth_data = decode_to_string(auth_data).map_err(|e| {
|
||||
warn!("Failed to decode SAML auth data: {}", e);
|
||||
warn!("Failed to decode SAML auth data: {}", auth_data);
|
||||
AuthDataParseError::Invalid(anyhow::anyhow!(e))
|
||||
})?;
|
||||
let auth_data = Self::from_html(&auth_data)?;
|
||||
|
||||
@@ -2,9 +2,13 @@ use std::collections::HashMap;
|
||||
|
||||
use log::{info, warn};
|
||||
use reqwest::Client;
|
||||
use roxmltree::Document;
|
||||
use xmltree::Element;
|
||||
|
||||
use crate::{gp_params::GpParams, process::hip_launcher::HipLauncher, utils::normalize_server};
|
||||
use crate::{
|
||||
gp_params::GpParams,
|
||||
process::hip_launcher::HipLauncher,
|
||||
utils::{normalize_server, xml::ElementExt},
|
||||
};
|
||||
|
||||
struct HipReporter<'a> {
|
||||
server: String,
|
||||
@@ -65,13 +69,11 @@ impl HipReporter<'_> {
|
||||
|
||||
let res = self.client.post(&config_url).form(¶ms).send().await?;
|
||||
let res_xml = res.error_for_status()?.text().await?;
|
||||
let doc = Document::parse(&res_xml)?;
|
||||
let root = Element::parse(res_xml.as_bytes())?;
|
||||
|
||||
// Get <ip-address>
|
||||
let ip = doc
|
||||
.descendants()
|
||||
.find(|n| n.has_tag_name("ip-address"))
|
||||
.and_then(|n| n.text())
|
||||
let ip = root
|
||||
.descendant_text("ip-address")
|
||||
.ok_or_else(|| anyhow::anyhow!("ip-address not found"))?;
|
||||
|
||||
Ok(ip.to_string())
|
||||
@@ -122,12 +124,9 @@ impl HipReporter<'_> {
|
||||
}
|
||||
|
||||
fn is_hip_needed(res_xml: &str) -> anyhow::Result<bool> {
|
||||
let doc = Document::parse(res_xml)?;
|
||||
|
||||
let hip_needed = doc
|
||||
.descendants()
|
||||
.find(|n| n.has_tag_name("hip-report-needed"))
|
||||
.and_then(|n| n.text())
|
||||
let root = Element::parse(res_xml.as_bytes())?;
|
||||
let hip_needed = root
|
||||
.descendant_text("hip-report-needed")
|
||||
.ok_or_else(|| anyhow::anyhow!("hip-report-needed not found"))?;
|
||||
|
||||
Ok(hip_needed == "yes")
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use anyhow::bail;
|
||||
use log::{info, warn};
|
||||
use log::{debug, info, warn};
|
||||
use reqwest::Client;
|
||||
use roxmltree::Document;
|
||||
use urlencoding::encode;
|
||||
use xmltree::Element;
|
||||
|
||||
use crate::{
|
||||
credential::Credential,
|
||||
error::PortalError,
|
||||
gp_params::GpParams,
|
||||
utils::{normalize_server, parse_gp_response, remove_url_scheme},
|
||||
utils::{normalize_server, parse_gp_response, remove_url_scheme, xml::ElementExt},
|
||||
};
|
||||
|
||||
pub enum GatewayLogin {
|
||||
@@ -50,18 +52,20 @@ pub async fn gateway_login(gateway: &str, cred: &Credential, gp_params: &GpParam
|
||||
return Ok(GatewayLogin::Mfa(message, input_str));
|
||||
}
|
||||
|
||||
let doc = Document::parse(&res)?;
|
||||
debug!("Gateway login response: {}", res);
|
||||
|
||||
let cookie = build_gateway_token(&doc, gp_params.computer())?;
|
||||
let root = Element::parse(res.as_bytes())?;
|
||||
|
||||
let cookie = build_gateway_token(&root, gp_params.computer())?;
|
||||
|
||||
Ok(GatewayLogin::Cookie(cookie))
|
||||
}
|
||||
|
||||
fn build_gateway_token(doc: &Document, computer: &str) -> anyhow::Result<String> {
|
||||
let args = doc
|
||||
.descendants()
|
||||
.filter(|n| n.has_tag_name("argument"))
|
||||
.map(|n| n.text().unwrap_or("").to_string())
|
||||
fn build_gateway_token(element: &Element, computer: &str) -> anyhow::Result<String> {
|
||||
let args = element
|
||||
.descendants("argument")
|
||||
.iter()
|
||||
.map(|e| e.get_text().unwrap_or_default())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let params = [
|
||||
@@ -82,7 +86,7 @@ fn build_gateway_token(doc: &Document, computer: &str) -> anyhow::Result<String>
|
||||
Ok(token)
|
||||
}
|
||||
|
||||
fn read_args<'a>(args: &'a [String], index: usize, key: &'a str) -> anyhow::Result<(&'a str, &'a str)> {
|
||||
fn read_args<'a>(args: &'a [Cow<'_, str>], index: usize, key: &'a str) -> anyhow::Result<(&'a str, &'a str)> {
|
||||
args
|
||||
.get(index)
|
||||
.ok_or_else(|| anyhow::anyhow!("Failed to read {key} from args"))
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
mod login;
|
||||
mod parse_gateways;
|
||||
|
||||
#[cfg(unix)]
|
||||
pub mod hip;
|
||||
|
||||
pub use login::*;
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
use log::info;
|
||||
use roxmltree::Node;
|
||||
use xmltree::Element;
|
||||
|
||||
use crate::utils::xml::NodeExt;
|
||||
use crate::utils::xml::ElementExt;
|
||||
|
||||
use super::{Gateway, PriorityRule};
|
||||
|
||||
pub(crate) fn parse_gateways(node: &Node, prefer_internal: bool) -> Option<Vec<Gateway>> {
|
||||
let node_gateways = node.find_descendant("gateways")?;
|
||||
pub(crate) fn parse_gateways(element: &Element, prefer_internal: bool) -> Option<Vec<Gateway>> {
|
||||
let node_gateways = element.descendant("gateways")?;
|
||||
let internal_gateway_list = if prefer_internal {
|
||||
info!("Try to parse the internal gateways...");
|
||||
node_gateways.find_descendant("internal").and_then(|n| n.find_child("list"))
|
||||
node_gateways.descendant("internal").and_then(|n| n.child("list"))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let gateway_list = internal_gateway_list.or_else(|| {
|
||||
info!("Try to parse the external gateways...");
|
||||
node_gateways.find_descendant("external").and_then(|n| n.find_child("list"))
|
||||
node_gateways.descendant("external").and_then(|n| n.child("list"))
|
||||
})?;
|
||||
|
||||
let gateways = gateway_list
|
||||
.children()
|
||||
.filter_map(|gateway_item| {
|
||||
if !gateway_item.has_tag_name("entry") {
|
||||
return None;
|
||||
}
|
||||
let address = gateway_item.attribute("name").unwrap_or_default().to_string();
|
||||
let name = gateway_item.child_text("description").unwrap_or_default().to_string();
|
||||
let priority = gateway_item
|
||||
.child_text("priority")
|
||||
.and_then(|s| s.parse().ok())
|
||||
.unwrap_or(u32::MAX);
|
||||
.children("entry")
|
||||
.iter()
|
||||
.map(|gateway_item| {
|
||||
let address = gateway_item.attr("name").map(|s| s.to_string()).unwrap_or_default();
|
||||
let name = gateway_item.child_text("description").unwrap_or_default();
|
||||
let priority = parse_priority(gateway_item);
|
||||
let priority_rules = gateway_item
|
||||
.find_child("priority-rule")
|
||||
.map(|n| {
|
||||
n.children()
|
||||
.filter_map(|n| {
|
||||
if !n.has_tag_name("entry") {
|
||||
return None;
|
||||
}
|
||||
let name = n.attribute("name").unwrap_or_default().to_string();
|
||||
let priority: u32 = n
|
||||
.child_text("priority")
|
||||
.and_then(|s| s.parse().ok())
|
||||
.unwrap_or(u32::MAX);
|
||||
|
||||
Some(PriorityRule { name, priority })
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.child("priority-rule")
|
||||
.map(|n| parse_priority_rules(n))
|
||||
.unwrap_or_default();
|
||||
|
||||
Some(Gateway {
|
||||
Gateway {
|
||||
name,
|
||||
address,
|
||||
priority,
|
||||
priority_rules,
|
||||
})
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
Some(gateways)
|
||||
}
|
||||
|
||||
fn parse_priority_rules(element: &Element) -> Vec<PriorityRule> {
|
||||
element
|
||||
.children("entry")
|
||||
.iter()
|
||||
.map(|n| {
|
||||
let name = n.attr("name").map(|s| s.to_string()).unwrap_or_default();
|
||||
let priority: u32 = parse_priority(n);
|
||||
|
||||
PriorityRule { name, priority }
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn parse_priority(element: &Element) -> u32 {
|
||||
element
|
||||
.child_text("priority")
|
||||
.and_then(|s| s.parse().ok())
|
||||
.unwrap_or(u32::MAX)
|
||||
}
|
||||
@@ -4,7 +4,10 @@ pub mod error;
|
||||
pub mod gateway;
|
||||
pub mod gp_params;
|
||||
pub mod portal;
|
||||
|
||||
#[cfg(unix)]
|
||||
pub mod process;
|
||||
|
||||
pub mod service;
|
||||
pub mod utils;
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@ use anyhow::bail;
|
||||
use dns_lookup::lookup_addr;
|
||||
use log::{debug, info, warn};
|
||||
use reqwest::{Client, StatusCode};
|
||||
use roxmltree::{Document, Node};
|
||||
use serde::Serialize;
|
||||
use specta::Type;
|
||||
use xmltree::Element;
|
||||
|
||||
use crate::{
|
||||
credential::{AuthCookieCredential, Credential},
|
||||
error::PortalError,
|
||||
gateway::{Gateway, parse_gateways},
|
||||
gp_params::GpParams,
|
||||
utils::{normalize_server, parse_gp_response, remove_url_scheme, xml::NodeExt},
|
||||
utils::{normalize_server, parse_gp_response, remove_url_scheme, xml::ElementExt},
|
||||
};
|
||||
|
||||
#[derive(Debug, Serialize, Type)]
|
||||
@@ -142,12 +142,11 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara
|
||||
}
|
||||
|
||||
debug!("Portal config response: {}", res_xml);
|
||||
let doc = Document::parse(&res_xml).map_err(|e| PortalError::ConfigError(e.to_string()))?;
|
||||
let root = doc.root();
|
||||
let root = Element::parse(res_xml.as_bytes()).map_err(|e| PortalError::ConfigError(e.to_string()))?;
|
||||
|
||||
let mut ihd_enabled = false;
|
||||
let mut prefer_internal = false;
|
||||
if let Some(ihd_node) = root.find_descendant("internal-host-detection") {
|
||||
if let Some(ihd_node) = root.descendant("internal-host-detection") {
|
||||
ihd_enabled = true;
|
||||
prefer_internal = internal_host_detect(&ihd_node)
|
||||
}
|
||||
@@ -172,7 +171,7 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara
|
||||
|
||||
Ok(PortalConfig {
|
||||
portal: server.to_string(),
|
||||
auth_cookie: AuthCookieCredential::new(cred.username(), user_auth_cookie, prelogon_user_auth_cookie),
|
||||
auth_cookie: AuthCookieCredential::new(cred.username(), &user_auth_cookie, &prelogon_user_auth_cookie),
|
||||
config_cred: cred.clone(),
|
||||
gateways,
|
||||
config_digest: config_digest.map(|s| s.to_string()),
|
||||
@@ -182,10 +181,10 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara
|
||||
}
|
||||
|
||||
// Perform DNS lookup and compare the result with the expected hostname
|
||||
fn internal_host_detect(node: &Node) -> bool {
|
||||
fn internal_host_detect(element: &Element) -> bool {
|
||||
let ip_info = [
|
||||
(node.child_text("ip-address"), node.child_text("host")),
|
||||
(node.child_text("ipv6-address"), node.child_text("ipv6-host")),
|
||||
(element.child_text("ip-address"), element.child_text("host")),
|
||||
(element.child_text("ipv6-address"), element.child_text("ipv6-host")),
|
||||
];
|
||||
|
||||
info!("Found internal-host-detection, performing DNS lookup");
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use anyhow::{anyhow, bail};
|
||||
use log::{info, warn};
|
||||
use reqwest::{Client, StatusCode};
|
||||
use roxmltree::Document;
|
||||
use serde::Serialize;
|
||||
use specta::Type;
|
||||
use xmltree::Element;
|
||||
|
||||
use crate::{
|
||||
error::PortalError,
|
||||
gp_params::GpParams,
|
||||
utils::{base64, normalize_server, parse_gp_response, xml::NodeExt},
|
||||
utils::{base64, normalize_server, parse_gp_response, xml::ElementExt},
|
||||
};
|
||||
|
||||
const REQUIRED_PARAMS: [&str; 8] = [
|
||||
@@ -143,32 +143,30 @@ pub async fn prelogin(portal: &str, gp_params: &GpParams) -> anyhow::Result<Prel
|
||||
}
|
||||
|
||||
fn parse_res_xml(res_xml: &str, is_gateway: bool) -> anyhow::Result<Prelogin> {
|
||||
let doc = Document::parse(res_xml)?;
|
||||
let root = doc.root();
|
||||
let root = Element::parse(res_xml.as_bytes())?;
|
||||
|
||||
let status = root
|
||||
.descendant_text("status")
|
||||
.ok_or_else(|| anyhow::anyhow!("Prelogin response does not contain status element"))?;
|
||||
// Check the status of the prelogin response
|
||||
if status.to_uppercase() != "SUCCESS" {
|
||||
let msg = root.descendant_text("msg").unwrap_or("Unknown error");
|
||||
let msg = root
|
||||
.descendant_text("msg")
|
||||
.unwrap_or_else(|| String::from("Unknown error"));
|
||||
bail!("{}", msg)
|
||||
}
|
||||
|
||||
let region = root
|
||||
.descendant_text("region")
|
||||
.unwrap_or_else(|| {
|
||||
info!("Prelogin response does not contain region element");
|
||||
"Unknown"
|
||||
})
|
||||
.to_string();
|
||||
let region = root.descendant_text("region").unwrap_or_else(|| {
|
||||
info!("Prelogin response does not contain region element");
|
||||
String::from("Unknown")
|
||||
});
|
||||
|
||||
let saml_method = root.descendant_text("saml-auth-method");
|
||||
let saml_request = root.descendant_text("saml-request");
|
||||
let saml_default_browser = root.descendant_text("saml-default-browser");
|
||||
// Check if the prelogin response is SAML
|
||||
if saml_method.is_some() && saml_request.is_some() {
|
||||
let saml_request = base64::decode_to_string(saml_request.unwrap())?;
|
||||
let saml_request = base64::decode_to_string(&saml_request.unwrap())?;
|
||||
let support_default_browser = saml_default_browser.map(|s| s.to_lowercase() == "yes").unwrap_or(false);
|
||||
|
||||
let saml_prelogin = SamlPrelogin {
|
||||
@@ -181,25 +179,18 @@ fn parse_res_xml(res_xml: &str, is_gateway: bool) -> anyhow::Result<Prelogin> {
|
||||
return Ok(Prelogin::Saml(saml_prelogin));
|
||||
}
|
||||
|
||||
let label_username = root
|
||||
.descendant_text("username-label")
|
||||
.unwrap_or_else(|| {
|
||||
info!("Username label has no value, using default");
|
||||
"Username"
|
||||
})
|
||||
.to_string();
|
||||
let label_password = root
|
||||
.descendant_text("password-label")
|
||||
.unwrap_or_else(|| {
|
||||
info!("Password label has no value, using default");
|
||||
"Password"
|
||||
})
|
||||
.to_string();
|
||||
let label_username = root.descendant_text("username-label").unwrap_or_else(|| {
|
||||
info!("Username label has no value, using default");
|
||||
String::from("Username")
|
||||
});
|
||||
let label_password = root.descendant_text("password-label").unwrap_or_else(|| {
|
||||
info!("Password label has no value, using default");
|
||||
String::from("Password")
|
||||
});
|
||||
|
||||
let auth_message = root
|
||||
.descendant_text("authentication-message")
|
||||
.unwrap_or("Please enter the login credentials")
|
||||
.to_string();
|
||||
.unwrap_or_else(|| String::from("Please enter the login credentials"));
|
||||
let standard_prelogin = StandardPrelogin {
|
||||
region,
|
||||
is_gateway,
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
pub(crate) mod command_traits;
|
||||
|
||||
pub(crate) mod gui_helper_launcher;
|
||||
|
||||
pub mod auth_launcher;
|
||||
pub mod gui_launcher;
|
||||
pub mod hip_launcher;
|
||||
pub mod service_launcher;
|
||||
|
||||
#[cfg(unix)]
|
||||
pub mod users;
|
||||
@@ -0,0 +1,108 @@
|
||||
use std::sync::OnceLock;
|
||||
|
||||
const DEFAULT_MACOS_VERSION: &str = "13.4.0";
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
const DEFAULT_LINUX_DISTRO: &str = "Ubuntu 24.04.3 LTS";
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
const DEFAULT_WINDOWS_DISTRO: &str = "Windows 11 Pro";
|
||||
const DEFAULT_WINDOWS_VERSION: &str = "10.0.22631.0";
|
||||
const DEFAULT_MACHINE_ID: &str = "DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF";
|
||||
|
||||
static MACHINE_ID: OnceLock<&'static str> = OnceLock::new();
|
||||
static MACOS_VERSION: OnceLock<&'static str> = OnceLock::new();
|
||||
static MACOS_OS_STRING: OnceLock<String> = OnceLock::new();
|
||||
static LINUX_OS_STRING: OnceLock<String> = OnceLock::new();
|
||||
static WINDOWS_VERSION: OnceLock<&'static str> = OnceLock::new();
|
||||
static WINDOWS_OS_STRING: OnceLock<String> = OnceLock::new();
|
||||
|
||||
/// On macOS, get the OS version, or fallback to default
|
||||
/// On other OSes, always return default
|
||||
pub fn get_macos_version() -> &'static str {
|
||||
MACOS_VERSION.get_or_init(|| {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
match os_info::get().version() {
|
||||
os_info::Version::Unknown => DEFAULT_MACOS_VERSION,
|
||||
v => v.to_string().leak(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
DEFAULT_MACOS_VERSION
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_macos_os_string() -> &'static str {
|
||||
MACOS_OS_STRING.get_or_init(|| format!("Apple Mac OS X {}", get_macos_version()))
|
||||
}
|
||||
|
||||
/// On Linux, use the real distro name if possible
|
||||
/// On other OSes, fallback to default
|
||||
pub fn get_linux_os_string() -> &'static str {
|
||||
LINUX_OS_STRING.get_or_init(|| {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
format!("Linux {}", whoami::distro())
|
||||
}
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
format!("Linux {}", DEFAULT_LINUX_DISTRO)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// On Windows, get the OS version, or fallback to default
|
||||
/// On other OSes, always return default
|
||||
pub fn get_windows_version() -> &'static str {
|
||||
WINDOWS_VERSION.get_or_init(|| {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
match os_info::get().version() {
|
||||
os_info::Version::Unknown => DEFAULT_WINDOWS_VERSION,
|
||||
v => format!("{}.0", v).leak(),
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
DEFAULT_WINDOWS_VERSION
|
||||
})
|
||||
}
|
||||
|
||||
/// On Windows, use the real edition if possible
|
||||
/// On other OSes, fallback to default
|
||||
/// The trailing space is intentional
|
||||
pub fn get_windows_os_string() -> &'static str {
|
||||
WINDOWS_OS_STRING.get_or_init(|| {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let edition = os_info::get()
|
||||
.edition()
|
||||
.map(|e| e.to_string())
|
||||
.unwrap_or_else(|| whoami::distro());
|
||||
format!("Microsoft {} , 64-bit", edition)
|
||||
}
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
format!("Microsoft {} , 64-bit", DEFAULT_WINDOWS_DISTRO)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Get machine ID or fallback to default
|
||||
pub fn get_machine_id() -> &'static str {
|
||||
MACHINE_ID.get_or_init(|| {
|
||||
machine_uid::get()
|
||||
.map(|id| id.to_string().leak() as &'static str)
|
||||
.unwrap_or(DEFAULT_MACHINE_ID)
|
||||
})
|
||||
}
|
||||
|
||||
/// Generate a UUID v5 based on machine ID and provided seeds
|
||||
pub fn derive_uuid(seeds: &[&str]) -> String {
|
||||
use uuid::Uuid;
|
||||
|
||||
let namespace = Uuid::NAMESPACE_DNS;
|
||||
let name = format!("{}-{}", get_machine_id(), seeds.join("-"));
|
||||
|
||||
let uuid = Uuid::new_v5(&namespace, name.as_bytes());
|
||||
uuid.hyphenated().to_string()
|
||||
}
|
||||
@@ -5,11 +5,12 @@ pub mod checksum;
|
||||
pub mod crypto;
|
||||
pub mod endpoint;
|
||||
pub mod env_utils;
|
||||
pub mod host_utils;
|
||||
pub mod lock_file;
|
||||
pub mod openssl;
|
||||
pub mod redact;
|
||||
pub mod request;
|
||||
#[cfg(feature = "tauri")]
|
||||
#[cfg(all(feature = "tauri", not(any(target_os = "macos", target_os = "windows"))))]
|
||||
pub mod window;
|
||||
|
||||
mod shutdown_signal;
|
||||
|
||||
@@ -6,15 +6,21 @@ pub async fn shutdown_signal() {
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
let terminate = async {
|
||||
signal::unix::signal(signal::unix::SignalKind::terminate())
|
||||
.expect("failed to install signal handler")
|
||||
.recv()
|
||||
.await;
|
||||
};
|
||||
{
|
||||
let terminate = async {
|
||||
signal::unix::signal(signal::unix::SignalKind::terminate())
|
||||
.expect("failed to install signal handler")
|
||||
.recv()
|
||||
.await;
|
||||
};
|
||||
tokio::select! {
|
||||
_ = ctrl_c => {},
|
||||
_ = terminate => {},
|
||||
}
|
||||
}
|
||||
|
||||
tokio::select! {
|
||||
_ = ctrl_c => {},
|
||||
_ = terminate => {},
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
ctrl_c.await;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,87 @@
|
||||
use roxmltree::Node;
|
||||
use xmltree::Element;
|
||||
|
||||
pub(crate) trait NodeExt<'a> {
|
||||
fn find_descendant(&self, name: &str) -> Option<Node<'a, 'a>>;
|
||||
fn descendant_text(&self, name: &str) -> Option<&'a str>;
|
||||
pub(crate) trait ElementExt {
|
||||
/// Recursively find all descendants with the given name
|
||||
fn descendants(&self, name: &str) -> Vec<&Element>;
|
||||
|
||||
fn find_child(&self, name: &str) -> Option<Node<'a, 'a>>;
|
||||
fn child_text(&self, name: &str) -> Option<&'a str>;
|
||||
/// Recursively find the first descendant with the given name
|
||||
fn descendant(&self, name: &str) -> Option<&Element>;
|
||||
|
||||
/// Recursively find the text of the first descendant with the given name
|
||||
fn descendant_text(&self, name: &str) -> Option<String>;
|
||||
|
||||
/// Find the first child with the given name
|
||||
fn child(&self, name: &str) -> Option<&Element>;
|
||||
|
||||
/// Find the text of the first child with the given name
|
||||
fn child_text(&self, name: &str) -> Option<String>;
|
||||
|
||||
/// Get the direct child element with the given name
|
||||
fn children(&self, name: &str) -> Vec<&Element>;
|
||||
|
||||
/// Get the attribute value by name
|
||||
fn attr(&self, name: &str) -> Option<&str>;
|
||||
}
|
||||
|
||||
impl<'a> NodeExt<'a> for Node<'a, 'a> {
|
||||
fn find_descendant(&self, name: &str) -> Option<Node<'a, 'a>> {
|
||||
self.descendants().find(|n| n.has_tag_name(name))
|
||||
impl ElementExt for Element {
|
||||
fn descendants(&self, name: &str) -> Vec<&Element> {
|
||||
let mut results = Vec::new();
|
||||
|
||||
if self.name == name {
|
||||
results.push(self);
|
||||
}
|
||||
|
||||
for child in &self.children {
|
||||
if let Some(element) = child.as_element() {
|
||||
results.extend(element.descendants(name));
|
||||
}
|
||||
}
|
||||
|
||||
results
|
||||
}
|
||||
|
||||
fn descendant_text(&self, name: &str) -> Option<&'a str> {
|
||||
self.find_descendant(name).and_then(|node| node.text())
|
||||
fn descendant(&self, name: &str) -> Option<&Element> {
|
||||
if self.name == name {
|
||||
return Some(self);
|
||||
}
|
||||
|
||||
for child in &self.children {
|
||||
if let Some(element) = child.as_element() {
|
||||
if let Some(found) = element.descendant(name) {
|
||||
return Some(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
fn find_child(&self, name: &str) -> Option<Node<'a, 'a>> {
|
||||
self.children().find(|n| n.has_tag_name(name))
|
||||
fn descendant_text(&self, name: &str) -> Option<String> {
|
||||
self
|
||||
.descendant(name)
|
||||
.and_then(|element| element.get_text().map(|s| s.to_string()))
|
||||
}
|
||||
|
||||
fn child_text(&self, name: &str) -> Option<&'a str> {
|
||||
self.find_child(name).and_then(|node| node.text())
|
||||
fn child(&self, name: &str) -> Option<&Element> {
|
||||
self.get_child(name)
|
||||
}
|
||||
|
||||
fn child_text(&self, name: &str) -> Option<String> {
|
||||
self
|
||||
.get_child(name)
|
||||
.and_then(|element| element.get_text().map(|s| s.to_string()))
|
||||
}
|
||||
|
||||
fn children(&self, name: &str) -> Vec<&Element> {
|
||||
self
|
||||
.children
|
||||
.iter()
|
||||
.filter_map(|child| child.as_element())
|
||||
.filter(|element| element.name == name)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn attr(&self, name: &str) -> Option<&str> {
|
||||
self.attributes.get(name).map(|s| s.as_str())
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ const VPNC_SCRIPT_LOCATIONS: &[&str] = &[
|
||||
];
|
||||
|
||||
const CSD_WRAPPER_LOCATIONS: &[&str] = &[
|
||||
"/usr/libexec/gpclient/hipreport.sh",
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
"/usr/lib/x86_64-linux-gnu/openconnect/hipreport.sh",
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
|
||||
+32
-5
@@ -1,12 +1,12 @@
|
||||
diff --git a/gpst.c b/gpst.c
|
||||
index 244aaf04..205bec1d 100644
|
||||
index 244aaf04..17fc1f45 100644
|
||||
--- a/gpst.c
|
||||
+++ b/gpst.c
|
||||
@@ -650,8 +650,11 @@ static int gpst_get_config(struct openconnect_info *vpninfo)
|
||||
|
||||
|
||||
/* submit getconfig request */
|
||||
+ char *app_version = vpninfo->csd_ticket ? : (vpninfo->gp_app_version ? : "6.3.0-33");
|
||||
+ char *app_version = openconnect_get_gp_app_version(vpninfo);
|
||||
+ vpn_progress(vpninfo, PRG_DEBUG, _("Using GlobalProtect app version: %s\n"), app_version);
|
||||
+
|
||||
buf_append(request_body, "client-type=1&protocol-version=p1&internal=no");
|
||||
@@ -15,8 +15,20 @@ index 244aaf04..205bec1d 100644
|
||||
append_opt(request_body, "ipv6-support", vpninfo->disable_ipv6 ? "no" : "yes");
|
||||
append_opt(request_body, "clientos", gpst_os_name(vpninfo));
|
||||
append_opt(request_body, "os-version", vpninfo->platname);
|
||||
@@ -1040,9 +1043,8 @@ static int run_hip_script(struct openconnect_info *vpninfo)
|
||||
* accept new ones.
|
||||
*/
|
||||
unsetenv("APP_VERSION");
|
||||
- if (vpninfo->csd_ticket)
|
||||
- if (setenv("APP_VERSION", vpninfo->csd_ticket, 1))
|
||||
- goto out;
|
||||
+ if (setenv("APP_VERSION", openconnect_get_gp_app_version(vpninfo), 1))
|
||||
+ goto out;
|
||||
|
||||
execv(hip_argv[0], (char **)hip_argv);
|
||||
|
||||
diff --git a/library.c b/library.c
|
||||
index b5e74e9b..fff28f77 100644
|
||||
index b5e74e9b..18334c76 100644
|
||||
--- a/library.c
|
||||
+++ b/library.c
|
||||
@@ -896,6 +896,7 @@ void openconnect_vpninfo_free(struct openconnect_info *vpninfo)
|
||||
@@ -27,7 +39,7 @@ index b5e74e9b..fff28f77 100644
|
||||
free(vpninfo->authgroup);
|
||||
#ifdef HAVE_LIBSTOKEN
|
||||
if (vpninfo->stoken_pin)
|
||||
@@ -1019,6 +1020,15 @@ int openconnect_set_useragent(struct openconnect_info *vpninfo,
|
||||
@@ -1019,6 +1020,20 @@ int openconnect_set_useragent(struct openconnect_info *vpninfo,
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -39,12 +51,17 @@ index b5e74e9b..fff28f77 100644
|
||||
+ STRDUP(vpninfo->gp_app_version, gp_app_version);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+const char *openconnect_get_gp_app_version(struct openconnect_info *vpninfo)
|
||||
+{
|
||||
+ return vpninfo->csd_ticket ?: (vpninfo->gp_app_version ?: "6.3.0-33");
|
||||
+}
|
||||
+
|
||||
int openconnect_set_urlpath(struct openconnect_info *vpninfo,
|
||||
const char *urlpath)
|
||||
{
|
||||
diff --git a/openconnect-internal.h b/openconnect-internal.h
|
||||
index abf45bbd..85933f4a 100644
|
||||
index abf45bbd..988f85f0 100644
|
||||
--- a/openconnect-internal.h
|
||||
+++ b/openconnect-internal.h
|
||||
@@ -786,6 +786,7 @@ struct openconnect_info {
|
||||
@@ -55,6 +72,16 @@ index abf45bbd..85933f4a 100644
|
||||
|
||||
const char *quit_reason;
|
||||
const char *delay_tunnel_reason; /* If non-null, provides a reason why protocol is not yet ready for tunnel setup */
|
||||
@@ -1677,6 +1678,9 @@ void openconnect_set_juniper(struct openconnect_info *vpninfo);
|
||||
/* hpke.c */
|
||||
int handle_external_browser(struct openconnect_info *vpninfo);
|
||||
|
||||
+/* Get the app version */
|
||||
+const char *openconnect_get_gp_app_version(struct openconnect_info *vpninfo);
|
||||
+
|
||||
/* version.c */
|
||||
extern const char openconnect_version_str[];
|
||||
|
||||
diff --git a/openconnect.h b/openconnect.h
|
||||
index 136f181a..67fc1283 100644
|
||||
--- a/openconnect.h
|
||||
|
||||
@@ -10,6 +10,9 @@ install:
|
||||
install -Dm755 artifacts/usr/bin/gpgui $(DESTDIR)/usr/bin/gpgui; \
|
||||
fi
|
||||
|
||||
# Install the HIP report script
|
||||
install -Dm755 artifacts/usr/libexec/gpclient/hipreport.sh $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
|
||||
|
||||
# Install the disconnect hooks
|
||||
install -Dm755 artifacts/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
|
||||
install -Dm755 artifacts/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
||||
@@ -30,6 +33,8 @@ uninstall:
|
||||
rm -f $(DESTDIR)/usr/bin/gpgui-helper
|
||||
rm -f $(DESTDIR)/usr/bin/gpgui
|
||||
|
||||
rm -f $(DESTDIR)/usr/libexec/gpclient/hipreport.sh
|
||||
|
||||
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
|
||||
rm -f $(DESTDIR)/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Wrapper for gpclient hip
|
||||
GPCLIENT_BIN="/usr/bin/gpclient"
|
||||
|
||||
# Redirect the output to a file for debugging then output to stdout
|
||||
LOGFILE="/tmp/gpclient-hipreport.log"
|
||||
|
||||
HIP_REPORT_OUTPUT=$(exec 2> "$LOGFILE" "$GPCLIENT_BIN" hip -vv "$@")
|
||||
|
||||
echo "$HIP_REPORT_OUTPUT"
|
||||
@@ -52,6 +52,7 @@ make build OFFLINE=@OFFLINE@ BUILD_FE=0
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%{_bindir}/*
|
||||
%{_libexecdir}/gpclient/hipreport.sh
|
||||
%{_datadir}/applications/gpgui.desktop
|
||||
%{_datadir}/icons/hicolor/32x32/apps/gpgui.png
|
||||
%{_datadir}/icons/hicolor/128x128/apps/gpgui.png
|
||||
@@ -66,6 +67,8 @@ make build OFFLINE=@OFFLINE@ BUILD_FE=0
|
||||
/usr/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down
|
||||
/usr/lib/NetworkManager/dispatcher.d/gpclient-nm-hook
|
||||
|
||||
%dir %{_libexecdir}
|
||||
%dir %{_libexecdir}/gpclient
|
||||
%dir %{_datadir}/icons/hicolor
|
||||
%dir %{_datadir}/icons/hicolor/32x32
|
||||
%dir %{_datadir}/icons/hicolor/32x32/apps
|
||||
|
||||
Reference in new issue
Block a user