Compare commits

...
348 Commits
Author SHA1 Message Date
Kevin Yue 4faa2ecb0d feat: prepare 3.1.0 with connection details and improved authentication
Add tunnel statistics and an optional CLI dashboard, native sign-in controls and recovery, and broader client certificate support. Include platform integration fixes and the approved release notes.
2026-10-19 23:47:11 +08:00
Kevin Yue 18ed6bac1a feat: prepare 3.0.5 with refreshed icons and dependency updates 2026-10-13 16:34:10 +08:00
github-actions[bot] 10139e0f2c chore: update flake hashes for v3.0.4 (#675)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-13 00:45:05 +08:00
Kevin Yue ff1ea259d9 feat: release 3.0.4 with background connections and service startup improvements 2026-10-12 23:53:21 +08:00
Kevin Yue 57322e3cf3 fix: skip macOS waiter without a successful dispatch 2026-10-12 15:03:34 +08:00
github-actions[bot] 9532374805 chore: update flake hashes for v3.0.3 (#673)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-12 14:42:20 +08:00
Kevin Yue 90faa58811 chore: prepare 3.0.3 release 2026-10-12 13:44:27 +08:00
Kevin Yue 93504eaec2 fix: improve authentication recovery and diagnostics
Recognize real GTK Wayland crash messages and keep remote
authentication prompts readable. Preserve device identifiers
without initializing OpenSSL, validate diagnostic executable
paths, and improve release automation.

Fixes #669
2026-10-12 13:37:15 +08:00
Ihar Hrachyshka d73b712dd3 chore: add make install-gpclient target (#672)
This is useful in build environments where gpclient is a separate
artifact from other binaries (this is the case in nixpkgs).
2026-10-12 10:53:37 +08:00
Finley Holt be111a671a fix(cli): let gpauth read the pasted callback with --browser remote (#671) 2026-10-12 10:36:38 +08:00
Ihar HrachyshkaandKevin Yue f9965f8a35 macOS: make openconnect relocatable; drive installation through make install (#668)
Co-authored-by: Kevin Yue <[email protected]>
2026-10-12 10:12:17 +08:00
Kevin Yue f7649898fd fix(ci): honor build-only for manually dispatched tag refs 2026-10-12 01:14:30 +08:00
github-actions[bot] e6910060df chore: update flake hashes for v3.0.2 (#667)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-12 01:07:34 +08:00
Kevin Yue f41a429a5e Merge release 3.0.2 2026-10-12 00:28:04 +08:00
Kevin Yue 888f288c0d Release 3.0.2 2026-10-12 00:26:32 +08:00
github-actions[bot] f0292a9292 chore: update flake hashes for v3.0.1 (#665)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-11 00:44:28 +08:00
Kevin Yue 580b81e7bb Release 3.0.1 2026-10-10 23:39:38 +08:00
github-actions[bot] 8724ed3b37 chore: update flake hashes for v3.0.0 (#662) 2026-10-09 21:07:32 +08:00
Kevin Yue 01075cb6dc Merge 3.0.0 release into main 2026-10-09 20:54:53 +08:00
Kevin Yue b7b708e9cd feat: prepare 3.0.0 release 2026-10-09 18:21:44 +08:00
koval-jan 0425ee6ddb fix(cli): exempt hip subcommand from singleton lock check (#658) 2026-09-18 08:29:34 +08:00
Maksym ShaievandMaksym Shaiev 9e4f45997e feat(gpclient): add --cookie-only to print gateway cookie without starting tunnel (#647)
Co-authored-by: Maksym Shaiev <[email protected]>
2026-09-07 22:53:32 +08:00
Kevin Yueandgithub-actions[bot] 3882e29b0e fix(nix): resolve systemd DNS tools (#654)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-09-01 15:33:15 +08:00
Kevin Yueandgithub-actions[bot] 32bac9b675 fix: run UFW status with required privileges (#655)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-09-01 15:32:16 +08:00
0e1aedce82 feat: add HIP support for Linux ClamAV (anti-malvare) and UFW (firewall) (#650)
Co-authored-by: J. Andres Guerrero <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-09-01 15:03:16 +08:00
Kevin Yueandgithub-actions[bot] 8eb4d48887 feat: add host-aligned NixOS module (#652)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-09-01 09:47:01 +08:00
github-actions[bot] 87f91e3c13 fix(nix): align prebuilt runtime dependencies (#651)
Use raw release-asset hashes, keep the Nixpkgs lock current, and validate the prebuilt package across supported Nixpkgs branches and architectures.

[skip ci]
2026-08-31 17:09:02 +00:00
Ronald HötschlandKevin Yue f9f9dd8abe feat: add --log-format json to gpclient and gpauth (#644)
Co-authored-by: Kevin Yue <[email protected]>
2026-08-20 23:28:01 +08:00
JD F 2283d4a076 fix: apply nixpkgs.follows to flake inputs (#646) 2026-08-20 22:17:03 +08:00
Kevin Yue d75e422c1d ci: split AUR publishing into retryable job 2026-08-06 22:58:25 +08:00
Ronald Hötschl 0c2d4830b5 Remove GUI dependencies from apk when GUI components are disabled (#638) 2026-08-05 14:23:36 +08:00
github-actions[bot] 3c49eab0c8 chore: update flake hashes for v2.6.5 (#640) 2026-08-05 12:23:53 +08:00
Kevin Yue 13ec7dfc37 Merge pull request #639 from yuezk/release/2.6.5
chore: merge 2.6.5 release
2026-08-05 12:13:22 +08:00
Kevin Yue e98fd7894a ci: build FreeBSD package on 14.4 2026-08-05 11:11:46 +08:00
Kevin Yue 6f860d3dff fix: avoid reformatting VPN progress messages 2026-08-05 10:27:19 +08:00
Kevin Yue 5902bee5ff chore: prepare 2.6.5 release 2026-08-05 10:16:07 +08:00
Nanami Nakano 66f48b3ff6 Remove linux-only component from darwin build (#633)
* feat: remove linux-only component from darwin build

* fix: rewrite paths after copy files
2026-07-04 16:22:18 +08:00
github-actions[bot] 0f7d065628 chore: update flake hashes for v2.6.4 (#632) [no ci] 2026-06-25 16:37:20 +08:00
Kevin Yue 494e4a5331 fix: replace passwd with OTP on gateway MFA retry
Gateway login OTP retries were appending a second passwd form field
instead of replacing the credential password. That regressed in 2.6.0
when login params moved from a HashMap to a Vec and could cause MFA
submissions to fail with HTTP 512 (fix #626).

Bump version to 2.6.4.
2026-06-25 14:41:42 +08:00
Kevin Yue b5b71df6e6 doc: update OpenBSD/FreeBSD instructions 2026-06-24 12:53:05 +08:00
Kevin Yue 49f410e63b Merge branch 'fix/nixos-desktop-launch-path' 2026-06-24 12:52:20 +08:00
Kevin Yue 225acf13aa fix: use stable NixOS desktop launcher path 2026-06-24 09:26:07 +08:00
Kevin Yueandgithub-actions[bot] 61d2b702c0 chore: update flake hashes for v2.6.3 (#631)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-06-23 23:12:52 +08:00
github-actions[bot] 3276ac0f9a chore: update flake hashes for v2.6.3 (#630) [no ci] 2026-06-23 21:57:51 +08:00
Kevin Yue 0b037e158c chore: prepare 2.6.3 release
- Fix NixOS GUI authorization after package updates.

- Treat Ctrl+C initiated OpenConnect disconnect as a successful shutdown.

- Update snapshot flake hash automation for prebuilt Nix packages.

- Bump gp workspace version and changelog to 2.6.3.
2026-06-23 20:06:04 +08:00
Kevin Yue 10e94e0b81 fix: use minimal Rust PPA build deps 2026-06-22 23:46:06 +08:00
github-actions[bot] 0f76539075 chore: update flake hashes for v2.6.2 (#628)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-06-22 23:08:15 +08:00
Kevin Yue f9b8c55924 Merge branch 'release/2.6.2' 2026-06-22 22:50:48 +08:00
Kevin Yue a708ce0115 chore: release 2.6.2 2026-06-22 20:33:14 +08:00
github-actions[bot] b3f4ba0a32 chore: update flake hashes for v2.6.1 (#625) 2026-06-22 14:33:21 +08:00
Kevin Yue 02cf4a0b26 ci: parallelize gpgui release builds 2026-06-22 12:51:52 +08:00
Kevin Yue 370189cbee fix: resolve release changelog path 2026-06-22 12:42:47 +08:00
Kevin Yue 6746cf64c3 fix: complete 2.6.1 release updates 2026-06-22 11:46:26 +08:00
Kevin Yue 40739739b5 fix: correct direct gateway browser auth mode 2026-06-22 08:24:48 +08:00
Kevin Yue dc7a200b93 ci: avoid Docker Hub auth pulls in release builds 2026-06-21 22:28:49 +08:00
Kevin Yue f49b6471f3 ci: reduce release Docker pull pressure 2026-06-21 22:25:28 +08:00
Kevin Yue 4da922aa3b chore: prepare 2.6.1 release 2026-06-21 22:15:09 +08:00
Kevin Yue ecc9c9f09c feat: auto-select browser for external auth 2026-06-21 20:59:13 +08:00
Kevin Yue b32002710b fix: support NixOS prebuilt GUI package 2026-06-21 20:08:19 +08:00
Kevin Yue 7b6d20a003 fix: substitute NixOS gpservice wrapper path 2026-06-21 15:26:52 +08:00
Kevin Yue d27029fad8 fix: match NixOS polkit service path 2026-06-21 15:21:51 +08:00
Kevin Yue 1b488ba696 fix: launch NixOS GUI service outside FHS env 2026-06-21 14:32:13 +08:00
Kevin Yue f78f7c9bc8 fix: prefer NixOS host wrappers in prebuilt package 2026-06-21 14:03:42 +08:00
Kevin Yue 7e11693ce3 Merge branch 'feature/nix-prebuilt-binaries'
# Conflicts:
#	.github/workflows/build.yaml
#	flake.nix
2026-06-21 12:46:18 +08:00
Kevin Yue c601fa9aa2 feat: add prebuilt Nix package 2026-06-21 12:20:28 +08:00
Kevin Yue 536a43773f feat: add prebuilt Nix package (#622) 2026-06-21 11:57:57 +08:00
Kevin Yue ae4cbedd3b doc: update NixOS installation instructions 2026-06-20 22:11:06 +08:00
Kevin Yue fe55d11fc4 ci: use main PPA publish action 2026-06-20 19:39:26 +08:00
github-actions[bot] 34f1feaf43 chore: update flake hashes for v2.6.0 (#621) 2026-06-20 19:12:58 +08:00
Kevin Yue f640b4d325 Merge branch 'fix/settings-crash-wayland-thread-safety' 2026-06-20 19:08:23 +08:00
Kevin Yue a35b4a289e chore: release 2.6.0 2026-06-20 18:21:58 +08:00
Kevin Yue a7a5d9bf96 fix: recover desktop session env for browser auth 2026-06-19 23:25:05 +08:00
Kevin Yue 888dc93643 refactor: align GP profile and packaging flow
Main changes:

- Refactor connect/auth flows around a single OS profile and host identity model, including gateway fallback and cookie-on-stdin handling.

- Align request parameters, HIP host-id propagation, SAML webview user-agent behavior, and portal default-browser handling with observed official client behavior.

- Add opt-in cookie cache support and Microsoft Defender HIP reporting while keeping host-id validation explicit.

- Add BSD build, packaging, release artifact, and provenance support with FreeBSD/OpenBSD path and dependency cleanup.

- Update NixOS install documentation and dependency compatibility fixes.
2026-06-19 21:23:29 +08:00
Rafa FlorestaandRafa Floresta f98e0336dc fix(gpapi): send host-id so the portal issues the auth-override cookie (#616)
PAN-OS binds the portal authentication-override cookie (portal-userauthcookie)
to the client's host-id. GpParams never had a host-id, so to_params() omitted it
from prelogin, getconfig and gateway login (prelogin even lists it in
REQUIRED_PARAMS, but it was never produced and got silently dropped).

On portals configured for SAML at both the portal and the gateway, the portal
then returns portal-userauthcookie=empty. With no cookie to present, the gateway
login falls back to a second, gateway-level SAML that the server rejects with
saml-auth-status=-1.

Add a stable host_id to GpParams (defaulting to host_utils::derive_uuid, the same
per-machine UUID used for HIP reports) and emit "host-id" from to_params(), so
prelogin, getconfig and gateway login all carry a consistent host-id. The portal
then issues a real portal-userauthcookie, which the gateway accepts; the failing
gateway-SAML path is never taken.

Fixes #491

Co-authored-by: Rafa Floresta <[email protected]>
2026-06-19 14:39:56 +08:00
Guangyuan Weng 7a571f9b27 feat(gpclient): cache portal-cookie to skip SAML on reconnect (#608) 2026-06-19 14:38:17 +08:00
bstock-rpandbstock84 67de92044f feat: add Microsoft Defender anti-malware HIP reporting support for linux (#618)
Co-authored-by: bstock84 <[email protected]>
2026-06-19 14:29:54 +08:00
Kevin Yue 7d63836e35 ci: support remote auth in docker image 2026-05-09 22:43:44 +08:00
Kevin Yue 3e23fc7d22 ci: add Alpine docker runtime libraries 2026-05-09 20:53:34 +08:00
Kevin Yue 8bf05d381e ci: dynamically link Alpine docker build 2026-05-09 20:36:24 +08:00
Kevin Yue 1ab36a1137 fix: gate gtk dependency behind tauri feature 2026-05-09 20:21:37 +08:00
Kevin Yue 18b788e664 ci: align docker packaging path 2026-05-09 20:10:24 +08:00
Kevin Yue ebadab8f06 ci: publish docker images by digest 2026-05-09 20:02:59 +08:00
Kevin Yue 81d13deaab refactor: simplify SAML browser selection 2026-05-09 09:24:26 +08:00
Kevin Yue 6f91a79081 docs: add minimal Alpine gpclient image 2026-05-09 09:04:28 +08:00
Kevin Yue 4d252fa31c ci: simplify gpgui matrix names 2026-05-09 07:45:32 +08:00
Kevin Yue 398475c649 ci: preserve gpgui check names 2026-05-09 07:41:21 +08:00
Kevin Yue 13d4aa398c ci: matrix gpgui libc builds 2026-05-09 07:38:24 +08:00
Kevin Yue 9423665fe5 ci: remove unsupported release action input 2026-05-09 01:26:26 +08:00
Kevin Yue 5e8dbfa26d ci: disambiguate APK release assets 2026-05-09 01:14:23 +08:00
github-actions[bot] d96b3f9c0d chore: update flake hashes for v2.5.4 (#607)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-05-08 17:03:26 +00:00
Kevin Yue 7720942681 ci: keep gpgui matrices running after failures 2026-05-09 00:11:39 +08:00
Kevin Yue f129ca7ea1 chore: release 2.5.4 2026-05-08 23:56:07 +08:00
Kevin Yue 628d0febdd ci: keep build-gp matrix running after failures 2026-05-08 23:07:21 +08:00
Kevin Yue add284d3b4 ci: always build arm packages 2026-05-08 22:39:21 +08:00
Kevin Yue a3f2224952 ci: add Alpine APK packaging 2026-05-08 22:24:15 +08:00
github-actions[bot] 966bcc554b chore: update flake hashes for v2.5.3 (#605) 2026-05-08 08:32:04 +08:00
Kevin Yue d6e3a212f2 chore: release v2.5.3 2026-05-08 08:15:11 +08:00
Kevin Yue e45b4a4145 fix: restore systemd-resolved DNS routing (#604)
Fixes #604.
2026-05-08 08:13:37 +08:00
Kevin Yue 93a7f4bd10 ci: enhance workflow inputs and series resolution for PPA publishing 2026-05-07 19:17:29 +08:00
Kevin Yue d1401171d8 ci: simplify aur publish workflow 2026-05-07 09:40:30 +08:00
Kevin Yue 9591ca287e ci: fix aur ssh known hosts path 2026-05-07 09:23:05 +08:00
Kevin Yue 46c80ecc93 ci: harden aur publish workflow 2026-05-07 09:14:02 +08:00
Kevin Yue 99d2a26d45 ci: fix aur srcinfo validation 2026-05-07 09:11:57 +08:00
Kevin Yue 067037517e ci: publish aur git package 2026-05-07 08:29:58 +08:00
github-actions[bot] c04b49fe11 chore: update flake hashes for v2.5.2 (#603)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-05-07 07:19:51 +08:00
Kevin Yue a044cb35ad ci: automate flake hash updates 2026-05-07 07:13:54 +08:00
Kevin Yue ac4b6240ef chore: bump version 2026-05-06 23:35:38 +08:00
Kevin Yue 0c3af0d60d chore: update dependencies 2026-05-06 23:20:58 +08:00
Kevin Yue 6289e1539a build: use vendored openconnect dependencies 2026-05-06 23:20:57 +08:00
Kevin Yue 08a77f9d38 fix: vendor vpnc script in linux packages 2026-05-06 23:20:57 +08:00
Kevin Yue fb6db0dc12 fix: use portal policy for session extension 2026-05-06 23:20:57 +08:00
Kevin Yue 731a0d895c debug: log GlobalProtect getconfig response 2026-05-06 23:20:57 +08:00
Kevin Yue ab58dd6cec refactor: update session extension flow 2026-05-06 23:20:57 +08:00
Kevin Yue cdcf03ff2f feat: add gpclient session refresh support (#595)
* Add session info events for GUI warnings

* fix macOS local build

* fix session expiry parsing

* chore: remove session info debug logging

* fix: decouple session info from vpn connect

* refactor: share gpapi response helpers

* fix: restore blocking session info fetch

* refactor: remove service session info flow

* refactor: share session protocol helpers

* refactor: separate cli session runtime
2026-05-06 23:20:57 +08:00
Kevin Yue 1d715f059d fix macOS local build 2026-05-06 23:20:56 +08:00
Kevin Yue 88951d863b ci: upgrade workflow actions for node 24 2026-05-06 23:20:56 +08:00
Kevin Yue 0d5d06ead0 ci: update artifact download action 2026-05-06 23:20:56 +08:00
Kevin Yue 3171bb9fd1 docs: add user-level installation instructions for NixOS integration 2026-05-06 23:20:56 +08:00
Kevin Yue d48b29025e style: reorder use statements for consistency across multiple files 2026-05-06 23:20:56 +08:00
Kevin Yue d06ce925ac fix: preserve GP reconnect cookie fields 2026-05-06 23:20:56 +08:00
Kevin Yue 5ace087f92 feat: expose openconnect connection options 2026-05-06 23:20:55 +08:00
Kevin Yue a51f034036 fix: continue deb build when mk-build-deps fails 2026-05-06 23:20:55 +08:00
Kevin Yue 982562874a fix: update Rust version handling in PPA build scripts 2026-05-06 23:20:55 +08:00
Kevin Yue 45fe7165f3 chore: upgrade to vite 8 2026-05-06 23:20:55 +08:00
Kevin Yue d0f6a67be1 fix: add excluded series input to PPA publish workflow 2026-05-06 23:20:55 +08:00
Kevin Yue 8461c73bc3 chore: bump Rust version to 1.89 2026-05-06 23:20:54 +08:00
Kevin Yue 238a4ee1e3 fix: log empty gateway login response headers and handle accordingly 2026-05-06 23:20:54 +08:00
Kevin Yue 253f995dc6 fix: trim leading slash from auth callback data 2026-05-06 23:20:54 +08:00
Kevin Yue 0972c89ee1 fix: include SAML auth data in decode warning 2026-05-06 23:20:54 +08:00
Kevin Yue 13a4b928ed refactor: add cookie handling from standard input in ConnectHandler 2026-05-06 23:20:54 +08:00
Kevin Yue c6b47eef6a refactor: improve error handling and update deprecation warnings in ConnectHandler 2026-05-06 23:20:54 +08:00
Kevin Yue a1afe3f1e3 refactor: update ConnectArgs to replace deprecated options and add HIP support 2026-05-06 23:20:53 +08:00
Kevin Yue a3672ba764 fix: remove rust build requirement and clarify openconnect dependency 2026-05-06 23:20:53 +08:00
Kevin Yue d01ef9d394 refactor: replace BUILD_GUI with BUILD_GUI_HELPER and simplify build options 2026-05-06 23:20:53 +08:00
Nanami Nakano dad4f13f64 feat: App support for Intel homebrew builds (#594) 2026-04-26 21:04:20 +08:00
Kevin Yue 4f477901d9 docs: clarify v2.3.13 distro packages 2026-04-20 09:02:30 +08:00
Kevin Yue d3ffefa897 docs: mention v2.3.13 for older Linux distros 2026-04-20 09:00:29 +08:00
Kevin Yue 93f786452d Merge pull request #590 from setarcos/unsupported 2026-04-16 10:34:24 -04:00
Kevin YueandMark Sheppard 635fd9f8bf Make BUILD_GUI=0 avoid using GUI libraries & better errors when spawn fails (#592)
Co-authored-by: Mark Sheppard <[email protected]>
Co-authored-by: Kevin Yue <[email protected]>
2026-04-16 10:32:38 -04:00
Kevin Yue e4295a6ce8 fix: improve error handling when spawning child processes 2026-04-16 22:30:08 +08:00
Mark Sheppard e4426df6a2 fix: better error messages when spawning a child program fails 2026-04-16 00:44:38 +01:00
Mark Sheppard 65a93041aa fix: mention the BUILD_GUI option in the docs 2026-04-15 23:50:46 +01:00
Mark Sheppard 8287a669fb fix: builds with BUILD_GUI=0 now omit the webview-auth feature 2026-04-15 23:37:29 +01:00
Pluto Yang 48d96dbb9d feat: add architecture check for GUI updater
Return early if target architecture is not x86_64 or aarch64
2026-04-14 16:22:48 +08:00
Kevin Yue bd613382bc fix: remove optional preFixup for GIO_EXTRA_MODULES in runtimeDependencies 2026-03-19 23:30:25 +08:00
Kevin Yue 3eda3afba4 fix: use pkgs.lib for optionalString in preFixup for better compatibility 2026-03-19 23:26:21 +08:00
Kevin Yue d7ec1c16a2 fix: add glib-networking and openssl to runtime and build inputs 2026-03-19 23:20:07 +08:00
Fabio Di Giorgio d241d48f52 fix: autoreconf: not found in devcontainer (#585) 2026-02-26 18:12:46 +08:00
Flameopathic 67954d7c4b fix: pkgs.system use in README (#581) 2026-02-14 14:31:11 +08:00
Kevin Yue 977725868a fix: use source tarball for nix build 2025-12-23 21:53:30 +08:00
Kevin Yue e2acdd7df2 fix: update flake.lock 2025-12-23 21:26:34 +08:00
Kevin Yue ae50155fbd fix: update hash for Nix build 2025-12-23 12:46:07 +08:00
Kevin Yue 24f9bbbccb feat: add LIBXML2_STATIC environment variable to Docker build for static linking 2025-12-23 07:45:55 +08:00
Kevin Yue 1b4ea720a6 Release 2.5.1 2025-12-22 23:16:52 +08:00
Kevin Yue 7d87442f73 feat: add HIP report generation functionality and related dependencies 2025-12-22 23:16:31 +08:00
Kevin Yue f398ccadb7 Release 2.5.0 2025-12-08 22:41:42 +08:00
Kevin Yue 740c79af9b chore: update dependencies 2025-12-08 22:10:15 +08:00
Kevin Yue d0096c6cb2 feat: update application name and description to reflect GP Connect branding 2025-12-08 21:46:02 +08:00
Kevin Yue e4701c1bd8 feat: add support for client version emulation and integrate OpenConnect submodule 2025-12-08 21:46:02 +08:00
Kevin Yue a08ae655cf feat: support the --script-tun option 2025-12-02 19:54:09 +08:00
Olivier Louvignes a917e16e62 Add support for macOS builds (apple silicon) (#557) 2025-12-01 22:43:00 +08:00
Kevin Yue 8ed3304e61 Update flake.nix 2025-11-13 11:03:13 +08:00
Kevin Yue c40fd051e5 Release 2.4.7 2025-11-13 00:14:07 +08:00
Kevin Yue 09cd8ecb18 feat: upgrade Rust version to 1.85 2025-11-13 00:13:53 +08:00
Kevin Yue a4e1743691 feat: add NixOS support with flake configuration and package setup 2025-11-12 23:35:44 +08:00
Kevin Yue 801a339525 feat: update browser argument in Cli and ConnectArgs to include default value and argument count 2025-11-12 23:35:44 +08:00
Kevin Yue 49a7cbfe99 feat: add auth_executable parameter to SamlAuthLauncher and update launch logic 2025-11-12 23:35:44 +08:00
Kevin Yue 603975bfe0 feat: add hip parameter to ConnectArgs and VpnBuilder, update connection logic 2025-11-12 23:35:44 +08:00
Kevin Yue 49fe7447ff feat: add VpnEnv struct and update WsEvent to include VPN environment details 2025-11-12 23:35:43 +08:00
Kevin Yue 7048248268 feat: integrate common crate and add constants for user agent and lock files 2025-11-12 23:35:43 +08:00
Kevin Yue cad5ca3d68 fix: add vpnc script location 2025-11-12 23:35:43 +08:00
Kevin Yue 9e9ab6fb7d fix: update @mui/icons-material and @mui/material dependencies to version 7.3.4 2025-11-12 23:35:42 +08:00
Fred Eisele 8e55698271 Update the README.md to describe building with devcontainers (#521) 2025-11-04 22:27:25 +08:00
Kevin Yue 47338b21a8 fix: remove conditional check for PPA input in publish job 2025-10-15 23:41:42 +08:00
Kevin Yue 4c307e05f5 fix: update Docker volume paths in build steps 2025-10-15 23:38:08 +08:00
Kevin Yue b56659b0b4 Release 2.4.6 2025-10-15 22:49:55 +08:00
Kevin Yue e3c3b6e89e Update dependencies and improve crypto handling
- Updated macOS-specific dependencies in `Cargo.toml` to their latest versions for better compatibility and performance.
- Refactored nonce handling in `crypto.rs` to improve clarity and correctness in the decryption process.
- Modified `gh-release.sh` to streamline asset uploads for snapshot releases and ensure stability for tagged releases by limiting uploaded components.
2025-10-15 22:49:54 +08:00
Kevin Yue f1a8a3c19a feat: add support for ubuntu-rolling package in build-gp job 2025-10-15 19:46:11 +08:00
Kevin Yue 986b63391a fix: update visibility of auth window based on clean state 2025-10-12 22:04:16 +08:00
Kevin Yue 9b180ad90c feat: add Publish PPA workflow and support for disabling Rust toolchain 2025-10-12 22:04:16 +08:00
Kevin Yue 6079dc6aee fix: update Rust version and dependencies for packaging 2025-10-12 22:04:16 +08:00
Kevin Yue 2bd7371c7a feat: refactor password handling in ConnectHandler to reuse stdin input
--passwd-on-stdin reads again on gateway failure
Fixes #546
2025-10-12 22:04:15 +08:00
Dark12andKevin Yue e1eb191def Support for remote browser. Useful for headless servers (#544)
* Support for remote browser. Useful for headless servers

* feat: enhance browser authentication to support remote mode and local IP detection

---------

Co-authored-by: Kevin Yue <[email protected]>
2025-10-12 22:02:19 +08:00
Eric Work a9d2de06b5 Fix gpclient disconnect bailing with client is already running (#542)
The command `gpclient disconnect` should disconnect an already running gpclient connection, but instead bails with `client is already running`. The client is expected to be running since the desired behavior is to disconnect an existing connection. Fix the CLI run logic to not bail when the client is already running and a disconnect operation is in progress.

Fixes #533
2025-10-10 11:41:34 +08:00
Kevin Yue 2aa875a626 Release 2.4.5 2025-07-16 14:18:00 +08:00
Kevin Yue e4fa429dcc style: format code for consistency and readability 2025-07-16 10:01:28 +08:00
Kevin Yue 5ba7bf2e18 feat: add the --force-dpd option
gh-519
2025-07-15 22:03:35 +08:00
Kevin Yue 11925a372d fix: parse VPN URL to support custom port
Related: #404
2025-07-08 23:32:54 +08:00
Kevin Yue e1eb9e20f1 feat: update VPN connection to parse URL and ensure HTTPS prefix 2025-07-08 23:26:04 +08:00
Kevin Yue 1d3aa889d5 ci: use GitHub hosted arm action runner 2025-06-11 11:37:48 +08:00
Kevin Yue c1ab26aef3 feat: add the -i/--interface option (#512) 2025-06-10 22:12:14 +08:00
Kevin Yue ea9819d161 fix: correct the Gentoo package name, fix #71 2025-05-05 17:14:23 +08:00
Kevin Yue dc9480fd71 Release 2.4.4 2025-02-09 14:30:40 +00:00
Kevin Yue fa2849a080 chore: update dependencies 2025-02-09 14:25:35 +00:00
Kevin Yue c70c7ee5b9 fix: multiple tray icon related: #464 2025-02-09 08:23:40 +00:00
Kevin Yue fe3d3df662 ci: upload offline tarball 2025-01-23 21:59:59 +08:00
Kevin Yue 2f90b73683 fix: check the cli running state 2025-01-22 21:30:42 +08:00
Kevin Yue 5186e80c6f doc: update installation for Ubuntu 18.04 2025-01-21 23:00:32 +08:00
Kevin Yue 4ff1c1dc1f Release 2.4.3 2025-01-21 00:16:00 +08:00
Kevin Yue c1427040f6 fix: do not use default value for os_version 2025-01-21 00:14:13 +08:00
Kevin Yue a7ad02acb6 Release 2.4.2 2025-01-20 20:57:57 +08:00
Kevin Yue b188d61be1 fix: disconnect VPN when sleep 2025-01-20 19:29:22 +08:00
Kevin Yue ec85e857bc Release 2.4.1 2025-01-09 23:53:03 +08:00
Kevin Yue d37ccafdc2 feat: gpauth support macos 2025-01-09 21:22:41 +08:00
Kevin Yue 0c9b8e6c63 Update publish.yaml 2024-12-26 23:25:23 +08:00
Kevin Yue 8f8ad466f4 refactor: upgrade tauri 2.0 2024-12-26 21:50:39 +08:00
Kevin Yue 0f67be465b chore: use tauri2 build container 2024-12-20 10:29:22 +00:00
Michael Nedokushev ed7c8ca1a1 Add installation instructions for Gentoo linux distro (#449) 2024-12-08 21:08:44 +08:00
Kevin Yue f71e29de5c chore: include dist in git repo 2024-12-08 20:12:40 +08:00
Kevin Yue a641453388 docs: update README for manual installation 2024-11-05 23:25:38 +08:00
Kevin Yue 366b95ce1f Release 2.3.9 2024-11-02 14:13:53 +00:00
Kevin Yue 136c870d1f chore: update CI 2024-11-02 09:46:27 +00:00
Kevin Yue 0c411a542f fix: enhance OpenSSL compatibility mode
Related: #437
2024-11-02 09:36:11 +00:00
Kevin Yue 1e70dd088f Release 2.3.8 2024-10-31 14:50:24 +00:00
Kevin Yue 2dc7f97ff0 Merge branch 'dev' into main 2024-10-31 14:36:50 +00:00
Kevin Yue 6542d677a9 update default browser 2024-10-31 14:31:13 +00:00
Kevin Yue 222fe26cea fix: default browser not working on some os 2024-10-31 06:31:54 +00:00
Kevin Yue ed413ee029 fix: saved credentials not working 2024-10-31 05:27:04 +00:00
Kevin Yue 516d685c9e fix: saved credentials not working 2024-10-30 16:13:20 +00:00
Kevin Yue 54e2371022 Fix the save credentials not working (#435) 2024-10-30 19:46:53 +08:00
Eric Dallo 511cc5ebd7 Fix flake.nix vpnc-script hardcoded path (#413) 2024-08-18 21:13:26 +08:00
Kevin Yue 30bec40338 Release 2.3.7 2024-08-16 01:34:19 +00:00
Kevin Yue 0bb9353a11 fix: build error with rust 1.80 2024-08-16 01:23:26 +00:00
Kevin Yue 80134f5a2b Release 2.3.6 2024-08-15 13:35:19 +00:00
Kevin Yue 57e20fe478 fix: enhance gpauth to support browser authentication 2024-08-15 13:14:08 +00:00
Kevin Yue 9317430968 Release 2.3.5 2024-08-14 22:47:08 +08:00
Kevin Yue f92b04e99a use --browser option 2024-08-14 22:42:35 +08:00
Kevin Yue a1c63f8498 chore: update dependencies 2024-08-14 21:43:35 +08:00
Kevin Yue 9460d498fc feat: support specify the browser to use
Related: #405, #407, #397
2024-08-14 21:27:23 +08:00
Kevin Yue c2a6a436a5 feat: support the --no-dtls option 2024-08-13 20:41:33 +08:00
Kevin Yue c578e35178 fix: correct the --os parameter 2024-08-12 21:47:39 +08:00
Kevin Yue 90cd9a46f6 Release 2.3.4 2024-07-08 13:49:30 +00:00
Kevin Yue 6616389a5f Update README.md 2024-07-08 21:37:54 +08:00
Farid Zakaria f5f5d358b4 Introduce flake.nix for project to build for NixOS (#387) 2024-07-08 21:20:15 +08:00
Kevin Yue 5cb9432f21 refactor: improve the XML parsing 2024-07-08 13:04:27 +00:00
Kevin Yue fb8fb21450 feat: support read password from stdin
Related: #381
2024-07-07 13:38:57 +00:00
Kevin Yue 370a32f1b5 refactor: improve gateway parsing 2024-07-07 13:38:34 +00:00
Kevin Yue 68227b64a2 refactor: improve the XML parsing 2024-07-07 18:15:12 +08:00
Kevin Yue 2a0880bfee chore: update the License 2024-07-06 03:29:13 +00:00
Ruben Rodriguez 26dbd8d312 feat: add internal host detection support (#384) 2024-07-02 21:30:34 +08:00
Kevin Yue 6357a4087d Update README.md 2024-06-26 08:54:39 +08:00
Kevin Yue f482bd077b Release 2.3.3 2024-06-23 21:42:55 +08:00
Kevin Yue 148468eee3 Release 2.3.2 2024-06-17 20:54:04 +08:00
Kevin Yue 79083e5664 feat: Remove dotenvy_macro crate from dependencies 2024-06-15 10:58:36 +08:00
Kevin Yue c52d2bc0b6 fix: Decode CAS callback before parsing
Related: #372
2024-06-13 14:34:58 +00:00
Kevin Yue 54d4f2ec57 fix: Cleanup temporary file after feeding auth data
Related: #366
2024-06-11 22:20:49 +08:00
Kevin Yue a25b5cb894 Release 2.3.1 2024-05-21 20:28:04 +08:00
Kevin Yue 6caa8fcd84 fix: sslkey not working (related #363) 2024-05-21 20:26:37 +08:00
Kevin Yue 66270eee77 chore: update CI 2024-05-20 22:12:03 +08:00
Kevin Yue 6119976027 Release 2.3.0 2024-05-20 21:31:26 +08:00
Kevin Yue a286b5e418 feat: improve client certificate authentication 2024-05-20 09:08:47 -04:00
Kevin Yue 882ab4001d chore: improve error message 2024-05-19 22:30:40 +08:00
Kevin Yue 52b6fa6fbd feat: support client certificate authentication (related #363) 2024-05-19 18:44:07 +08:00
Kevin Yue 3bb115bd2d Merge branch 'main' into dev 2024-05-19 10:23:00 +08:00
Kevin Yue e08f239176 fix: do not panic when failed to start service (fix #362) 2024-05-19 10:21:18 +08:00
Kevin Yue a01c55e38d fix: do not panic when failed to start service (fix #362) 2024-05-19 10:19:21 +08:00
Kevin Yue af51bc257b feat: add the --reconnect-timeout option 2024-05-19 09:59:25 +08:00
Kevin Yue 90a8c11acb feat: add disable_ipv6 option (related #364) 2024-05-19 09:04:45 +08:00
Kevin Yue 92b858884c fix: check executable for file 2024-05-10 10:26:45 -04:00
Kevin Yue 159673652c Refactor prelogin.rs to use default labels for username and password 2024-05-09 01:48:02 -04:00
Kevin Yue 200d13ef15 Release 2.2.1 2024-05-07 11:58:15 -04:00
Kevin Yue ddeef46d2e Restore the browser auth, related #360 2024-05-07 11:40:44 -04:00
Dr. Larry D. Pyeatt 97c3998383 Install instructions for Gentoo (#352)
* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

Add install instructions for Gentoo
2024-05-06 19:00:17 +08:00
Kevin Yue 93aea4ee60 doc: using the default browser for CLI 2024-04-30 18:47:38 +08:00
Kevin Yue 546dbf542e Update README.md 2024-04-30 13:28:20 +08:00
Kevin Yue 005410d40b Update README.md 2024-04-30 13:19:52 +08:00
Kevin Yue 3b384a199a Update changelog 2024-04-29 21:56:50 -04:00
Kevin Yue b62b024a8b Release 2.2.0 2024-04-29 21:05:36 -04:00
Kevin Yue 4fbd373e29 chore: update logging 2024-04-17 21:25:25 +08:00
Kevin Yue ae211a923a refactor: refine the logging 2024-04-15 22:31:50 +08:00
Kevin Yue d94d730a44 feat: support default browser for CLI (#345) 2024-04-15 20:27:33 +08:00
Kevin Yue 18ae1c5fa5 refactor: improve gp response parsing 2024-04-14 17:22:37 +08:00
Kevin Yue a0afabeb04 Release 2.1.4 2024-04-10 10:13:37 -04:00
Kevin Yue 1158ab9095 Add MFA support 2024-04-10 10:07:37 -04:00
Kevin Yue 54ccb761e5 Fix CI 2024-04-07 09:42:00 -04:00
Kevin Yue f72dbd1dec Release 2.1.3 2024-04-07 20:46:23 +08:00
Kevin Yue 0814c3153a Merge branch 'feature/as_gateway' into release/2.1.3 2024-04-07 20:44:29 +08:00
Kevin Yue 9f085e8b8c Improve code style 2024-04-07 20:31:05 +08:00
Kevin Yue 0188752c0a Bump version 2.1.3 2024-04-06 20:07:57 +08:00
Kevin Yue a884c41813 Rename PreloginCredential 2024-04-06 19:40:08 +08:00
Kevin Yue 879b977321 Add message for the '--as-gateway' option 2024-04-06 19:26:42 +08:00
Kevin Yue e9cb253be1 Update dependencies 2024-04-06 19:14:31 +08:00
Kevin Yue 07eacae385 Add '--as-gateway' option (#318) 2024-04-06 19:07:09 +08:00
Kevin Yue 8446874290 Decode extracted gpcallback 2024-04-05 18:01:09 +08:00
Kevin Yue c347f97b95 Update vite 2024-04-04 18:34:58 +08:00
Kevin Yue 29cfa9e24b Polish authentication 2024-04-04 18:31:48 +08:00
Kevin Yue 1b1ce882a5 Update CI 2024-04-03 21:17:24 +08:00
Kevin Yue e9f2dbf9ea Support CAS authentication 2024-04-03 06:40:40 -04:00
Kevin Yue 7c6ae315e1 Fix CI 2024-04-02 21:46:30 +08:00
Kevin Yue cec0d22dc8 Support CAS authentication 2024-04-02 20:06:00 +08:00
Kevin Yue b2ca82e105 Update changelog 2024-03-29 07:55:10 -04:00
Kevin Yue 5ba6b1d5fc Merge branch 'hotfix/handle_network_error' into release/2.1.2 2024-03-29 07:52:17 -04:00
Kevin Yue a96e77c758 Bump version 2.1.2 2024-03-29 07:48:02 -04:00
Kevin Yue 79e0f0c7c1 Handle portal endpoint network error 2024-03-29 01:57:53 -04:00
Kevin Yue 187ca778f2 Release 2.1.1 2024-03-25 21:42:16 +08:00
Kevin Yue 2d1aa3ba8c Handle the gateway endpoint error
Related: #338
2024-03-25 21:03:54 +08:00
Kevin Yue 08bd4efefa Improve the error message
Related #327
2024-03-23 20:05:54 +08:00
Kevin Yue 558485f5a9 Add the --hip option 2024-03-17 18:41:42 +08:00
Kevin Yue cff2ff9dbe Update dependencies 2024-03-16 21:24:41 +08:00
Kevin Yue d5d92cfbee Ensure vpnc_script and csd_wrapper executable 2024-03-16 21:06:49 +08:00
Kevin Yue a00f6a8cba Add vpnc_script location, fix #336 2024-03-16 12:05:09 +08:00
Kevin Yue 59dee3d767 Update packaging script 2024-03-11 07:55:49 -04:00
Kevin Yue e94661b213 Fix build-depends 2024-03-10 08:32:35 -04:00
Kevin Yue 9dea81bdff Update CI 2024-03-10 16:31:18 +08:00
Kevin Yue 6ff552c1ec Update packaging 2024-03-05 08:12:26 -05:00
Kevin Yue c1b1ea1a67 Update install instructions 2024-02-27 21:05:52 +08:00
Kevin Yue 167a8f4037 Release 2.1.0 2024-02-26 23:45:37 +08:00
Kevin Yue 47776d54d9 Improve packaging (#328)
* Add gpgui-helper (#326)

* Add packaging
2024-02-26 23:33:39 +08:00
Kevin Yue 5767c252b7 Update issue templates 2024-02-17 20:39:11 +08:00
Kevin Yue a2efcada02 Update README.md 2024-02-13 04:07:18 -05:00
Kevin Yue e68aa0ffa6 Update README.md 2024-02-13 03:24:20 -05:00
Kevin Yue 66bcccabe4 Add mtu option 2024-02-10 18:19:37 +08:00
Kevin Yue 3736189308 Retry auth if failed to obtain the auth cookie 2024-02-07 19:33:58 +08:00
Kevin Yue c408482c55 Update install instruction 2024-02-06 20:30:57 +08:00
Kevin Yue 00b0b8eb84 Update README.md 2024-02-06 12:44:18 +08:00
Wesley vieira b14294f131 update readme with the prerequisites (#313) 2024-02-06 12:43:26 +08:00
Kevin Yue db9249bd61 Support HIP report (#309) 2024-02-05 18:35:45 +08:00
Kevin Yue 662e4d0b8a Support specify csd-wrapper 2024-02-03 13:12:17 +08:00
Kevin Yue 13be9179f5 Bump version 2.0.0 2024-02-01 22:41:36 +08:00
Kevin Yue 0a55506077 Do not error when region is not found 2024-02-01 21:52:31 +08:00
Kevin Yue 8860efa82e Simplify code 2024-01-29 07:54:58 -05:00
Kevin Yue 9bc0994a8e Update gpauth app icon 2024-01-29 06:10:34 -05:00
Kevin Yue 1f50e4d82b Add CI 2024-01-28 20:34:15 +08:00
Kevin Yue 995d1216ea Bump version 2.0.0-beta8 2024-01-28 20:21:33 +08:00
Kevin Yue 196e91289c Update format 2024-01-28 05:11:46 -05:00
Kevin Yue b2bb35994f Support connect gateway (#306) 2024-01-28 11:41:48 +08:00
Kevin Yue 6fe6a1387a Update README.md 2024-01-25 20:30:23 +08:00
Kevin Yue aac401e7ee Perform gateway prelogin when failed to login to gateway 2024-01-23 09:26:45 -05:00
Kevin Yue 9655b735a1 Fix ignore TLS errors 2024-01-22 23:20:25 -05:00
Kevin Yue c3bd7aeb93 Support SSO using default browser 2024-01-22 09:43:44 -05:00
Kevin Yue 0b55a80317 Bump version 2.0.0-beta4 2024-01-21 11:05:15 -05:00
Kevin Yue c6315bf384 Handle auth window auth fail 2024-01-21 11:04:35 -05:00
Kevin Yue 87b965f80c Add default os-version for CLI 2024-01-21 08:54:08 -05:00
Kevin Yue b09b21ae0f Bump 2.0.0-beta3 2024-01-21 05:43:49 -05:00
Kevin Yue 7e372cd113 Align with the old behavior of the portal config request (#293) 2024-01-21 18:31:39 +08:00
Kevin Yue 1e211e8912 Update README.md 2024-01-20 22:55:35 -05:00
Kevin Yue 8bc4049a0f Enhancements and Bug Fixes: Align Pre-login Behavior, TLS Error Ignorance, GUI Auto-Launch, and Documentation Improvements (#291) 2024-01-21 10:43:47 +08:00
Kevin Yue 03f8c98cb5 Use uzers crate 2024-01-18 08:54:08 -05:00
Kevin Yue 5c56acc677 Bump version 2.0.0-beta2 2024-01-18 08:51:11 -05:00
Kevin Yue 2d8393dcf7 Update doc (#282) 2024-01-18 20:48:40 +08:00
Kevin Yue 04a916a3e1 Refactor using Tauri (#278) 2024-01-16 22:18:20 +08:00
Kevin Yue edc13ed14d Merge pull request #265 from fftmp/master
fix link in Readme
2023-11-13 18:04:46 +08:00
fftmp dd737bc8c5 fix link in Readme 2023-11-10 22:58:40 +04:00
Kevin Yue 939f2bd94a Merge pull request #263 from iamtalhaasghar/master
chores: update opensuse leap repo link
2023-11-06 09:31:14 +08:00
Talha Asghar abffa21268 chores: update opensuse leap repo link
The old link is broken!
2023-11-04 09:55:26 +05:00
Danilo Nascimento 705b03c0bb Fix: handshake failed by ERR_CERT_AUTHORITY_INVALID (#240) 2023-06-27 20:30:25 +08:00
Dimitri Papadopoulos Orfanos 7bef2ccc68 Fix typos found by codespell (#234) 2023-05-09 09:44:05 +08:00
Dmitry Mikushin bffc5d733b Fixing binary paths array wrongly iterated up to binaryPaths->length() (#216) 2023-02-17 12:08:09 +08:00
545 changed files with 77760 additions and 7278 deletions

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
BasedOnStyle: LLVM
IndentWidth: 8
TabWidth: 8
UseTab: Always
ColumnLimit: 80
BreakBeforeBraces: Linux
+80
View File
@@ -0,0 +1,80 @@
FROM ubuntu:22.04
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.89.0 \
DEBIAN_FRONTEND=noninteractive
# Install all system dependencies in a single layer and clean up apt cache
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
# Common utilities
dh-autoreconf \
sudo \
ca-certificates \
curl \
gnupg \
git \
less \
wget \
file \
software-properties-common \
# libopenconnect-dev to install the related dependencies for building openconnect from source
# Otherwise, we have to install them manually one by one
libopenconnect-dev \
# Tauri dependencies
libwebkit2gtk-4.1-dev \
build-essential \
libxdo-dev \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev; \
# Clean up apt cache to reduce image size
apt-get clean; \
rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN set -eux; \
groupadd --gid $USER_GID $USERNAME; \
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME; \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME; \
chmod 0440 /etc/sudoers.d/$USERNAME
# Install Rust
RUN set -eux; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUST_VERSION --profile minimal; \
chown -R $USERNAME:$USERNAME $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version
# Install Node.js and global npm packages
RUN set -eux; \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -; \
apt-get install -y --no-install-recommends nodejs; \
corepack enable; \
npm install -g diff-so-fancy; \
# Clean up apt cache
apt-get clean; \
rm -rf /var/lib/apt/lists/*
USER $USERNAME
# Install Oh My Zsh
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \
-t https://github.com/denysdovhan/spaceship-prompt \
-a 'SPACESHIP_PROMPT_ADD_NEWLINE="false"' \
-a 'SPACESHIP_PROMPT_SEPARATE_LINE="false"' \
-p git \
-p https://github.com/zsh-users/zsh-autosuggestions \
-p https://github.com/zsh-users/zsh-completions; \
# Change the default shell
sudo chsh -s /bin/zsh $USERNAME; \
# Change the XTERM to xterm-256color
sed -i 's/TERM=xterm/TERM=xterm-256color/g' $HOME/.zshrc;
+10
View File
@@ -0,0 +1,10 @@
{
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--privileged",
"--cap-add=NET_ADMIN",
"--device=/dev/net/tun"
]
}
+6
View File
@@ -0,0 +1,6 @@
.build
.git
.vendor
apps/gpgui-helper/node_modules
target
vendor.tar.xz
+10 -7
View File
@@ -1,13 +1,16 @@
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace=true
charset = utf-8
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.sh]
[{*.c,*.h}]
indent_style = tab
indent_size = 8
[{Makefile,Makefile.in}]
indent_style = tab
+115
View File
@@ -0,0 +1,115 @@
name: Bug report
description: Report a problem with GP Connect or gpclient.
body:
- type: markdown
attributes:
value: |
Thank you for reporting a problem. You can report against your installed version; you do not need to upgrade first.
Review everything before posting. Remove passwords, cookies, tokens, SAML payloads, and private VPN addresses. Do not attach a complete environment dump.
- type: dropdown
id: component
attributes:
label: Affected component
options:
- CLI connection
- GP Connect GUI
- Login window or browser authentication
- Installation or update
- Credential storage
- Other or unsure
validations:
required: true
- type: input
id: version
attributes:
label: Application version
description: Run gpclient --version, or use the version shown in the GUI's About dialog. Include helper versions if relevant.
placeholder: "For example: gpclient 3.0.1"
validations:
required: true
- type: dropdown
id: installation
attributes:
label: Installation method
options:
- APT
- AUR
- RPM package or repository
- Nix
- Homebrew
- Downloaded release package
- FreeBSD or OpenBSD package
- Source build
- Other or unknown
validations:
required: true
- type: input
id: os
attributes:
label: Operating system and version
description: Include the Linux distribution, macOS version, or FreeBSD/OpenBSD version, and architecture if known.
placeholder: "For example: Fedora 43 x86_64, macOS 26 arm64, or FreeBSD 14.4 amd64"
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Steps to reproduce
description: Include the exact command and options, or the GUI steps. Replace private portal names with a placeholder and omit credentials.
placeholder: |
1. Run sudo gpclient connect <portal> --browser
2. ...
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
validations:
required: true
- type: textarea
id: actual
attributes:
label: Actual behavior
description: Describe the failure and any error message.
validations:
required: true
- type: textarea
id: regression
attributes:
label: Last working version and recent changes
description: If this worked before, give the last working app version and any recent OS, desktop, graphics driver, or package updates. It is okay if you do not know.
- type: textarea
id: diagnostics
attributes:
label: Diagnostics
description: Run gpclient diagnostics as your normal desktop user, without sudo. If the command is unavailable, use the standalone script linked below or provide the relevant information manually. Reports include raw desktop identifiers and are not guaranteed anonymous; review before posting.
render: text
- type: markdown
attributes:
value: |
**Older versions:** download and inspect the [standalone diagnostic script](https://github.com/yuezk/GlobalProtect-openconnect/blob/dev/scripts/collect-diagnostics.sh), then run it with `sh collect-diagnostics.sh`. See [collection instructions](https://github.com/yuezk/GlobalProtect-openconnect/blob/dev/docs/diagnostics.md). Do not pipe a download directly into a shell.
If you cannot run either collector, provide the relevant details below. You do not need graphics details for unrelated connection problems.
- type: textarea
id: rendering
attributes:
label: Window or rendering failures only
description: Desktop/compositor and version; Wayland or X11; GPU and driver version; GTK/WebKitGTK version when available; VM or remote session; any rendering environment overrides. Skip for unrelated problems. The diagnostics report may already contain this information.
- type: textarea
id: authentication
attributes:
label: Authentication or credential storage failures only
description: Embedded login window or external browser (name/version)? At what stage does it stop? For credential storage errors, include the keyring implementation or macOS Keychain error. Omit cookies, tokens, passwords, and SAML data.
- type: textarea
id: logs
attributes:
label: Relevant logs
description: For the CLI, paste relevant terminal output. For the GUI, use its built-in option to open or export logs, if available. Review and remove sensitive authentication data before posting; avoid full verbose logs unless requested.
render: text
- type: textarea
id: screenshots
attributes:
label: Screenshots and additional context
description: Attach screenshots if helpful. Hide private portal names, account details, and other sensitive content.
+98
View File
@@ -0,0 +1,98 @@
name: Build Linux GUI
on:
workflow_call:
inputs:
gp_ref:
required: true
type: string
gpgui_ref:
required: true
type: string
channel:
required: true
type: string
builder:
required: true
type: string
artifact_suffix:
default: ""
type: string
verify_desktop_assets:
default: false
type: boolean
secrets:
GH_PAT:
required: true
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- runner: ubuntu-latest
arch: amd64
- runner: ubuntu-24.04-arm
arch: ubuntu-24.04-arm
runs-on: ${{ matrix.os.runner }}
name: build (${{ matrix.os.arch }})
steps:
- uses: pnpm/action-setup@v5
with:
version: 9
- name: Prepare workspace
run: rm -rf gpgui-source && mkdir gpgui-source
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ inputs.gp_ref }}
path: gpgui-source/gp
submodules: recursive
- name: Checkout gpgui
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/gpgui
ref: ${{ inputs.gpgui_ref }}
path: gpgui-source/gpgui
- name: Verify Linux desktop assets
if: matrix.os.arch == 'amd64' && inputs.verify_desktop_assets
run: gpgui-source/gp/scripts/verify-linux-desktop-assets.sh gpgui-source/gpgui
- name: Tarball
run: |
cd gpgui-source
tar -czf gpgui.tar.gz gpgui gp
- name: Build gpgui in Docker
env:
GPGUI_BUILDER: ${{ inputs.builder }}
GPGUI_BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
run: |
docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \
-e GPGUI_BUILD_VERSION \
-e GPGUI_UPDATE_CHANNEL \
-e GPGUI_LICENSE_SIGNING_KEYS \
-v "$(pwd)/gpgui-source:/workspace" "yuezk/gpdev:$GPGUI_BUILDER"
- name: Install gpgui in Docker
env:
GPGUI_BUILDER: ${{ inputs.builder }}
run: |
cd gpgui-source
tar -xJf ./*.bin.tar.xz
docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \
-v "$(pwd):/workspace" "yuezk/gpdev:$GPGUI_BUILDER" \
bash -c "cd /workspace/gpgui_*/ && ./gpgui --version"
- name: Upload gpgui
uses: actions/upload-artifact@v7
with:
name: artifact-gpgui${{ inputs.artifact_suffix }}-${{ matrix.os.arch }}
if-no-files-found: error
path: |
gpgui-source/*.bin.tar.xz
gpgui-source/*.bin.tar.xz.sha256
+968
View File
@@ -0,0 +1,968 @@
name: Build
on:
workflow_dispatch:
inputs:
channel:
description: 'Build channel. Stable builds require matching vX.Y.Z refs in both repositories.'
required: true
default: snapshot
type: choice
options: [snapshot, stable]
build_only:
description: 'Build and test artifacts without publishing releases, images, or update feeds'
required: true
default: false
type: boolean
gp_branch:
description: 'GlobalProtect-openconnect ref to build (use the matching tag for stable builds)'
required: true
default: dev
gpgui_branch:
description: 'gpgui ref to build (use the matching tag for stable builds)'
required: true
default: dev
build_macos:
description: 'Build Apple Silicon artifacts for this run'
required: true
default: false
type: boolean
build_bsd:
description: 'Build FreeBSD/OpenBSD packages for this run'
required: true
default: false
type: boolean
build_bsd_arm64:
description: 'Build optional FreeBSD/OpenBSD arm64 packages for this run. Slow and disabled by default'
required: true
default: false
type: boolean
push:
paths-ignore:
- LICENSE
- "*.md"
- .vscode
- .devcontainer
branches:
- main
tags:
- v*.*.*
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && (inputs.build_only && github.run_id || 'release') || github.ref }}
cancel-in-progress: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') }}
jobs:
validate-inputs:
runs-on: ubuntu-latest
steps:
- name: Validate stable refs
env:
EVENT: ${{ github.event_name }}
CHANNEL: ${{ inputs.channel }}
GP_REF: ${{ inputs.gp_branch }}
GPGUI_REF: ${{ inputs.gpgui_branch }}
run: |
if [[ "$EVENT" == workflow_dispatch && "$CHANNEL" == stable ]]; then
if [[ ! "$GP_REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ || "$GP_REF" != "$GPGUI_REF" ]]; then
echo "Stable builds require matching vX.Y.Z refs" >&2
exit 1
fi
fi
test-gp:
needs: validate-inputs
runs-on: ubuntu-latest
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
submodules: recursive
- name: Run Rust tests as a non-root user with focused privilege checks
run: |
docker run --rm \
--user vscode \
-e HOME=/home/vscode \
-e CARGO_TARGET_DIR=/tmp/gp-test-target \
-e COREPACK_INTEGRITY_KEYS=0 \
-e LIBXML2_STATIC=1 \
-v "$(pwd):/workspace:ro" \
-w /workspace \
yuezk/gpdev:binary-builder-tauri2 \
sh -ec '
test "$(id -u)" -ne 0
# Tauri generates schemas in the source tree. Keep the host checkout read-only.
cp -R /workspace /tmp/gp-test-workspace
cd /tmp/gp-test-workspace
cargo test --workspace --locked
# Exercise only the paths that require an actual root process.
sudo -E env PATH="$PATH" PKEXEC_UID="$(id -u)" cargo test --locked -p gpapi \
process::auth_launcher::tests::custom_authenticator_crash_does_not_request_recovery -- --exact
sudo -E env PATH="$PATH" PKEXEC_UID="$(id -u)" cargo test --locked -p gpapi \
process::collection::tests::root_owned_sticky_directories_protect_collectors_without_trusting_writable_files -- --exact
sudo -E env PATH="$PATH" PKEXEC_UID="$(id -u)" cargo test --locked -p gpservice \
--bin gpservice device_anchor::tests
'
tarball:
needs: validate-inputs
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup@v5
with:
version: 9
- name: Prepare workspace
run: rm -rf source && mkdir -p source/artifacts
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
path: source/gp
submodules: recursive
- name: Create tarball
env:
IS_SNAPSHOT: ${{ (github.event_name == 'workflow_dispatch' && inputs.channel == 'snapshot') || (github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/')) }}
run: |
cd source/gp
# Stable manual builds use tagged source even when dispatched from main.
if [[ "$IS_SNAPSHOT" == true ]]; then
touch SNAPSHOT
fi
make tarball
mv -v .build/tarball/*.tar.gz ../artifacts/
- name: Generate RPM spec file
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
run: |
cd source/gp
make init-rpm \
REVISION='1%{?dist}' \
RPM_SOURCE=https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${RELEASE_TAG}/%{name}-%{version}.tar.gz
mv -v .build/rpm/*.spec ../artifacts/
- name: Upload tarball
uses: actions/upload-artifact@v7
with:
name: artifact-source
if-no-files-found: error
path: |
source/artifacts/*
tarball-offline:
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
needs:
- tarball
steps:
- uses: pnpm/action-setup@v5
with:
version: 9
- name: Prepare workspace
run: rm -rf source-offline && mkdir source-offline
- name: Download tarball
uses: actions/download-artifact@v8
with:
name: artifact-source
path: source-offline
- name: Create offline tarball
run: |
cd source-offline
offline_tarball=$(basename *.tar.gz .tar.gz).offline.tar.gz
# Extract the tarball
tar -xzf *.tar.gz
cd */
make tarball OFFLINE=1
# Rename the tarball to .offline.tar.gz
mv -v .build/tarball/*.tar.gz ../$offline_tarball
- name: Upload offline tarball
uses: actions/upload-artifact@v7
with:
path: source-offline/*.offline.tar.gz
name: artifact-source-offline
if-no-files-found: error
build-gp:
if: ${{ !(startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.channel == 'stable')) }}
needs:
- tarball
strategy:
fail-fast: false
matrix:
os:
- runner: ubuntu-latest
arch: amd64
- runner: ubuntu-24.04-arm
arch: ubuntu-24.04-arm
package: [deb, rpm, pkg, apk, binary, ubuntu-rolling]
runs-on: ${{ matrix.os.runner }}
name: build-gp (${{ matrix.package }}, ${{ matrix.os.arch }})
steps:
- name: Prepare workspace
run: |
rm -rf build-gp-${{ matrix.package }}
mkdir -p build-gp-${{ matrix.package }}
- name: Download tarball
uses: actions/download-artifact@v8
with:
name: artifact-source
path: build-gp-${{ matrix.package }}
- name: Build ${{ matrix.package }} package in Docker
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
run: |
docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \
-e LIBXML2_STATIC=1 \
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
- name: Install ${{ matrix.package }} package in Docker
run: |
docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \
-e GPGUI_INSTALLED=0 \
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
bash install.sh
# Don't upload package for ubuntu-rolling because it's duplicate of deb package
- name: Upload ${{ matrix.package }} package
if: ${{ matrix.package != 'ubuntu-rolling' }}
uses: actions/upload-artifact@v7
with:
name: artifact-gp-${{ matrix.package }}-${{ matrix.os.arch }}
if-no-files-found: error
path: |
build-gp-${{ matrix.package }}/artifacts/*
build-docker-image:
if: ${{ !(startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.channel == 'stable')) }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
platform: linux/amd64
- runner: ubuntu-24.04-arm
platform: linux/arm64
runs-on: ${{ matrix.runner }}
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.build_only }}
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push by digest
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.build_only }}
id: build
uses: docker/build-push-action@v7
with:
context: .
file: packaging/docker/alpine/Dockerfile
platforms: ${{ matrix.platform }}
outputs: type=image,name=yuezk/globalprotect-openconnect,push-by-digest=true,name-canonical=true,push=true
- name: Build local image for verification
if: ${{ github.event_name == 'workflow_dispatch' && inputs.build_only }}
uses: docker/build-push-action@v7
with:
context: .
file: packaging/docker/alpine/Dockerfile
platforms: ${{ matrix.platform }}
tags: yuezk/globalprotect-openconnect:build-test
load: true
push: false
- name: Verify CLI tools
env:
IMAGE: yuezk/globalprotect-openconnect
DIGEST: ${{ steps.build.outputs.digest }}
BUILD_ONLY: ${{ github.event_name == 'workflow_dispatch' && inputs.build_only }}
run: |
image_ref="$IMAGE@$DIGEST"
if [[ "$BUILD_ONLY" == "true" ]]; then
image_ref="$IMAGE:build-test"
fi
docker run --rm "$image_ref" --help
docker run --rm --entrypoint gpauth "$image_ref" --help
docker run --rm --entrypoint sh "$image_ref" -lc 'test "$(id -u gp)" = "1000" && test "$SUDO_UID" = "1000"'
- name: Export digest
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.build_only }}
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.build_only }}
uses: actions/upload-artifact@v7
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
build-gpgui-glibc:
needs: validate-inputs
name: build-gpgui (glibc)
uses: ./.github/workflows/build-gpgui-linux.yaml
with:
gp_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
gpgui_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
builder: gpgui-builder-tauri2
verify_desktop_assets: true
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
build-gpgui-musl:
needs: validate-inputs
name: build-gpgui (musl)
uses: ./.github/workflows/build-gpgui-linux.yaml
with:
gp_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
gpgui_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
builder: gpgui-alpine-builder-tauri2
artifact_suffix: -musl
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
nix-source:
needs: [build-gpgui-glibc]
strategy:
fail-fast: false
matrix:
platform:
- runner: ubuntu-latest
system: x86_64-linux
artifact_arch: amd64
- runner: ubuntu-24.04-arm
system: aarch64-linux
artifact_arch: ubuntu-24.04-arm
runs-on: ${{ matrix.platform.runner }}
name: nix-source (${{ matrix.platform.system }})
env:
NIX_SYSTEM: ${{ matrix.platform.system }}
NIXPKGS: locked
steps:
- name: Checkout source and dependencies
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
submodules: recursive
path: gp
- name: Download current GUI artifact
uses: actions/download-artifact@v8
with:
name: artifact-gpgui-${{ matrix.platform.artifact_arch }}
path: nix-artifacts/gui
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Configure current source and GUI inputs
run: |
echo "GP_SOURCE=$PWD/gp" >> "$GITHUB_ENV"
gui_archive=$(find "$PWD/nix-artifacts/gui" -name '*.bin.tar.xz' -type f)
test -f "$gui_archive"
echo "GP_GUI_ARCHIVE=$gui_archive" >> "$GITHUB_ENV"
- name: Build source package
run: |
nix build --impure --file gp/nix/ci.nix source \
--extra-experimental-features "nix-command flakes" --print-build-logs
bash gp/scripts/tests/nix-desktop-authorization.sh result
- name: Test source runtime in NixOS
if: matrix.platform.system == 'x86_64-linux'
run: |
nix build --impure --file gp/nix/ci.nix runtime-source \
--extra-experimental-features "nix-command flakes" --print-build-logs
nix-prebuilt:
needs: [build-gp, build-gpgui-glibc]
strategy:
fail-fast: false
matrix:
platform:
- runner: ubuntu-latest
system: x86_64-linux
artifact_arch: amd64
- runner: ubuntu-24.04-arm
system: aarch64-linux
artifact_arch: ubuntu-24.04-arm
nixpkgs: [locked, nixos-25.11, nixos-26.05, nixpkgs-unstable]
runs-on: ${{ matrix.platform.runner }}
name: nix-prebuilt (${{ matrix.platform.system }}, ${{ matrix.nixpkgs }})
env:
NIX_SYSTEM: ${{ matrix.platform.system }}
NIXPKGS: ${{ matrix.nixpkgs }}
steps:
- name: Checkout packaging and tests
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
submodules: recursive
path: gp
- name: Download current Linux binary artifact
uses: actions/download-artifact@v8
with:
name: artifact-gp-binary-${{ matrix.platform.artifact_arch }}
path: nix-artifacts/binaries
- name: Download current GUI artifact
uses: actions/download-artifact@v8
with:
name: artifact-gpgui-${{ matrix.platform.artifact_arch }}
path: nix-artifacts/gui
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Configure current artifact inputs
run: |
echo "GP_SOURCE=$PWD/gp" >> "$GITHUB_ENV"
binary_archive=$(find "$PWD/nix-artifacts/binaries" -name '*.bin.tar.xz' -type f)
gui_archive=$(find "$PWD/nix-artifacts/gui" -name '*.bin.tar.xz' -type f)
test -f "$binary_archive"
test -f "$gui_archive"
echo "GP_BINARY_ARCHIVE=$binary_archive" >> "$GITHUB_ENV"
echo "GP_GUI_ARCHIVE=$gui_archive" >> "$GITHUB_ENV"
- name: Build package through host NixOS module
run: |
nix build --impure --file gp/nix/ci.nix module \
--extra-experimental-features "nix-command flakes" --print-build-logs
bash gp/scripts/tests/nix-desktop-authorization.sh result
- name: Build standalone prebuilt package
if: matrix.nixpkgs == 'locked'
run: |
nix build --impure --file gp/nix/ci.nix prebuilt \
--extra-experimental-features "nix-command flakes" --print-build-logs
- name: Test prebuilt runtime in NixOS
if: matrix.nixpkgs == 'locked' && matrix.platform.system == 'x86_64-linux'
run: |
nix build --impure --file gp/nix/ci.nix runtime-prebuilt \
--extra-experimental-features "nix-command flakes" --print-build-logs
trigger-gpgui-macos:
needs: test-gp
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_macos) || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_MACOS_ON_TAG == 'true') }}
permissions:
contents: read
runs-on: ubuntu-latest
name: trigger private macOS build
outputs:
run_id: ${{ steps.dispatch.outputs.run_id }}
run_url: ${{ steps.dispatch.outputs.run_url }}
steps:
- name: Dispatch private macOS build
id: dispatch
env:
GH_TOKEN: ${{ secrets.GPGUI_ACTIONS_TOKEN }}
PUBLIC_GH_TOKEN: ${{ github.token }}
CHANNEL: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
GP_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref_name }}
GPGUI_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
REQUEST_ID: ${{ github.run_id }}.${{ github.run_attempt }}.macos
run: |
set -euo pipefail
if [[ -z "${GH_TOKEN:-}" ]]; then
echo "GPGUI_ACTIONS_TOKEN is not configured" >&2
exit 1
fi
gp_ref_path="$(jq -rn --arg ref "$GP_REF" '$ref | @uri')"
gpgui_ref_path="$(jq -rn --arg ref "$GPGUI_REF" '$ref | @uri')"
gp_sha="$(GH_TOKEN="$PUBLIC_GH_TOKEN" gh api \
"repos/yuezk/GlobalProtect-openconnect/commits/$gp_ref_path" --jq .sha)"
gpgui_sha="$(gh api "repos/yuezk/gpgui/commits/$gpgui_ref_path" --jq .sha)"
if [[ -z "$gp_sha" || -z "$gpgui_sha" ]]; then
echo "Could not resolve release source refs" >&2
exit 1
fi
expected_title="macOS build $CHANNEL $RELEASE_TAG ($REQUEST_ID)"
jq -n \
--arg workflow_ref "$GPGUI_REF" \
--arg request_id "$REQUEST_ID" \
--arg build_version "$BUILD_VERSION" \
--arg channel "$CHANNEL" \
--arg release_tag "$RELEASE_TAG" \
--arg gp_ref "$gp_sha" \
--arg gpgui_ref "$gpgui_sha" \
'{
ref: $workflow_ref,
inputs: {
request_id: $request_id,
build_version: $build_version,
channel: $channel,
release_tag: $release_tag,
gp_ref: $gp_ref,
gpgui_ref: $gpgui_ref
}
}' | gh api --method POST \
repos/yuezk/gpgui/actions/workflows/build-macos.yaml/dispatches \
--input -
run_id=""
run_url=""
for _ in {1..40}; do
runs="$(gh api \
'repos/yuezk/gpgui/actions/workflows/build-macos.yaml/runs?event=workflow_dispatch&per_page=50')"
run_id="$(jq -r --arg title "$expected_title" \
'[.workflow_runs[] | select(.display_title == $title)] | first | .id // empty' \
<<<"$runs")"
run_url="$(jq -r --arg title "$expected_title" \
'[.workflow_runs[] | select(.display_title == $title)] | first | .html_url // empty' \
<<<"$runs")"
if [[ -n "$run_id" ]]; then
{
echo "run_id=$run_id"
echo "run_url=$run_url"
} >> "$GITHUB_OUTPUT"
echo "Triggered private workflow: $run_url"
exit 0
fi
sleep 3
done
echo "Could not locate the dispatched private workflow run" >&2
exit 1
setup-bsd-matrix:
needs: validate-inputs
runs-on: ubuntu-latest
outputs:
enabled: ${{ steps.matrix.outputs.enabled }}
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Build matrix
id: matrix
env:
BUILD_BSD_ON_TAG: ${{ startsWith(github.ref, 'refs/tags/') && vars.BUILD_BSD_ON_TAG == 'true' }}
BUILD_BSD: ${{ github.event_name == 'workflow_dispatch' && inputs.build_bsd }}
BUILD_BSD_ARM64: ${{ github.event_name == 'workflow_dispatch' && inputs.build_bsd_arm64 }}
run: |
python3 - <<'PY'
import json
import os
build_bsd = os.environ["BUILD_BSD_ON_TAG"] == "true" or os.environ["BUILD_BSD"] == "true"
build_bsd_arm64 = os.environ["BUILD_BSD_ARM64"] == "true"
include = []
def add(os_name, arch):
include.append({
"os": os_name,
"arch": arch,
"workspace": f"{os_name}-{arch}-source",
"artifact": f"artifact-bsd-{os_name}-{arch}",
"package_target": f"package-{os_name}",
"artifact_dir": os_name,
})
if build_bsd:
add("freebsd", "x86_64")
add("openbsd", "x86_64")
if build_bsd_arm64:
add("freebsd", "arm64")
add("openbsd", "arm64")
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
output.write(f"enabled={str(bool(include)).lower()}\n")
output.write(f"matrix={json.dumps({'include': include}, separators=(',', ':'))}\n")
PY
build-gpgui-frontend:
needs: setup-bsd-matrix
if: ${{ needs.setup-bsd-matrix.outputs.enabled == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup@v5
with:
version: 9
- name: Prepare workspace
run: rm -rf gpgui-frontend && mkdir gpgui-frontend
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
path: gpgui-frontend/gp
submodules: recursive
- name: Checkout gpgui
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/gpgui
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
path: gpgui-frontend/gpgui
- name: Build gpgui frontend
run: |
cd gpgui-frontend/gpgui/apps/desktop
pnpm install --frozen-lockfile
pnpm build
- name: Upload gpgui frontend
uses: actions/upload-artifact@v7
with:
name: bsd-gpgui-frontend
if-no-files-found: error
path: gpgui-frontend/gpgui/apps/desktop/dist/**
build-bsd:
needs:
- setup-bsd-matrix
- build-gpgui-frontend
if: ${{ needs.setup-bsd-matrix.outputs.enabled == 'true' }}
runs-on: ubuntu-latest
name: build-${{ matrix.os }} (${{ matrix.arch }})
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup-bsd-matrix.outputs.matrix) }}
steps:
- name: Prepare workspace
run: rm -rf "${{ matrix.workspace }}" && mkdir "${{ matrix.workspace }}"
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
path: ${{ matrix.workspace }}/gp
submodules: recursive
- name: Checkout gpgui
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/gpgui
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
path: ${{ matrix.workspace }}/gpgui
- name: Download gpgui frontend
uses: actions/download-artifact@v8
with:
name: bsd-gpgui-frontend
path: ${{ matrix.workspace }}/gpgui/apps/desktop/dist
- name: Build on FreeBSD
if: ${{ matrix.os == 'freebsd' }}
uses: vmactions/freebsd-vm@v1
with:
release: "14.4"
arch: ${{ matrix.arch }}
usesh: true
prepare: |
pkg install -y \
git \
rust \
libiconv \
gettext-tools \
autoconf \
automake \
libtool \
patch \
gmake \
pkgconf \
libxml2 \
gnutls \
p11-kit \
nettle \
gmp \
gnome-keyring \
libayatana-appindicator \
polkit \
webkit2-gtk_41
run: |
set -eu
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
cd "${{ matrix.workspace }}/gp"
cargo build --release --workspace
cd ../gpgui/apps/desktop/src-tauri
cargo build --release --workspace
cd ../../../../gp
gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui
pkg install -y ".build/${{ matrix.artifact_dir }}"/artifacts/*.pkg
gpclient --version
gpauth --version
gpgui --version
rm -rf target ../gpgui/target
find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} +
- name: Build on OpenBSD
if: ${{ matrix.os == 'openbsd' }}
uses: vmactions/openbsd-vm@v1
with:
release: "7.9"
arch: ${{ matrix.arch }}
usesh: true
prepare: |
set -eu
pkg_add -u -I
pkg_add -I \
git \
rust \
libiconv \
gettext-tools \
autoconf%2.72 \
automake%1.17 \
libtool \
gmake \
libxml \
gnutls \
p11-kit \
gmp \
lz4 \
dbus \
gnome-keyring \
polkit \
webkitgtk41 \
xdg-utils
ln -sf /usr/local/bin/autoreconf-2.72 /usr/local/bin/autoreconf
ln -sf /usr/local/bin/autoconf-2.72 /usr/local/bin/autoconf
ln -sf /usr/local/bin/autoheader-2.72 /usr/local/bin/autoheader
ln -sf /usr/local/bin/autom4te-2.72 /usr/local/bin/autom4te
ln -sf /usr/local/bin/aclocal-1.17 /usr/local/bin/aclocal
ln -sf /usr/local/bin/automake-1.17 /usr/local/bin/automake
run: |
set -eu
export AUTOCONF_VERSION=2.72
export AUTOMAKE_VERSION=1.17
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
cd "${{ matrix.workspace }}/gp"
cargo build --release --workspace
cd ../gpgui/apps/desktop/src-tauri
cargo build --release --workspace
cd ../../../../gp
gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui
pkg_add -D unsigned ".build/${{ matrix.artifact_dir }}"/artifacts/*.tgz
gpclient --version
gpauth --version
gpgui --version
rm -rf target ../gpgui/target
find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} +
- name: Upload BSD package
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
if-no-files-found: error
path: |
${{ matrix.workspace }}/gp/.build/${{ matrix.artifact_dir }}/artifacts/*
gh-release:
if: ${{ always() && ((github.event_name == 'workflow_dispatch' && !inputs.build_only) || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))) }}
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
id-token: write
attestations: write
artifact-metadata: write
needs:
- test-gp
- nix-source
- nix-prebuilt
- tarball
- tarball-offline
- build-gp
- build-docker-image
- build-gpgui-glibc
- build-gpgui-musl
- setup-bsd-matrix
- build-gpgui-frontend
- build-bsd
steps:
- name: Check required jobs
env:
NEEDS_JSON: ${{ toJson(needs) }}
BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }}
IS_STABLE: ${{ (startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.channel == 'stable')) }}
run: |
python3 - <<'PY'
import json
import os
import sys
needs = json.loads(os.environ["NEEDS_JSON"])
bsd_matrix_enabled = os.environ["BSD_MATRIX_ENABLED"] == "true"
is_stable = os.environ["IS_STABLE"] == "true"
failed = []
for name, data in needs.items():
result = data["result"]
if result in {"failure", "cancelled"}:
failed.append(f"{name}: {result}")
elif name in {"build-gp", "build-docker-image", "nix-prebuilt"} and result == "skipped" and is_stable:
continue
elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled:
continue
elif result == "skipped":
failed.append(f"{name}: {result}")
if failed:
print("Required jobs did not complete successfully:")
for item in failed:
print(f" - {item}")
sys.exit(1)
PY
- name: Prepare workspace
run: rm -rf gh-release && mkdir gh-release
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
path: gh-release/gp
submodules: recursive
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: gh-release/gp/.build/artifacts
- name: Rename APK artifacts
run: |
shopt -s nullglob
for file in gh-release/gp/.build/artifacts/artifact-gp-apk-amd64/*.apk; do
mv "$file" "${file%.apk}-x86_64.apk"
done
for file in gh-release/gp/.build/artifacts/artifact-gp-apk-ubuntu-24.04-arm/*.apk; do
mv "$file" "${file%.apk}-aarch64.apk"
done
- name: Generate release asset checksums
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
run: |
cd gh-release/gp
mkdir -p .build
scripts/release-assets.sh "$RELEASE_TAG" > .build/release-assets.txt
if [ ! -s .build/release-assets.txt ]; then
echo "No release assets found"
exit 1
fi
while IFS= read -r file; do
digest=$(sha256sum "$file" | cut -d ' ' -f 1)
printf '%s %s\n' "$digest" "$(basename "$file")"
done < .build/release-assets.txt > .build/release-assets.sha256
- name: Attest release assets
uses: actions/attest-build-provenance@v4
with:
subject-checksums: gh-release/gp/.build/release-assets.sha256
- name: Create GH release
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
run: |
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
wait-gpgui-macos:
if: ${{ !cancelled() && needs.trigger-gpgui-macos.result == 'success' }}
needs:
- trigger-gpgui-macos
runs-on: ubuntu-latest
timeout-minutes: 130
steps:
- name: Wait for private macOS build
env:
GH_TOKEN: ${{ secrets.GPGUI_ACTIONS_TOKEN }}
PRIVATE_RUN_ID: ${{ needs.trigger-gpgui-macos.outputs.run_id }}
PRIVATE_RUN_URL: ${{ needs.trigger-gpgui-macos.outputs.run_url }}
run: |
set -euo pipefail
if [[ -z "$PRIVATE_RUN_ID" ]]; then
echo "The private macOS workflow was not started" >&2
exit 1
fi
for _ in $(seq 1 480); do
run="$(gh api "repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID")"
status="$(jq -r '.status' <<<"$run")"
conclusion="$(jq -r '.conclusion // ""' <<<"$run")"
if [[ "$status" == "completed" ]]; then
echo "Private macOS build completed: $PRIVATE_RUN_URL"
if [[ "$conclusion" != "success" ]]; then
echo "Private macOS build concluded with: $conclusion" >&2
exit 1
fi
exit 0
fi
sleep 15
done
gh api --method POST \
"repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID/cancel" >/dev/null || true
echo "Private macOS build timed out: $PRIVATE_RUN_URL" >&2
exit 1
publish-docker-image:
needs:
- test-gp
- build-docker-image
if: ${{ (github.event_name == 'workflow_dispatch' && !inputs.build_only) || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download digests
uses: actions/download-artifact@v8
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Publish Docker manifest
working-directory: /tmp/digests
env:
IMAGE: yuezk/globalprotect-openconnect
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
run: |
docker buildx imagetools create -t "$IMAGE:$RELEASE_TAG" \
$(printf "$IMAGE@sha256:%s " *)
"$GITHUB_WORKSPACE/scripts/verify-docker-publication.sh" "$IMAGE:$RELEASE_TAG" /tmp/digests all
-275
View File
@@ -1,275 +0,0 @@
name: Build
on:
push:
branches:
- master
- develop
tags:
- "v*.*.*"
paths-ignore:
- LICENSE
- "*.md"
- .vscode
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
# Checkout repository and submodules
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build
run: |
./scripts/install-ubuntu.sh
# assert no library missing
test $(ldd $(which gpclient) | grep 'not found' | wc -l) -eq 0
snapshot-archive-all:
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/develop' }}
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install git-archive-all
- name: Archive all
run: |
./scripts/snapshot-archive-all.sh
- name: Verify debian package
run: |
./scripts/verify-debian-package.sh
- uses: actions/upload-artifact@v2
with:
name: snapshot-source-code
path: ./artifacts/*
snapshot-ppa:
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/develop' }}
needs: snapshot-archive-all
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: snapshot-source-code
path: artifacts
- name: Extract source code
run: |
cd $GITHUB_WORKSPACE/artifacts
mkdir deb-build && cp *.tar.gz deb-build && cd deb-build
tar xf *.tar.gz
- name: Publish PPA
uses: yuezk/publish-ppa-package@develop
with:
repository: 'ppa:yuezk/globalprotect-openconnect-snapshot'
gpg_private_key: ${{ secrets.PPA_GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.PPA_GPG_PASSPHRASE }}
pkgdir: '${{ github.workspace }}/artifacts/deb-build/globalprotect-openconnect*/'
snapshot-aur:
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/develop' }}
needs: snapshot-archive-all
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: snapshot-source-code
path: artifacts
- name: Publish AUR package
uses: yuezk/github-actions-deploy-aur@update-pkgver
with:
pkgname: globalprotect-openconnect-git
pkgbuild: ./artifacts/aur/PKGBUILD
assets: ./artifacts/aur/gp.install
update_pkgver: true
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: 'Snapshot release: git#${{ github.sha }}'
snapshot-obs:
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/develop' }}
needs: snapshot-archive-all
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: snapshot-source-code
path: artifacts
- uses: yuezk/publish-obs-package@main
with:
project: home:yuezk
package: globalprotect-openconnect-snapshot
username: yuezk
password: ${{ secrets.OBS_PASSWORD }}
files: ./artifacts/obs/*
snapshot-snap:
# if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/develop' }}
if: ${{ false }}
needs: snapshot-archive-all
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: snapshot-source-code
path: artifacts
- name: Extract source code
run: |
mkdir snap-source
tar xvf ./artifacts/globalprotect-openconnect-*tar.gz \
--directory snap-source \
--strip 1
- uses: snapcore/action-build@v1
id: build
with:
path: ./snap-source
- uses: snapcore/action-publish@v1
with:
store_login: ${{ secrets.SNAPSTORE_LOGIN }}
snap: ${{ steps.build.outputs.snap }}
release: edge
release-archive-all:
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install git-archive-all
- name: Archive all
run: |
./scripts/release-archive-all.sh
- name: Verify debian package
run: |
./scripts/verify-debian-package.sh
- uses: actions/upload-artifact@v2
with:
name: release-source-code
path: ./artifacts/*
release-ppa:
if: startsWith(github.ref, 'refs/tags/v')
needs: release-archive-all
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: release-source-code
path: artifacts
- name: Extract source code
run: |
cd $GITHUB_WORKSPACE/artifacts
mkdir deb-build && cp *.tar.gz deb-build && cd deb-build
tar xf *.tar.gz
- name: Publish PPA
uses: yuezk/publish-ppa-package@develop
with:
repository: 'ppa:yuezk/globalprotect-openconnect'
gpg_private_key: ${{ secrets.PPA_GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.PPA_GPG_PASSPHRASE }}
pkgdir: '${{ github.workspace }}/artifacts/deb-build/globalprotect-openconnect*/'
release-aur:
if: startsWith(github.ref, 'refs/tags/v')
needs: release-archive-all
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: release-source-code
path: artifacts
- name: Publish AUR package
uses: yuezk/github-actions-deploy-aur@update-pkgver
with:
pkgname: globalprotect-openconnect-git
pkgbuild: ./artifacts/aur/PKGBUILD
assets: ./artifacts/aur/gp.install
update_pkgver: true
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: 'Release ${{ github.ref }}'
release-obs:
if: startsWith(github.ref, 'refs/tags/v')
needs: release-archive-all
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: release-source-code
path: artifacts
- uses: yuezk/publish-obs-package@main
with:
project: home:yuezk
package: globalprotect-openconnect
username: yuezk
password: ${{ secrets.OBS_PASSWORD }}
files: ./artifacts/obs/*
release-github:
if: startsWith(github.ref, 'refs/tags/v')
needs:
- release-ppa
- release-aur
- release-obs
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: release-source-code
path: artifacts
- uses: softprops/action-gh-release@v1
with:
files: |
./artifacts/*.tar.gz
+118
View File
@@ -0,0 +1,118 @@
name: Nix
on:
pull_request:
paths:
- "flake.nix"
- "flake.lock"
- "nix/**"
- ".github/workflows/nix.yaml"
push:
branches:
- main
paths:
- "flake.nix"
- "flake.lock"
- "nix/**"
- ".github/workflows/nix.yaml"
permissions:
contents: read
jobs:
standalone-package:
name: standalone-package (${{ matrix.platform.system }})
strategy:
fail-fast: false
matrix:
platform:
- runner: ubuntu-latest
system: x86_64-linux
- runner: ubuntu-24.04-arm
system: aarch64-linux
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Build standalone prebuilt package
run: |
nix build .#prebuilt \
--extra-experimental-features "nix-command flakes" \
--print-build-logs
- name: Inspect prebuilt package
run: |
test -x result/bin/gpclient
test -x result/bin/gpauth
test -x result/bin/gpservice
test -x result/bin/gpgui-helper
test -x result/bin/gpgui
nixos-module:
name: nixos-module (${{ matrix.platform.system }}, ${{ matrix.nixpkgs }})
strategy:
fail-fast: false
matrix:
platform:
- runner: ubuntu-latest
system: x86_64-linux
- runner: ubuntu-24.04-arm
system: aarch64-linux
nixpkgs:
- nixos-25.11
- nixos-26.05
- nixpkgs-unstable
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Build package through host NixOS module
env:
NIXPKGS_URL: github:NixOS/nixpkgs/${{ matrix.nixpkgs }}
NIX_SYSTEM: ${{ matrix.platform.system }}
run: |
nix build \
--impure \
--extra-experimental-features "nix-command flakes" \
--print-build-logs \
--expr '
let
gp = builtins.getFlake (toString ./.);
hostNixpkgs =
builtins.getFlake (builtins.getEnv "NIXPKGS_URL");
hostSystem = hostNixpkgs.lib.nixosSystem {
system = builtins.getEnv "NIX_SYSTEM";
modules = [
gp.nixosModules.default
{
programs.globalprotect-openconnect.enable = true;
system.stateVersion = "25.11";
}
];
};
package =
hostSystem.config.programs.globalprotect-openconnect.package;
in
assert builtins.elem package
hostSystem.config.environment.systemPackages;
assert hostSystem.config.services.ayatana-indicators.enable;
package
'
- name: Inspect module package
run: |
test -x result/bin/gpclient
test -x result/bin/gpauth
test -x result/bin/gpservice
test -x result/bin/gpgui-helper
test -x result/bin/gpgui
-33
View File
@@ -1,33 +0,0 @@
name: PR Build
on:
pull_request:
branches:
- master
- develop
paths-ignore:
- LICENSE
- "*.md"
- .vscode
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
# Checkout repository and submodules
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build
run: |
./scripts/install-ubuntu.sh
# assert no library missing
test $(ldd $(which gpclient) | grep 'not found' | wc -l) -eq 0
+186
View File
@@ -0,0 +1,186 @@
name: Publish AUR git package
on:
workflow_dispatch:
inputs:
build-package:
type: boolean
description: "Build the package before publishing"
required: true
default: true
publish:
type: boolean
description: "Push PKGBUILD, .SRCINFO, and gp.install to AUR"
required: true
default: true
push:
branches:
- main
paths:
- packaging/aur/globalprotect-openconnect-git/**
- .github/workflows/publish-aur-git.yaml
permissions:
contents: read
jobs:
validate:
name: Validate AUR package
runs-on: ubuntu-latest
container: archlinux:base-devel
defaults:
run:
shell: bash
env:
AUR_PACKAGE_DIR: packaging/aur/globalprotect-openconnect-git
steps:
- name: Install checkout tools
run: pacman -Syu --noconfirm --needed git openssh
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
- name: Install build tools
run: |
pacman -Syu --noconfirm --needed \
appmenu-gtk-module \
autoconf \
automake \
cargo \
curl \
desktop-file-utils \
file \
git \
gettext \
gmp \
gnutls \
libappindicator-gtk3 \
libp11-kit \
libsecret \
libtool \
libxml2 \
lz4 \
make \
namcap \
nettle \
openssl \
patch \
pkgconf \
librsvg \
shared-mime-info \
wget \
webkit2gtk-4.1 \
xdg-utils \
zlib
- name: Save committed .SRCINFO
if: ${{ github.event_name == 'push' }}
run: cp "$AUR_PACKAGE_DIR/.SRCINFO" /tmp/committed.SRCINFO
- name: Prepare build user
run: |
useradd -m builder
chown -R builder:builder "$GITHUB_WORKSPACE"
- name: Refresh VCS package version
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
cd "$AUR_PACKAGE_DIR"
runuser -u builder -- makepkg --nobuild --noconfirm --cleanbuild
- name: Regenerate .SRCINFO
run: |
cd "$AUR_PACKAGE_DIR"
runuser -u builder -- makepkg --printsrcinfo > .SRCINFO
- name: Check committed .SRCINFO
if: ${{ github.event_name == 'push' }}
run: |
cmp -s /tmp/committed.SRCINFO "$AUR_PACKAGE_DIR/.SRCINFO" || {
diff -u /tmp/committed.SRCINFO "$AUR_PACKAGE_DIR/.SRCINFO"
echo ".SRCINFO is out of date. Regenerate it with makepkg --printsrcinfo." >&2
exit 1
}
- name: Run namcap
run: |
cd "$AUR_PACKAGE_DIR"
runuser -u builder -- namcap PKGBUILD
- name: Build package
if: ${{ github.event_name == 'workflow_dispatch' && inputs['build-package'] }}
run: |
cd "$AUR_PACKAGE_DIR"
runuser -u builder -- makepkg --noconfirm --clean --cleanbuild
- name: Upload AUR package metadata
if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish }}
uses: actions/upload-artifact@v7
with:
name: aur-package-metadata
path: |
${{ env.AUR_PACKAGE_DIR }}/PKGBUILD
${{ env.AUR_PACKAGE_DIR }}/.SRCINFO
${{ env.AUR_PACKAGE_DIR }}/gp.install
if-no-files-found: error
include-hidden-files: true
overwrite: true
publish:
name: Publish to AUR
needs: validate
if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish }}
runs-on: ubuntu-latest
container: archlinux:base-devel
defaults:
run:
shell: bash
env:
AUR_PACKAGE_DIR: /tmp/aur-package
AUR_REPO: ssh://[email protected]/globalprotect-openconnect-git.git
steps:
- name: Install publish tools
run: pacman -Syu --noconfirm --needed git openssh
- name: Download AUR package metadata
uses: actions/download-artifact@v8
with:
name: aur-package-metadata
path: ${{ env.AUR_PACKAGE_DIR }}
- name: Configure SSH
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
if [[ -z "$AUR_SSH_PRIVATE_KEY" ]]; then
echo "AUR_SSH_PRIVATE_KEY is required to publish to AUR" >&2
exit 1
fi
install -d -m 700 ~/.ssh
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur
chmod 600 ~/.ssh/aur
ssh-keyscan -t rsa,ecdsa,ed25519 aur.archlinux.org > ~/.ssh/known_hosts
- name: Publish to AUR
env:
GIT_SSH_COMMAND: ssh -i /github/home/.ssh/aur -o UserKnownHostsFile=/github/home/.ssh/known_hosts -o StrictHostKeyChecking=yes
run: |
workdir="$(mktemp -d)"
git clone "$AUR_REPO" "$workdir/aur"
cp "$AUR_PACKAGE_DIR"/PKGBUILD "$workdir/aur/PKGBUILD"
cp "$AUR_PACKAGE_DIR"/.SRCINFO "$workdir/aur/.SRCINFO"
cp "$AUR_PACKAGE_DIR"/gp.install "$workdir/aur/gp.install"
cd "$workdir/aur"
if git diff --quiet; then
echo "AUR package is already up to date"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add PKGBUILD .SRCINFO gp.install
git commit -m "Update globalprotect-openconnect-git"
git push origin master
+143
View File
@@ -0,0 +1,143 @@
name: Publish COPR
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish'
required: true
revision:
description: 'Package revision'
type: string
required: true
default: "1"
build_id:
description: 'Existing Copr build ID to verify; leave empty to submit a new build'
type: string
required: false
distros:
description: 'Space-separated distro releases, e.g. fedora-44 fedora-45; all configured architectures are included'
type: string
required: false
concurrency:
group: publish-copr
cancel-in-progress: false
permissions:
contents: read
jobs:
publish-copr:
runs-on: ubuntu-latest
container: fedora:latest
timeout-minutes: 210
defaults:
run:
shell: bash
steps:
- name: Install tools
run: dnf install -y copr-cli gh python3 zstd
- uses: actions/checkout@v6
- name: Check inputs
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
REVISION: ${{ inputs.revision }}
run: |
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ || ! "$REVISION" =~ ^[1-9][0-9]*$ ]]; then
echo "Expected a stable vX.Y.Z tag and positive package revision" >&2
exit 1
fi
gh api "repos/${{ github.repository }}/git/ref/tags/$TAG" >/dev/null
- name: Resolve publication distros
id: targets
env:
DISTROS: ${{ inputs.distros }}
BUILD_ID: ${{ inputs.build_id }}
run: |
build_args=()
if [[ -n "$BUILD_ID" ]]; then
build_args+=(--build-id "$BUILD_ID")
fi
python3 scripts/select-publication-targets.py copr \
--distros "$DISTROS" "${build_args[@]}"
- name: Download published spec
if: ${{ inputs.build_id == '' }}
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
run: |
mkdir -p publish-copr
gh release download "$TAG" \
--repo "${{ github.repository }}" \
--pattern globalprotect-openconnect.spec \
--dir publish-copr
- name: Set package revision
if: ${{ inputs.build_id == '' }}
env:
REVISION: ${{ inputs.revision }}
run: |
spec=publish-copr/globalprotect-openconnect.spec
if [[ "$(grep -c '^Release:' "$spec")" -ne 1 ]]; then
echo "Expected exactly one Release field in $spec" >&2
exit 1
fi
sed -Ei \
"s/^Release:[[:space:]]+.*/Release: ${REVISION}%{?dist}/" \
"$spec"
grep '^Release:' "$spec"
- name: Configure COPR authentication
if: ${{ inputs.build_id == '' }}
env:
COPR_CONFIG: ${{ secrets.COPR_CONFIG }}
run: |
install -d -m 700 "$HOME/.config"
printf '%s\n' "$COPR_CONFIG" > "$HOME/.config/copr"
chmod 600 "$HOME/.config/copr"
- name: Submit or select Copr build
id: build
env:
EXISTING_BUILD_ID: ${{ inputs.build_id }}
CHROOTS: ${{ steps.targets.outputs.targets }}
run: |
set -euo pipefail
build_id="$EXISTING_BUILD_ID"
if [[ -z "$build_id" ]]; then
read -r -a chroots <<< "$CHROOTS"
chroot_args=()
for chroot in "${chroots[@]}"; do
chroot_args+=(--chroot "$chroot")
done
copr-cli build --nowait yuezk/globalprotect-openconnect \
"${chroot_args[@]}" \
publish-copr/globalprotect-openconnect.spec | tee copr-submission.log
build_id="$(sed -n 's/^Created builds: \([0-9][0-9]*\)$/\1/p' copr-submission.log)"
fi
[[ "$build_id" =~ ^[0-9]+$ ]]
echo "id=$build_id" >> "$GITHUB_OUTPUT"
echo "Copr build: https://copr.fedorainfracloud.org/coprs/yuezk/globalprotect-openconnect/build/$build_id/" \
>> "$GITHUB_STEP_SUMMARY"
- name: Wait for Copr builds and public repositories
env:
TAG: ${{ inputs.tag }}
REVISION: ${{ inputs.revision }}
BUILD_ID: ${{ steps.build.outputs.id }}
CHROOTS: ${{ steps.targets.outputs.targets }}
run: |
read -r -a chroots <<< "$CHROOTS"
python3 scripts/wait-for-publication.py copr \
--chroots "${chroots[@]}" \
--build-id "$BUILD_ID" --version "${TAG#v}" --revision "$REVISION"
+112
View File
@@ -0,0 +1,112 @@
name: Publish OBS
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish'
required: true
revision:
description: 'Package revision'
type: string
required: true
default: "1"
verify_only:
description: 'Verify the existing source and publication without uploading again'
type: boolean
default: false
repositories:
description: 'Space-separated distro repositories, e.g. 16.0 openSUSE_Tumbleweed; empty keeps enabled targets'
type: string
required: false
concurrency:
group: publish-obs
cancel-in-progress: false
permissions:
contents: read
jobs:
publish-obs:
runs-on: ubuntu-latest
timeout-minutes: 210
steps:
- uses: actions/checkout@v6
- name: Install metadata decompressor
run: sudo apt-get update && sudo apt-get install -y zstd
- name: Check inputs
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
REVISION: ${{ inputs.revision }}
run: |
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ || ! "$REVISION" =~ ^[1-9][0-9]*$ ]]; then
echo "Expected a stable vX.Y.Z tag and positive package revision" >&2
exit 1
fi
gh api "repos/${{ github.repository }}/git/ref/tags/$TAG" >/dev/null
- name: Prepare OBS package
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
REVISION: ${{ inputs.revision }}
run: |
version="${TAG#v}"
archive="globalprotect-openconnect-${version}.offline.tar.gz"
source_dir="publish-obs/source/globalprotect-openconnect-${version}"
mkdir -p publish-obs/files publish-obs/source
gh release download "$TAG" \
--repo "${{ github.repository }}" \
--pattern "$archive" \
--dir publish-obs
tar -xzf "publish-obs/$archive" -C publish-obs/source
make -C "$source_dir" init-rpm \
REVISION="$REVISION" \
RPM_SOURCE='%{name}.tar.gz'
mv "publish-obs/$archive" \
publish-obs/files/globalprotect-openconnect.tar.gz
cp "$source_dir/.build/rpm/globalprotect-openconnect.spec" \
"$source_dir/.build/rpm/globalprotect-openconnect.changes" \
publish-obs/files/
- name: Select OBS publication targets
env:
REPOSITORIES: ${{ inputs.repositories }}
VERIFY_ONLY: ${{ inputs.verify_only }}
OBS_USERNAME: yuezk
OBS_PASSWORD: ${{ secrets.OBS_PASSWORD }}
run: |
verify_args=()
if [[ "$VERIFY_ONLY" == 'true' ]]; then
verify_args+=(--verify-only)
fi
python3 scripts/select-publication-targets.py obs \
--repositories "$REPOSITORIES" "${verify_args[@]}" --output publish-obs/targets.json
- name: Publish OBS package
if: ${{ !inputs.verify_only }}
uses: yuezk/publish-obs-package@main
with:
project: home:yuezk
package: globalprotect-openconnect
username: yuezk
password: ${{ secrets.OBS_PASSWORD }}
files: ./publish-obs/files/*
commit_message: 'Release ${{ inputs.tag }}-${{ inputs.revision }}'
- name: Wait for OBS builds and public repositories
env:
TAG: ${{ inputs.tag }}
REVISION: ${{ inputs.revision }}
run: |
python3 scripts/wait-for-publication.py obs \
--targets-file publish-obs/targets.json \
--version "${TAG#v}" --revision "$REVISION" --files publish-obs/files
+196
View File
@@ -0,0 +1,196 @@
name: Publish PPA
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish'
required: true
revision:
description: 'Package revision'
required: false
default: "1"
series:
description: 'Space-separated Ubuntu series. Leave empty to publish all supported series.'
type: "string"
required: false
default: ""
rust:
description: 'Rust version to use'
type: "string"
required: true
default: "1.91"
verify_only:
description: 'Verify an existing upload without building or uploading source again'
type: boolean
default: false
concurrency:
group: publish-ppa
cancel-in-progress: false
defaults:
run:
shell: bash
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check tag exists
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
REVISION: ${{ inputs.revision }}
run: |
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ || ! "$REVISION" =~ ^[1-9][0-9]*$ ]]; then
echo "Expected a stable vX.Y.Z tag and positive package revision" >&2
exit 1
fi
if ! gh api "repos/${{ github.repository }}/git/ref/tags/$TAG" >/dev/null 2>&1; then
echo "Tag $TAG does not exist"
exit 1
fi
resolve-series:
needs: check
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.resolve.outputs.matrix }}
steps:
- name: Resolve Ubuntu series
id: resolve
env:
INPUT_SERIES: ${{ inputs.series }}
run: |
sudo apt-get update
sudo apt-get install -y distro-info distro-info-data
if [[ "$INPUT_SERIES" == *","* ]]; then
echo "Use space-separated series, for example: jammy noble" >&2
exit 1
fi
series=()
if [[ -z "${INPUT_SERIES// }" ]]; then
while IFS= read -r item; do
[[ -n "$item" ]] && series+=("$item")
done < <(ubuntu-distro-info --supported)
else
read -r -a series <<< "$INPUT_SERIES"
fi
if [[ "${#series[@]}" -eq 0 ]]; then
echo "No Ubuntu series resolved" >&2
exit 1
fi
declare -A seen=()
for item in "${series[@]}"; do
ubuntu-distro-info --series "$item" >/dev/null
if [[ -n "${seen[$item]+present}" ]]; then
echo "Duplicate Ubuntu series: $item" >&2
exit 1
fi
seen[$item]=1
done
matrix="$(printf '%s\n' "${series[@]}" | jq -R . | jq -s -c '{series: .}')"
echo "Resolved matrix: $matrix"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
publish-ppa:
needs: [check, resolve-series]
name: publish-ppa (${{ matrix.series }})
runs-on: ubuntu-latest
timeout-minutes: 210
container:
image: ubuntu:${{ matrix.series }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.resolve-series.outputs.matrix) }}
steps:
- name: Install container tools
run: |
apt-get update
apt-get install -y ca-certificates curl gpg sudo python3 distro-info distro-info-data
mkdir -p /etc/apt/keyrings
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
| gpg --dearmor -o /etc/apt/keyrings/githubcli-archive-keyring.gpg
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
> /etc/apt/sources.list.d/github-cli.list
apt-get update
apt-get install -y gh
- uses: actions/checkout@v6
- name: Prepare workspace
if: ${{ !inputs.verify_only }}
run: rm -rf publish-ppa && mkdir publish-ppa
- name: Download ${{ inputs.tag }} offline source code
if: ${{ !inputs.verify_only }}
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
gh -R yuezk/GlobalProtect-openconnect \
release download ${{ inputs.tag }} \
--pattern '*.offline.tar.gz' \
--dir publish-ppa
- name: Patch the source code
if: ${{ !inputs.verify_only }}
run: |
cd publish-ppa
# Rename the source tarball without the offline suffix
archives=(./*.offline.tar.gz)
[[ "${#archives[@]}" -eq 1 && -f "${archives[0]}" ]]
archive="${archives[0]%.offline.tar.gz}.tar.gz"
mv -v -- "${archives[0]}" "$archive"
# Extract the source tarball
tar -xzf "$archive"
# Prepare the debian directory with custom files
source_dirs=(./globalprotect-openconnect-*/)
[[ "${#source_dirs[@]}" -eq 1 && -d "${source_dirs[0]}" ]]
cd "${source_dirs[0]}"
# Prepare the debian directory with custom files
mkdir -p .build/debian
cp -v packaging/deb/control.in .build/debian/control
cp -v packaging/deb/rules.in .build/debian/rules
cp -v packaging/deb/compat .build/debian/compat
cp -v packaging/deb/postrm .build/debian/postrm
sed -i "s/@BUILD_GUI_HELPER@/1/g" .build/debian/rules
sed -i "s/@BUILD_WEBVIEW_AUTH@/1/g" .build/debian/rules
# Update the control file with the correct Rust version
sed -i "s/@RUST_VERSION@/${{ inputs.rust }}/g" .build/debian/control
sed -i "s/@RUST_VERSION@/${{ inputs.rust }}/g" .build/debian/rules
sed -i "s/DISABLE_RUST_TOOLCHAIN = 0/DISABLE_RUST_TOOLCHAIN = 1/g" .build/debian/rules
- name: Publish to PPA
if: ${{ !inputs.verify_only }}
uses: yuezk/publish-ppa-package@main
with:
repository: "yuezk/globalprotect-openconnect"
gpg_private_key: ${{ secrets.PPA_GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.PPA_GPG_PASSPHRASE }}
tarball: publish-ppa/globalprotect-openconnect-*.tar.gz
debian_dir: publish-ppa/globalprotect-openconnect-*/.build/debian
deb_email: ${{ vars.DEB_EMAIL }}
deb_fullname: ${{ vars.DEB_FULLNAME }}
extra_ppa: "yuezk/globalprotect-openconnect"
series: ${{ matrix.series }}
revision: ${{ inputs.revision }}
- name: Wait for Launchpad builds and public package indexes
if: ${{ inputs.verify_only }}
env:
TAG: ${{ inputs.tag }}
REVISION: ${{ inputs.revision }}
SERIES: ${{ matrix.series }}
run: |
ubuntu_version="$(ubuntu-distro-info --series "$SERIES" --release | cut -d' ' -f1)"
python3 scripts/wait-for-publication.py ppa --series "$SERIES" \
--version "${TAG#v}-ppa${REVISION}~ubuntu${ubuntu_version}"
+38
View File
@@ -0,0 +1,38 @@
name: Release infrastructure checks
on:
pull_request:
paths:
- '.github/workflows/**'
- 'scripts/wait-for-publication.py'
- 'scripts/select-publication-targets.py'
- 'scripts/verify-docker-publication.sh'
- 'scripts/tests/test_*publication.py'
push:
branches: [main]
paths:
- '.github/workflows/**'
- 'scripts/wait-for-publication.py'
- 'scripts/select-publication-targets.py'
- 'scripts/verify-docker-publication.sh'
- 'scripts/tests/test_*publication.py'
permissions:
contents: read
jobs:
release-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Validate workflow expressions and schema
run: |
docker run --rm -v "$PWD:/repo" -w /repo \
rhysd/actionlint:1.7.12@sha256:b1934ee5f1c509618f2508e6eb47ee0d3520686341fec936f3b79331f9315667 \
-shellcheck='' -pyflakes=''
- name: Check Docker publication script
run: |
bash -n scripts/verify-docker-publication.sh
shellcheck scripts/verify-docker-publication.sh
- name: Test publication verification
run: python3 -m unittest discover -s scripts/tests -p 'test_*publication.py'
+342
View File
@@ -0,0 +1,342 @@
name: GH Release Packages
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to release'
required: true
arch:
type: choice
description: 'Architecture to build'
required: true
default: all
options:
- all
- x86_64
- arm64
release-deb:
type: boolean
description: 'Build DEB package'
required: true
default: true
release-rpm:
type: boolean
description: 'Build RPM package'
required: true
default: true
release-pkg:
type: boolean
description: 'Build PKG package'
required: true
default: true
release-apk:
type: boolean
description: 'Build APK package'
required: true
default: true
release-binary:
type: boolean
description: 'Build binary package'
required: true
default: true
release-docker:
type: boolean
description: 'Publish Docker image'
required: true
default: true
gh-release:
type: boolean
description: 'Update GitHub release'
required: true
default: true
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Check tag exists
uses: mukunku/[email protected]
id: check-tag
with:
tag: ${{ inputs.tag }}
- name: Exit if tag does not exist
run: |
if [[ "${{ steps.check-tag.outputs.exists }}" == "false" ]]; then
echo "Tag ${{ inputs.tag }} does not exist"
exit 1
fi
setup-matrix:
needs:
- check
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.result }}
steps:
- name: Set up matrix
id: set-matrix
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const inputs = ${{ toJson(inputs) }}
const { arch } = inputs
const osMap = {
"all": ["ubuntu-latest", "ubuntu-24.04-arm"],
"x86_64": ["ubuntu-latest"],
"arm64": ["ubuntu-24.04-arm"]
}
const package = Object.entries(inputs)
.filter(([key, value]) => key.startsWith('release-') && key !== 'release-docker' && value)
.map(([key, value]) => key.replace('release-', ''))
return JSON.stringify({
os: osMap[arch],
package,
})
build:
needs:
- setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- name: Prepare workspace
run: rm -rf build-${{ matrix.package }} && mkdir -p build-${{ matrix.package }}
- name: Download ${{ inputs.tag }} source code
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
gh -R yuezk/GlobalProtect-openconnect \
release download ${{ inputs.tag }} \
--pattern '*[^offline].tar.gz' \
--dir build-${{ matrix.package }}
- name: Build ${{ matrix.package }} package in Docker
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
run: |
docker run --rm \
-v $(pwd)/build-${{ matrix.package }}:/workspace \
-e COREPACK_INTEGRITY_KEYS=0 \
-e LIBXML2_STATIC=1 \
-e INCLUDE_GUI=1 \
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
- name: Install ${{ matrix.package }} package in Docker
run: |
docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \
-v $(pwd)/build-${{ matrix.package }}:/workspace \
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
bash install.sh
- name: Upload ${{ matrix.package }} package
uses: actions/upload-artifact@v7
with:
name: artifact-${{ matrix.os }}-${{ matrix.package }}
if-no-files-found: error
path: |
build-${{ matrix.package }}/artifacts/*
build-docker-image:
needs:
- check
if: ${{ inputs.release-docker }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
platform: linux/amd64
- runner: ubuntu-24.04-arm
platform: linux/arm64
runs-on: ${{ matrix.runner }}
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
- name: Prepare workspace
run: rm -rf docker-image && mkdir -p docker-image/source
- name: Download ${{ inputs.tag }} source code
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
gh -R yuezk/GlobalProtect-openconnect \
release download ${{ inputs.tag }} \
--pattern '*[^offline].tar.gz' \
--dir docker-image
tar -xzf docker-image/*.tar.gz -C docker-image/source --strip-components=1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v7
with:
context: docker-image/source
file: docker-image/source/packaging/docker/alpine/Dockerfile
platforms: ${{ matrix.platform }}
outputs: type=image,name=yuezk/globalprotect-openconnect,push-by-digest=true,name-canonical=true,push=true
- name: Verify CLI tools
env:
IMAGE: yuezk/globalprotect-openconnect
DIGEST: ${{ steps.build.outputs.digest }}
run: |
docker run --rm "$IMAGE@$DIGEST" --help
docker run --rm --entrypoint gpauth "$IMAGE@$DIGEST" --help
docker run --rm --entrypoint sh "$IMAGE@$DIGEST" -lc 'test "$(id -u gp)" = "1000" && test "$SUDO_UID" = "1000"'
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v7
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
publish-docker-image:
needs:
- build-docker-image
if: ${{ inputs.release-docker }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download digests
uses: actions/download-artifact@v8
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Publish Docker manifest
working-directory: /tmp/digests
env:
IMAGE: yuezk/globalprotect-openconnect
TAG: ${{ inputs.tag }}
run: |
VERSION="${TAG#v}"
tags=(-t "$IMAGE:$TAG")
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
tags+=(-t "$IMAGE:$VERSION" -t "$IMAGE:latest")
fi
docker buildx imagetools create "${tags[@]}" \
$(printf "$IMAGE@sha256:%s " *)
"$GITHUB_WORKSPACE/scripts/verify-docker-publication.sh" "$IMAGE:$TAG" /tmp/digests "${{ inputs.arch }}"
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
for alias in "$VERSION" latest; do
"$GITHUB_WORKSPACE/scripts/verify-docker-publication.sh" "$IMAGE:$alias" /tmp/digests "${{ inputs.arch }}"
done
fi
gh-release:
needs:
- build
runs-on: ubuntu-latest
if: ${{ inputs.gh-release }}
outputs:
stable_version: ${{ steps.stable-release.outputs.version }}
permissions:
actions: read
contents: read
id-token: write
attestations: write
artifact-metadata: write
steps:
- name: Prepare workspace
run: rm -rf gh-release && mkdir gh-release
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ github.ref }}
path: gh-release/gp
submodules: recursive
- name: Download artifact
uses: actions/download-artifact@v8
with:
path: gh-release
- name: Rename APK artifacts
run: |
shopt -s nullglob
for file in gh-release/artifact-ubuntu-latest-apk/*.apk; do
mv "$file" "${file%.apk}-x86_64.apk"
done
for file in gh-release/artifact-ubuntu-24.04-arm-apk/*.apk; do
mv "$file" "${file%.apk}-aarch64.apk"
done
- name: Generate release asset checksums
run: |
cd gh-release/gp
mkdir -p .build
scripts/release-assets.sh all "$GITHUB_WORKSPACE/gh-release" > .build/release-assets.txt
if [ ! -s .build/release-assets.txt ]; then
echo "No release assets found"
exit 1
fi
while IFS= read -r file; do
digest=$(sha256sum "$file" | cut -d ' ' -f 1)
printf '%s %s\n' "$digest" "$(basename "$file")"
done < .build/release-assets.txt > .build/release-assets.sha256
- name: Attest release assets
uses: actions/attest-build-provenance@v4
with:
subject-checksums: gh-release/gp/.build/release-assets.sha256
- name: Upload release assets
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
mapfile -t files < gh-release/gp/.build/release-assets.txt
if [[ "${{ inputs.tag }}" == "snapshot" ]]; then
for file in "${files[@]}"; do
gh release upload snapshot "$file" --clobber \
--repo yuezk/GlobalProtect-openconnect
done
else
gh-release/gp/scripts/upload-release-assets.sh "${{ inputs.tag }}" "${files[@]}"
fi
- name: Resolve stable release version
id: stable-release
env:
TAG: ${{ inputs.tag }}
run: |
if [[ "$TAG" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
fi
update-flake-hashes:
needs: gh-release
if: ${{ inputs.release-binary && inputs.arch == 'all' && needs.gh-release.outputs.stable_version != '' }}
permissions:
contents: write
pull-requests: write
uses: ./.github/workflows/update-flake-hashes.yaml
with:
version: ${{ needs.gh-release.outputs.stable_version }}
release_tag: ${{ inputs.tag }}
+148
View File
@@ -0,0 +1,148 @@
name: Update flake hashes
on:
workflow_call:
inputs:
version:
required: true
type: string
release_tag:
required: true
type: string
workflow_dispatch:
inputs:
version:
description: "Release version. Defaults to Cargo.toml workspace version."
required: false
release_tag:
description: "GitHub release tag to fetch assets from. Defaults to v<version>; use snapshot for snapshot assets."
required: false
permissions:
contents: write
pull-requests: write
jobs:
update-flake-hashes:
runs-on: ubuntu-latest
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Update Nixpkgs lock
run: |
nix flake update nixpkgs \
--extra-experimental-features "nix-command flakes"
- name: Update flake hashes
env:
RELEASE_VERSION: ${{ inputs.version }}
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
if [[ -n "$RELEASE_VERSION" ]]; then
scripts/update-flake-hashes.sh "$RELEASE_VERSION" "$RELEASE_TAG"
else
scripts/update-flake-hashes.sh "" "$RELEASE_TAG"
fi
- name: Upload updated flake
uses: actions/upload-artifact@v7
with:
name: updated-flake
path: |
flake.nix
flake.lock
if-no-files-found: error
validate-nix-prebuilt:
needs:
- update-flake-hashes
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-latest
- ubuntu-24.04-arm
nixpkgs:
- locked
- nixos-25.11
- nixos-26.05
- nixpkgs-unstable
exclude:
- runner: ubuntu-24.04-arm
nixpkgs: locked
name: validate-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
- name: Download updated flake
uses: actions/download-artifact@v8
with:
name: updated-flake
path: .
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Build prebuilt Nix package
env:
NIXPKGS: ${{ matrix.nixpkgs }}
run: |
if [[ "$NIXPKGS" == "locked" ]]; then
nix build .#prebuilt \
--extra-experimental-features "nix-command flakes" \
--print-build-logs
else
nix build .#prebuilt \
--override-input nixpkgs "github:NixOS/nixpkgs/$NIXPKGS" \
--extra-experimental-features "nix-command flakes" \
--print-build-logs
fi
- name: Inspect prebuilt Nix package
run: |
test -x result/bin/gpclient
test -x result/bin/gpauth
test -x result/bin/gpservice
test -x result/bin/gpgui-helper
test -x result/bin/gpgui
test ! -L result/bin/gpservice
test -x result/libexec/gpclient/gp-vpnc-script-installer
test -x result/libexec/gpclient/gp-hip-script-installer
result/bin/gpclient --version
result/bin/gpservice --version
result/bin/gpauth --version
if grep -R '/usr/bin/gp' result/share; then
echo "Desktop assets contain paths outside the Nix package" >&2
exit 1
fi
- name: Verify desktop authorization runs on the host
run: bash scripts/tests/nix-desktop-authorization.sh result
open-pull-request:
needs:
- validate-nix-prebuilt
runs-on: ubuntu-latest
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
- name: Download updated flake
uses: actions/download-artifact@v8
with:
name: updated-flake
path: .
- name: Open pull request
env:
GH_TOKEN: ${{ github.token }}
RELEASE_VERSION: ${{ inputs.version }}
RELEASE_TAG: ${{ inputs.release_tag }}
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION" "$RELEASE_TAG"
+14 -66
View File
@@ -1,70 +1,18 @@
# Binaries
*.rpm
*.gz
*.snap
.DS_Store
build-debian
build
artifacts
.cmake
.idea
.DS_Store
/target
.pnpm-store
.env
.vendor
*.tar.xz
# Auto generated DBus files
*_adaptor.cpp
*_adaptor.h
.cargo
.build
SNAPSHOT
SOURCE_COMMIT
gpservice_interface.*
# Tauri generated files
gen
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.so.*
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl
# Qt unit tests
target_wrapper.*
# QtCreator
*.autosave
# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCreator CMake
CMakeLists.txt.user*
# QtCreator 4.8< compilation database
compile_commands.json
# QtCreator local machine specific files for imported projects
*creator.user*
# Nix files
result
+7 -10
View File
@@ -1,10 +1,7 @@
[submodule "singleapplication"]
path = 3rdparty/SingleApplication
url = https://github.com/itay-grudev/SingleApplication.git
[submodule "plog"]
path = 3rdparty/plog
url = https://github.com/SergiusTheBest/plog.git
[submodule "3rdparty/qtkeychain"]
path = 3rdparty/qtkeychain
url = [email protected]:frankosterfeld/qtkeychain.git
[submodule "crates/openconnect/deps/openconnect"]
path = crates/openconnect/deps/openconnect
url = https://github.com/yuezk/openconnect.git
branch = globalprotect
[submodule "crates/openconnect/deps/libxml2"]
path = crates/openconnect/deps/libxml2
url = https://github.com/GNOME/libxml2.git
+14
View File
@@ -0,0 +1,14 @@
{
"configurations": [
{
"name": "Mac",
"includePath": ["crates/openconnect/deps/openconnect"],
"macFrameworkPath": ["/System/Library/Frameworks", "/Library/Frameworks"],
"intelliSenseMode": "macos-clang-x64",
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17"
}
],
"version": 4
}
+9
View File
@@ -0,0 +1,9 @@
{
"recommendations": [
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"eamodio.gitlens",
"EditorConfig.EditorConfig",
"streetsidesoftware.code-spell-checker",
]
}
+71 -23
View File
@@ -1,26 +1,74 @@
{
"files.watcherExclude": {
"**/artifacts/**": true,
},
"cSpell.words": [
"authcookie",
"badssl",
"bincode",
"chacha",
"clientos",
"cstring",
"datetime",
"disconnectable",
"distro",
"dotenv",
"dotenvy",
"dtls",
"getconfig",
"globalprotect",
"globalprotectcallback",
"gpapi",
"gpauth",
"gpcallback",
"gpclient",
"gpcommon",
"gpgui",
"gpservice",
"hidpi",
"Ivars",
"jnlp",
"LOGNAME",
"NSHTTPURL",
"NSURL",
"objc",
"oneshot",
"openconnect",
"pkcs",
"pkexec",
"pkey",
"Prelogin",
"prelogon",
"prelogonuserauthcookie",
"repr",
"reqwest",
"roxmltree",
"rspc",
"servercert",
"specta",
"sslkey",
"sysinfo",
"tanstack",
"tauri",
"tempfile",
"thiserror",
"tungstenite",
"unistd",
"unlisten",
"urlencoding",
"userauthcookie",
"utsbuf",
"uzers",
"Vite",
"vpnc",
"vpninfo",
"webbrowser",
"wmctrl",
"XAUTHORITY",
"yuezk"
],
"rust-analyzer.cargo.features": "all",
"files.associations": {
"qregularexpression": "cpp",
"qfileinfo": "cpp",
"qregularexpressionmatch": "cpp",
"qdatetime": "cpp",
"qprocess": "cpp",
"qobject": "cpp",
"qstandardpaths": "cpp",
"qmainwindow": "cpp",
"qsystemtrayicon": "cpp",
"qpushbutton": "cpp",
"qmenu": "cpp",
"qjsondocument": "cpp",
"qnetworkaccessmanager": "cpp",
"qwebengineview": "cpp",
"qprocessenvironment": "cpp",
"qnetworkreply": "cpp",
"qicon": "cpp",
"qsslsocket": "cpp",
"qapplication": "cpp"
}
"unistd.h": "c",
"utsname.h": "c",
"vpn.h": "c",
"openconnect.h": "c"
},
}
-12
View File
@@ -1,12 +0,0 @@
cmake_minimum_required(VERSION 3.10.0)
set(CMAKE_CXX_STANDARD 17)
project(inih)
add_library(inih STATIC
ini.h
ini.c
cpp/INIReader.h
cpp/INIReader.cpp
)
target_include_directories(inih PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/cpp")
-27
View File
@@ -1,27 +0,0 @@
The "inih" library is distributed under the New BSD license:
Copyright (c) 2009, Ben Hoyt
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Ben Hoyt nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY BEN HOYT ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL BEN HOYT BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-116
View File
@@ -1,116 +0,0 @@
// Read an INI file into easy-to-access name/value pairs.
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (C) 2009-2020, Ben Hoyt
// inih and INIReader are released under the New BSD license (see LICENSE.txt).
// Go to the project home page for more info:
//
// https://github.com/benhoyt/inih
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include "../ini.h"
#include "INIReader.h"
using std::string;
INIReader::INIReader(const string& filename)
{
_error = ini_parse(filename.c_str(), ValueHandler, this);
}
INIReader::INIReader(const char *buffer, size_t buffer_size)
{
string content(buffer, buffer_size);
_error = ini_parse_string(content.c_str(), ValueHandler, this);
}
int INIReader::ParseError() const
{
return _error;
}
string INIReader::Get(const string& section, const string& name, const string& default_value) const
{
string key = MakeKey(section, name);
// Use _values.find() here instead of _values.at() to support pre C++11 compilers
return _values.count(key) ? _values.find(key)->second : default_value;
}
string INIReader::GetString(const string& section, const string& name, const string& default_value) const
{
const string str = Get(section, name, "");
return str.empty() ? default_value : str;
}
long INIReader::GetInteger(const string& section, const string& name, long default_value) const
{
string valstr = Get(section, name, "");
const char* value = valstr.c_str();
char* end;
// This parses "1234" (decimal) and also "0x4D2" (hex)
long n = strtol(value, &end, 0);
return end > value ? n : default_value;
}
double INIReader::GetReal(const string& section, const string& name, double default_value) const
{
string valstr = Get(section, name, "");
const char* value = valstr.c_str();
char* end;
double n = strtod(value, &end);
return end > value ? n : default_value;
}
bool INIReader::GetBoolean(const string& section, const string& name, bool default_value) const
{
string valstr = Get(section, name, "");
// Convert to lower case to make string comparisons case-insensitive
std::transform(valstr.begin(), valstr.end(), valstr.begin(), ::tolower);
if (valstr == "true" || valstr == "yes" || valstr == "on" || valstr == "1")
return true;
else if (valstr == "false" || valstr == "no" || valstr == "off" || valstr == "0")
return false;
else
return default_value;
}
bool INIReader::HasSection(const string& section) const
{
const string key = MakeKey(section, "");
std::map<string, string>::const_iterator pos = _values.lower_bound(key);
if (pos == _values.end())
return false;
// Does the key at the lower_bound pos start with "section"?
return pos->first.compare(0, key.length(), key) == 0;
}
bool INIReader::HasValue(const string& section, const string& name) const
{
string key = MakeKey(section, name);
return _values.count(key);
}
string INIReader::MakeKey(const string& section, const string& name)
{
string key = section + "=" + name;
// Convert to lower case to make section/name lookups case-insensitive
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
return key;
}
int INIReader::ValueHandler(void* user, const char* section, const char* name,
const char* value)
{
if (!name) // Happens when INI_CALL_HANDLER_ON_NEW_SECTION enabled
return 1;
INIReader* reader = static_cast<INIReader*>(user);
string key = MakeKey(section, name);
if (reader->_values[key].size() > 0)
reader->_values[key] += "\n";
reader->_values[key] += value ? value : "";
return 1;
}
-94
View File
@@ -1,94 +0,0 @@
// Read an INI file into easy-to-access name/value pairs.
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (C) 2009-2020, Ben Hoyt
// inih and INIReader are released under the New BSD license (see LICENSE.txt).
// Go to the project home page for more info:
//
// https://github.com/benhoyt/inih
#ifndef INIREADER_H
#define INIREADER_H
#include <map>
#include <string>
// Visibility symbols, required for Windows DLLs
#ifndef INI_API
#if defined _WIN32 || defined __CYGWIN__
# ifdef INI_SHARED_LIB
# ifdef INI_SHARED_LIB_BUILDING
# define INI_API __declspec(dllexport)
# else
# define INI_API __declspec(dllimport)
# endif
# else
# define INI_API
# endif
#else
# if defined(__GNUC__) && __GNUC__ >= 4
# define INI_API __attribute__ ((visibility ("default")))
# else
# define INI_API
# endif
#endif
#endif
// Read an INI file into easy-to-access name/value pairs. (Note that I've gone
// for simplicity here rather than speed, but it should be pretty decent.)
class INIReader
{
public:
// Construct INIReader and parse given filename. See ini.h for more info
// about the parsing.
INI_API explicit INIReader(const std::string& filename);
// Construct INIReader and parse given buffer. See ini.h for more info
// about the parsing.
INI_API explicit INIReader(const char *buffer, size_t buffer_size);
// Return the result of ini_parse(), i.e., 0 on success, line number of
// first error on parse error, or -1 on file open error.
INI_API int ParseError() const;
// Get a string value from INI file, returning default_value if not found.
INI_API std::string Get(const std::string& section, const std::string& name,
const std::string& default_value) const;
// Get a string value from INI file, returning default_value if not found,
// empty, or contains only whitespace.
INI_API std::string GetString(const std::string& section, const std::string& name,
const std::string& default_value) const;
// Get an integer (long) value from INI file, returning default_value if
// not found or not a valid integer (decimal "1234", "-1234", or hex "0x4d2").
INI_API long GetInteger(const std::string& section, const std::string& name, long default_value) const;
// Get a real (floating point double) value from INI file, returning
// default_value if not found or not a valid floating point value
// according to strtod().
INI_API double GetReal(const std::string& section, const std::string& name, double default_value) const;
// Get a boolean value from INI file, returning default_value if not found or if
// not a valid true/false value. Valid true values are "true", "yes", "on", "1",
// and valid false values are "false", "no", "off", "0" (not case sensitive).
INI_API bool GetBoolean(const std::string& section, const std::string& name, bool default_value) const;
// Return true if the given section exists (section must contain at least
// one name=value pair).
INI_API bool HasSection(const std::string& section) const;
// Return true if a value exists with the given section and field names.
INI_API bool HasValue(const std::string& section, const std::string& name) const;
private:
int _error;
std::map<std::string, std::string> _values;
static std::string MakeKey(const std::string& section, const std::string& name);
static int ValueHandler(void* user, const char* section, const char* name,
const char* value);
};
#endif // INIREADER_H
-298
View File
@@ -1,298 +0,0 @@
/* inih -- simple .INI file parser
SPDX-License-Identifier: BSD-3-Clause
Copyright (C) 2009-2020, Ben Hoyt
inih is released under the New BSD license (see LICENSE.txt). Go to the project
home page for more info:
https://github.com/benhoyt/inih
*/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "ini.h"
#if !INI_USE_STACK
#if INI_CUSTOM_ALLOCATOR
#include <stddef.h>
void* ini_malloc(size_t size);
void ini_free(void* ptr);
void* ini_realloc(void* ptr, size_t size);
#else
#include <stdlib.h>
#define ini_malloc malloc
#define ini_free free
#define ini_realloc realloc
#endif
#endif
#define MAX_SECTION 50
#define MAX_NAME 50
/* Used by ini_parse_string() to keep track of string parsing state. */
typedef struct {
const char* ptr;
size_t num_left;
} ini_parse_string_ctx;
/* Strip whitespace chars off end of given string, in place. Return s. */
static char* rstrip(char* s)
{
char* p = s + strlen(s);
while (p > s && isspace((unsigned char)(*--p)))
*p = '\0';
return s;
}
/* Return pointer to first non-whitespace char in given string. */
static char* lskip(const char* s)
{
while (*s && isspace((unsigned char)(*s)))
s++;
return (char*)s;
}
/* Return pointer to first char (of chars) or inline comment in given string,
or pointer to NUL at end of string if neither found. Inline comment must
be prefixed by a whitespace character to register as a comment. */
static char* find_chars_or_comment(const char* s, const char* chars)
{
#if INI_ALLOW_INLINE_COMMENTS
int was_space = 0;
while (*s && (!chars || !strchr(chars, *s)) &&
!(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) {
was_space = isspace((unsigned char)(*s));
s++;
}
#else
while (*s && (!chars || !strchr(chars, *s))) {
s++;
}
#endif
return (char*)s;
}
/* Similar to strncpy, but ensures dest (size bytes) is
NUL-terminated, and doesn't pad with NULs. */
static char* strncpy0(char* dest, const char* src, size_t size)
{
/* Could use strncpy internally, but it causes gcc warnings (see issue #91) */
size_t i;
for (i = 0; i < size - 1 && src[i]; i++)
dest[i] = src[i];
dest[i] = '\0';
return dest;
}
/* See documentation in header file. */
int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
void* user)
{
/* Uses a fair bit of stack (use heap instead if you need to) */
#if INI_USE_STACK
char line[INI_MAX_LINE];
int max_line = INI_MAX_LINE;
#else
char* line;
size_t max_line = INI_INITIAL_ALLOC;
#endif
#if INI_ALLOW_REALLOC && !INI_USE_STACK
char* new_line;
size_t offset;
#endif
char section[MAX_SECTION] = "";
char prev_name[MAX_NAME] = "";
char* start;
char* end;
char* name;
char* value;
int lineno = 0;
int error = 0;
#if !INI_USE_STACK
line = (char*)ini_malloc(INI_INITIAL_ALLOC);
if (!line) {
return -2;
}
#endif
#if INI_HANDLER_LINENO
#define HANDLER(u, s, n, v) handler(u, s, n, v, lineno)
#else
#define HANDLER(u, s, n, v) handler(u, s, n, v)
#endif
/* Scan through stream line by line */
while (reader(line, (int)max_line, stream) != NULL) {
#if INI_ALLOW_REALLOC && !INI_USE_STACK
offset = strlen(line);
while (offset == max_line - 1 && line[offset - 1] != '\n') {
max_line *= 2;
if (max_line > INI_MAX_LINE)
max_line = INI_MAX_LINE;
new_line = ini_realloc(line, max_line);
if (!new_line) {
ini_free(line);
return -2;
}
line = new_line;
if (reader(line + offset, (int)(max_line - offset), stream) == NULL)
break;
if (max_line >= INI_MAX_LINE)
break;
offset += strlen(line + offset);
}
#endif
lineno++;
start = line;
#if INI_ALLOW_BOM
if (lineno == 1 && (unsigned char)start[0] == 0xEF &&
(unsigned char)start[1] == 0xBB &&
(unsigned char)start[2] == 0xBF) {
start += 3;
}
#endif
start = lskip(rstrip(start));
if (strchr(INI_START_COMMENT_PREFIXES, *start)) {
/* Start-of-line comment */
}
#if INI_ALLOW_MULTILINE
else if (*prev_name && *start && start > line) {
/* Non-blank line with leading whitespace, treat as continuation
of previous name's value (as per Python configparser). */
if (!HANDLER(user, section, prev_name, start) && !error)
error = lineno;
}
#endif
else if (*start == '[') {
/* A "[section]" line */
end = find_chars_or_comment(start + 1, "]");
if (*end == ']') {
*end = '\0';
strncpy0(section, start + 1, sizeof(section));
*prev_name = '\0';
#if INI_CALL_HANDLER_ON_NEW_SECTION
if (!HANDLER(user, section, NULL, NULL) && !error)
error = lineno;
#endif
}
else if (!error) {
/* No ']' found on section line */
error = lineno;
}
}
else if (*start) {
/* Not a comment, must be a name[=:]value pair */
end = find_chars_or_comment(start, "=:");
if (*end == '=' || *end == ':') {
*end = '\0';
name = rstrip(start);
value = end + 1;
#if INI_ALLOW_INLINE_COMMENTS
end = find_chars_or_comment(value, NULL);
if (*end)
*end = '\0';
#endif
value = lskip(value);
rstrip(value);
/* Valid name[=:]value pair found, call handler */
strncpy0(prev_name, name, sizeof(prev_name));
if (!HANDLER(user, section, name, value) && !error)
error = lineno;
}
else if (!error) {
/* No '=' or ':' found on name[=:]value line */
#if INI_ALLOW_NO_VALUE
*end = '\0';
name = rstrip(start);
if (!HANDLER(user, section, name, NULL) && !error)
error = lineno;
#else
error = lineno;
#endif
}
}
#if INI_STOP_ON_FIRST_ERROR
if (error)
break;
#endif
}
#if !INI_USE_STACK
ini_free(line);
#endif
return error;
}
/* See documentation in header file. */
int ini_parse_file(FILE* file, ini_handler handler, void* user)
{
return ini_parse_stream((ini_reader)fgets, file, handler, user);
}
/* See documentation in header file. */
int ini_parse(const char* filename, ini_handler handler, void* user)
{
FILE* file;
int error;
file = fopen(filename, "r");
if (!file)
return -1;
error = ini_parse_file(file, handler, user);
fclose(file);
return error;
}
/* An ini_reader function to read the next line from a string buffer. This
is the fgets() equivalent used by ini_parse_string(). */
static char* ini_reader_string(char* str, int num, void* stream) {
ini_parse_string_ctx* ctx = (ini_parse_string_ctx*)stream;
const char* ctx_ptr = ctx->ptr;
size_t ctx_num_left = ctx->num_left;
char* strp = str;
char c;
if (ctx_num_left == 0 || num < 2)
return NULL;
while (num > 1 && ctx_num_left != 0) {
c = *ctx_ptr++;
ctx_num_left--;
*strp++ = c;
if (c == '\n')
break;
num--;
}
*strp = '\0';
ctx->ptr = ctx_ptr;
ctx->num_left = ctx_num_left;
return str;
}
/* See documentation in header file. */
int ini_parse_string(const char* string, ini_handler handler, void* user) {
ini_parse_string_ctx ctx;
ctx.ptr = string;
ctx.num_left = strlen(string);
return ini_parse_stream((ini_reader)ini_reader_string, &ctx, handler,
user);
}
-178
View File
@@ -1,178 +0,0 @@
/* inih -- simple .INI file parser
SPDX-License-Identifier: BSD-3-Clause
Copyright (C) 2009-2020, Ben Hoyt
inih is released under the New BSD license (see LICENSE.txt). Go to the project
home page for more info:
https://github.com/benhoyt/inih
*/
#ifndef INI_H
#define INI_H
/* Make this header file easier to include in C++ code */
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
/* Nonzero if ini_handler callback should accept lineno parameter. */
#ifndef INI_HANDLER_LINENO
#define INI_HANDLER_LINENO 0
#endif
/* Visibility symbols, required for Windows DLLs */
#ifndef INI_API
#if defined _WIN32 || defined __CYGWIN__
# ifdef INI_SHARED_LIB
# ifdef INI_SHARED_LIB_BUILDING
# define INI_API __declspec(dllexport)
# else
# define INI_API __declspec(dllimport)
# endif
# else
# define INI_API
# endif
#else
# if defined(__GNUC__) && __GNUC__ >= 4
# define INI_API __attribute__ ((visibility ("default")))
# else
# define INI_API
# endif
#endif
#endif
/* Typedef for prototype of handler function. */
#if INI_HANDLER_LINENO
typedef int (*ini_handler)(void* user, const char* section,
const char* name, const char* value,
int lineno);
#else
typedef int (*ini_handler)(void* user, const char* section,
const char* name, const char* value);
#endif
/* Typedef for prototype of fgets-style reader function. */
typedef char* (*ini_reader)(char* str, int num, void* stream);
/* Parse given INI-style file. May have [section]s, name=value pairs
(whitespace stripped), and comments starting with ';' (semicolon). Section
is "" if name=value pair parsed before any section heading. name:value
pairs are also supported as a concession to Python's configparser.
For each name=value pair parsed, call handler function with given user
pointer as well as section, name, and value (data only valid for duration
of handler call). Handler should return nonzero on success, zero on error.
Returns 0 on success, line number of first error on parse error (doesn't
stop on first error), -1 on file open error, or -2 on memory allocation
error (only when INI_USE_STACK is zero).
*/
INI_API int ini_parse(const char* filename, ini_handler handler, void* user);
/* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
close the file when it's finished -- the caller must do that. */
INI_API int ini_parse_file(FILE* file, ini_handler handler, void* user);
/* Same as ini_parse(), but takes an ini_reader function pointer instead of
filename. Used for implementing custom or string-based I/O (see also
ini_parse_string). */
INI_API int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
void* user);
/* Same as ini_parse(), but takes a zero-terminated string with the INI data
instead of a file. Useful for parsing INI data from a network socket or
already in memory. */
INI_API int ini_parse_string(const char* string, ini_handler handler, void* user);
/* Nonzero to allow multi-line value parsing, in the style of Python's
configparser. If allowed, ini_parse() will call the handler with the same
name for each subsequent line parsed. */
#ifndef INI_ALLOW_MULTILINE
#define INI_ALLOW_MULTILINE 1
#endif
/* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
the file. See https://github.com/benhoyt/inih/issues/21 */
#ifndef INI_ALLOW_BOM
#define INI_ALLOW_BOM 1
#endif
/* Chars that begin a start-of-line comment. Per Python configparser, allow
both ; and # comments at the start of a line by default. */
#ifndef INI_START_COMMENT_PREFIXES
#define INI_START_COMMENT_PREFIXES ";#"
#endif
/* Nonzero to allow inline comments (with valid inline comment characters
specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match
Python 3.2+ configparser behaviour. */
#ifndef INI_ALLOW_INLINE_COMMENTS
#define INI_ALLOW_INLINE_COMMENTS 1
#endif
#ifndef INI_INLINE_COMMENT_PREFIXES
#define INI_INLINE_COMMENT_PREFIXES ";"
#endif
/* Nonzero to use stack for line buffer, zero to use heap (malloc/free). */
#ifndef INI_USE_STACK
#define INI_USE_STACK 1
#endif
/* Maximum line length for any line in INI file (stack or heap). Note that
this must be 3 more than the longest line (due to '\r', '\n', and '\0'). */
#ifndef INI_MAX_LINE
#define INI_MAX_LINE 200
#endif
/* Nonzero to allow heap line buffer to grow via realloc(), zero for a
fixed-size buffer of INI_MAX_LINE bytes. Only applies if INI_USE_STACK is
zero. */
#ifndef INI_ALLOW_REALLOC
#define INI_ALLOW_REALLOC 0
#endif
/* Initial size in bytes for heap line buffer. Only applies if INI_USE_STACK
is zero. */
#ifndef INI_INITIAL_ALLOC
#define INI_INITIAL_ALLOC 200
#endif
/* Stop parsing on first error (default is to keep parsing). */
#ifndef INI_STOP_ON_FIRST_ERROR
#define INI_STOP_ON_FIRST_ERROR 0
#endif
/* Nonzero to call the handler at the start of each new section (with
name and value NULL). Default is to only call the handler on
each name=value pair. */
#ifndef INI_CALL_HANDLER_ON_NEW_SECTION
#define INI_CALL_HANDLER_ON_NEW_SECTION 0
#endif
/* Nonzero to allow a name without a value (no '=' or ':' on the line) and
call the handler with value NULL in this case. Default is to treat
no-value lines as an error. */
#ifndef INI_ALLOW_NO_VALUE
#define INI_ALLOW_NO_VALUE 0
#endif
/* Nonzero to use custom ini_malloc, ini_free, and ini_realloc memory
allocation functions (INI_USE_STACK must also be 0). These functions must
have the same signatures as malloc/free/realloc and behave in a similar
way. ini_realloc is only needed if INI_ALLOW_REALLOC is set. */
#ifndef INI_CUSTOM_ALLOCATOR
#define INI_CUSTOM_ALLOCATOR 0
#endif
#ifdef __cplusplus
}
#endif
#endif /* INI_H */
-1
Submodule 3rdparty/plog deleted from 914e799d2b.
-14
View File
@@ -1,14 +0,0 @@
cmake_minimum_required(VERSION 3.1.0)
project(QtSignals LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
find_package(Qt5 REQUIRED COMPONENTS Core)
add_library(QtSignals STATIC sigwatch.cpp)
target_include_directories(QtSignals INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(QtSignals Qt5::Core)
-176
View File
@@ -1,176 +0,0 @@
/*
* Unix signal watcher for Qt.
*
* Copyright (C) 2014 Simon Knopp
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <sys/socket.h>
#include <unistd.h>
#include <errno.h>
#include <QMap>
#include <QSocketNotifier>
#include <QDebug>
#include "sigwatch.h"
/*!
* \brief The UnixSignalWatcherPrivate class implements the back-end signal
* handling for the UnixSignalWatcher.
*
* \see http://qt-project.org/doc/qt-5.0/qtdoc/unix-signals.html
*/
class UnixSignalWatcherPrivate : public QObject
{
UnixSignalWatcher * const q_ptr;
Q_DECLARE_PUBLIC(UnixSignalWatcher)
public:
UnixSignalWatcherPrivate(UnixSignalWatcher *q);
~UnixSignalWatcherPrivate();
void watchForSignal(int signal);
static void signalHandler(int signal);
void _q_onNotify(int sockfd);
private:
static int sockpair[2];
QSocketNotifier *notifier;
QList<int> watchedSignals;
};
int UnixSignalWatcherPrivate::sockpair[2];
UnixSignalWatcherPrivate::UnixSignalWatcherPrivate(UnixSignalWatcher *q) :
q_ptr(q)
{
// Create socket pair
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sockpair)) {
qDebug() << "UnixSignalWatcher: socketpair: " << ::strerror(errno);
return;
}
// Create a notifier for the read end of the pair
notifier = new QSocketNotifier(sockpair[1], QSocketNotifier::Read);
QObject::connect(notifier, SIGNAL(activated(int)), q, SLOT(_q_onNotify(int)));
notifier->setEnabled(true);
}
UnixSignalWatcherPrivate::~UnixSignalWatcherPrivate()
{
delete notifier;
}
/*!
* Registers a handler for the given Unix \a signal. The handler will write to
* a socket pair, the other end of which is connected to a QSocketNotifier.
* This provides a way to break out of the asynchronous context from which the
* signal handler is called and back into the Qt event loop.
*/
void UnixSignalWatcherPrivate::watchForSignal(int signal)
{
if (watchedSignals.contains(signal)) {
qDebug() << "Already watching for signal" << signal;
return;
}
// Register a sigaction which will write to the socket pair
struct sigaction sigact;
sigact.sa_handler = UnixSignalWatcherPrivate::signalHandler;
sigact.sa_flags = 0;
::sigemptyset(&sigact.sa_mask);
sigact.sa_flags |= SA_RESTART;
if (::sigaction(signal, &sigact, NULL)) {
qDebug() << "UnixSignalWatcher: sigaction: " << ::strerror(errno);
return;
}
watchedSignals.append(signal);
}
/*!
* Called when a Unix \a signal is received. Write to the socket to wake up the
* QSocketNotifier.
*/
void UnixSignalWatcherPrivate::signalHandler(int signal)
{
ssize_t nBytes = ::write(sockpair[0], &signal, sizeof(signal));
Q_UNUSED(nBytes);
}
/*!
* Called when the signal handler has written to the socket pair. Emits the Unix
* signal as a Qt signal.
*/
void UnixSignalWatcherPrivate::_q_onNotify(int sockfd)
{
Q_Q(UnixSignalWatcher);
int signal;
ssize_t nBytes = ::read(sockfd, &signal, sizeof(signal));
Q_UNUSED(nBytes);
qDebug() << "Caught signal:" << ::strsignal(signal);
emit q->unixSignal(signal);
}
/*!
* Create a new UnixSignalWatcher as a child of the given \a parent.
*/
UnixSignalWatcher::UnixSignalWatcher(QObject *parent) :
QObject(parent),
d_ptr(new UnixSignalWatcherPrivate(this))
{
}
/*!
* Destroy this UnixSignalWatcher.
*/
UnixSignalWatcher::~UnixSignalWatcher()
{
delete d_ptr;
}
/*!
* Register a signal handler for the given \a signal.
*
* After calling this method you can \c connect() to the unixSignal() Qt signal
* to be notified when the Unix signal is received.
*/
void UnixSignalWatcher::watchForSignal(int signal)
{
Q_D(UnixSignalWatcher);
d->watchForSignal(signal);
}
/*!
* \fn void UnixSignalWatcher::unixSignal(int signal)
* Emitted when the given Unix \a signal is received.
*
* watchForSignal() must be called for each Unix signal that you want to receive
* via the unixSignal() Qt signal. If a watcher is watching multiple signals,
* unixSignal() will be emitted whenever *any* of the watched Unix signals are
* received, and the \a signal argument can be inspected to find out which one
* was actually received.
*/
#include "moc_sigwatch.cpp"
-59
View File
@@ -1,59 +0,0 @@
/*
* Unix signal watcher for Qt.
*
* Copyright (C) 2014 Simon Knopp
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SIGWATCH_H
#define SIGWATCH_H
#include <QObject>
#include <signal.h>
class UnixSignalWatcherPrivate;
/*!
* \brief The UnixSignalWatcher class converts Unix signals to Qt signals.
*
* To watch for a given signal, e.g. \c SIGINT, call \c watchForSignal(SIGINT)
* and \c connect() your handler to unixSignal().
*/
class UnixSignalWatcher : public QObject
{
Q_OBJECT
public:
explicit UnixSignalWatcher(QObject *parent = 0);
~UnixSignalWatcher();
void watchForSignal(int signal);
signals:
void unixSignal(int signal);
private:
UnixSignalWatcherPrivate * const d_ptr;
Q_DECLARE_PRIVATE(UnixSignalWatcher)
Q_PRIVATE_SLOT(d_func(), void _q_onNotify(int))
};
#endif // SIGWATCH_H
Submodule 3rdparty/qtkeychain deleted from f197cdb935.
-39
View File
@@ -1,39 +0,0 @@
cmake_minimum_required(VERSION 3.10.0)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
file(STRINGS "VERSION" version)
project(GlobalProtect-openconnect LANGUAGES CXX)
# Set the CMAKE_INSTALL_PREFIX to /usr if not specified
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "The default install prefix" FORCE)
endif()
message(STATUS "CMAKE_INSTALL_PREFIX was set to: ${CMAKE_INSTALL_PREFIX}")
configure_file(version.h.in version.h)
find_package(Qt5 REQUIRED COMPONENTS
Core
Widgets
Network
WebSockets
WebEngine
WebEngineWidgets
DBus
)
find_package(Qt5Keychain REQUIRED)
add_subdirectory(3rdparty/qt-unix-signals)
add_subdirectory(3rdparty/inih)
add_subdirectory(GPService)
add_subdirectory(GPClient)
add_dependencies(gpclient gpservice)
Generated
+7110
View File
File diff suppressed because it is too large. Load diff
+81
View File
@@ -0,0 +1,81 @@
[workspace]
resolver = "2"
members = [
"crates/*",
"apps/gpclient",
"apps/gpservice",
"apps/gpauth",
"apps/gpgui-helper/src-tauri",
]
[workspace.package]
rust-version = "1.91"
version = "3.1.0"
authors = ["Kevin Yue <[email protected]>"]
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
edition = "2024"
license = "GPL-3.0"
[workspace.dependencies]
anyhow = "1.0"
askama = { version = "0.16", default-features = false, features = ["std", "derive", "config"] }
base64 = { version = "0.23", default-features = false, features = ["std"] }
chrono = "0.4"
clap = { version = "4", features = ["derive"] }
clap-verbosity-flag = "3"
ctrlc = "3.4"
directories = "6.0"
dns-lookup = "4.0.2"
env_logger = "0.11"
is_executable = "1.0"
log = "0.4"
# RUST_LOG accepts user-supplied Unicode property filters through env_logger.
regex = { version = "1", default-features = false, features = ["std", "perf", "unicode"] }
reqwest = { version = "0.13", default-features = false, features = ["native-tls", "charset", "http2", "system-proxy", "json", "form", "query"] }
openssl = "0.10"
pem = "4"
xmltree = { version = "0.12", features = ["attribute-order"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# The 0.39 series requires Rust 1.95, above the workspace minimum.
sysinfo = { version = "0.38.4", default-features = false, features = ["system"] }
tempfile = "3.8"
tokio = { version = "1" }
tokio-util = "0.7"
url = "2.4"
urlencoding = "2.1.3"
axum = { version = "0.8", default-features = false, features = ["http1", "tokio"] }
futures = { version = "0.3", default-features = false, features = ["std"] }
futures-util = "0.3"
uzers = "0.12"
whoami = "2"
thiserror = "2"
compile-time = "0.4"
serde_urlencoded = "0.7"
md5 = "0.8"
sha2 = { version = "0.11", default-features = false }
which = "8"
uuid = "1"
netdev = "0.46.3"
humantime = "2"
snow = { version = "0.10", default-features = false, features = ["use-getrandom", "use-curve25519", "use-chacha20poly1305", "use-sha2"] }
zeroize = "1"
# Tauri dependencies
tauri = { version = "2" }
specta = "=2.0.0-rc.20"
proptest = "1"
[patch.crates-io]
# Restore BSD GTK resize hit testing until https://github.com/tauri-apps/tao/pull/1356 is released.
tao = { git = "https://github.com/yuezk/tao", rev = "1452ae7a42c9f134296ba199f91f514fc9077f61" }
# Use one macro source for Tao and Wry so Cargo can vendor the workspace.
tao-macros = { git = "https://github.com/yuezk/tao", rev = "1452ae7a42c9f134296ba199f91f514fc9077f61" }
[profile.release]
opt-level = 'z' # Optimize for size
lto = true # Enable link-time optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations
panic = 'abort' # Abort on panic
strip = true # Strip symbols from binary*
-109
View File
@@ -1,109 +0,0 @@
include("${CMAKE_SOURCE_DIR}/cmake/Add3rdParty.cmake")
project(GPClient)
set(gpclient_GENERATED_SOURCES)
configure_file(com.yuezk.qt.gpclient.desktop.in com.yuezk.qt.gpclient.desktop)
configure_file(com.yuezk.qt.gpclient.metainfo.xml.in com.yuezk.qt.gpclient.metainfo.xml)
qt5_add_dbus_interface(
gpclient_GENERATED_SOURCES
${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml
gpserviceinterface
)
add_executable(gpclient
cdpcommand.cpp
cdpcommandmanager.cpp
enhancedwebview.cpp
gatewayauthenticator.cpp
gatewayauthenticatorparams.cpp
gpgateway.cpp
gphelper.cpp
loginparams.cpp
main.cpp
standardloginwindow.cpp
portalauthenticator.cpp
portalconfigresponse.cpp
preloginresponse.cpp
samlloginwindow.cpp
gpclient.cpp
settingsdialog.cpp
gpclient.ui
standardloginwindow.ui
settingsdialog.ui
challengedialog.h
challengedialog.cpp
challengedialog.ui
vpn_dbus.cpp
vpn_json.cpp
resources.qrc
${gpclient_GENERATED_SOURCES}
)
add_3rdparty(
SingleApplication
GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication.git
GIT_TAG v3.3.0
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
-DCMAKE_PREFIX_PATH=$ENV{CMAKE_PREFIX_PATH}
-DQAPPLICATION_CLASS=QApplication
)
add_3rdparty(
plog
GIT_REPOSITORY https://github.com/SergiusTheBest/plog.git
GIT_TAG master
CMAKE_ARGS
-DPLOG_BUILD_SAMPLES=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
)
ExternalProject_Get_Property(SingleApplication-${PROJECT_NAME} SOURCE_DIR BINARY_DIR)
set(SingleApplication_INCLUDE_DIR ${SOURCE_DIR})
set(SingleApplication_LIBRARY ${BINARY_DIR}/libSingleApplication.a)
ExternalProject_Get_Property(plog-${PROJECT_NAME} SOURCE_DIR)
set(plog_INCLUDE_DIR "${SOURCE_DIR}/include")
add_dependencies(gpclient
SingleApplication-${PROJECT_NAME}
plog-${PROJECT_NAME}
)
target_include_directories(gpclient PRIVATE
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${SingleApplication_INCLUDE_DIR}
${plog_INCLUDE_DIR}
${QTKEYCHAIN_INCLUDE_DIRS}/qt5keychain
)
target_link_libraries(gpclient
${SingleApplication_LIBRARY}
Qt5::Widgets
Qt5::Network
Qt5::WebSockets
Qt5::WebEngine
Qt5::WebEngineWidgets
Qt5::DBus
QtSignals
${QTKEYCHAIN_LIBRARIES}
)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0 AND CMAKE_BUILD_TYPE STREQUAL Release)
target_compile_options(gpclient PUBLIC "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
endif()
target_compile_definitions(gpclient PUBLIC QAPPLICATION_CLASS=QApplication)
install(TARGETS gpclient DESTINATION bin)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.yuezk.qt.gpclient.metainfo.xml" DESTINATION share/metainfo)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.yuezk.qt.gpclient.desktop" DESTINATION share/applications)
install(FILES "com.yuezk.qt.gpclient.svg" DESTINATION share/icons/hicolor/scalable/apps)
-30
View File
@@ -1,30 +0,0 @@
#include <QtCore/QVariantMap>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
#include "cdpcommand.h"
CDPCommand::CDPCommand(QObject *parent) : QObject(parent)
{
}
CDPCommand::CDPCommand(int id, QString cmd, QVariantMap& params) :
QObject(nullptr),
id(id),
cmd(cmd),
params(&params)
{
}
QByteArray CDPCommand::toJson()
{
QVariantMap payloadMap;
payloadMap["id"] = id;
payloadMap["method"] = cmd;
payloadMap["params"] = *params;
QJsonObject payloadJsonObject = QJsonObject::fromVariantMap(payloadMap);
QJsonDocument payloadJson(payloadJsonObject);
return payloadJson.toJson();
}
-24
View File
@@ -1,24 +0,0 @@
#ifndef CDPCOMMAND_H
#define CDPCOMMAND_H
#include <QtCore/QObject>
class CDPCommand : public QObject
{
Q_OBJECT
public:
explicit CDPCommand(QObject *parent = nullptr);
CDPCommand(int id, QString cmd, QVariantMap& params);
QByteArray toJson();
signals:
void finished();
private:
int id;
QString cmd;
QVariantMap *params;
};
#endif // CDPCOMMAND_H
-87
View File
@@ -1,87 +0,0 @@
#include <QtCore/QVariantMap>
#include <plog/Log.h>
#include "cdpcommandmanager.h"
CDPCommandManager::CDPCommandManager(QObject *parent)
: QObject(parent)
, networkManager(new QNetworkAccessManager)
, socket(new QWebSocket)
{
// WebSocket setup
QObject::connect(socket, &QWebSocket::connected, this, &CDPCommandManager::ready);
QObject::connect(socket, &QWebSocket::textMessageReceived, this, &CDPCommandManager::onTextMessageReceived);
QObject::connect(socket, &QWebSocket::disconnected, this, &CDPCommandManager::onSocketDisconnected);
QObject::connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error), this, &CDPCommandManager::onSocketError);
}
CDPCommandManager::~CDPCommandManager()
{
delete networkManager;
delete socket;
}
void CDPCommandManager::initialize(QString endpoint)
{
QNetworkReply *reply = networkManager->get(QNetworkRequest(endpoint));
QObject::connect(
reply, &QNetworkReply::finished,
[reply, this]() {
if (reply->error()) {
LOGE << "CDP request error";
return;
}
QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
QJsonArray pages = doc.array();
QJsonObject page = pages.first().toObject();
QString wsUrl = page.value("webSocketDebuggerUrl").toString();
socket->open(wsUrl);
}
);
}
CDPCommand *CDPCommandManager::sendCommand(QString cmd)
{
QVariantMap emptyParams;
return sendCommend(cmd, emptyParams);
}
CDPCommand *CDPCommandManager::sendCommend(QString cmd, QVariantMap &params)
{
int id = ++commandId;
CDPCommand *command = new CDPCommand(id, cmd, params);
socket->sendTextMessage(command->toJson());
commandPool.insert(id, command);
return command;
}
void CDPCommandManager::onTextMessageReceived(QString message)
{
QJsonDocument responseDoc = QJsonDocument::fromJson(message.toUtf8());
QJsonObject response = responseDoc.object();
// Response for method
if (response.contains("id")) {
int id = response.value("id").toInt();
if (commandPool.contains(id)) {
CDPCommand *command = commandPool.take(id);
command->finished();
}
} else { // Response for event
emit eventReceived(response.value("method").toString(), response.value("params").toObject());
}
}
void CDPCommandManager::onSocketDisconnected()
{
LOGI << "WebSocket disconnected";
}
void CDPCommandManager::onSocketError(QAbstractSocket::SocketError error)
{
LOGE << "WebSocket error" << error;
}
-40
View File
@@ -1,40 +0,0 @@
#ifndef CDPCOMMANDMANAGER_H
#define CDPCOMMANDMANAGER_H
#include <QtCore/QObject>
#include <QtCore/QHash>
#include <QtWebSockets/QtWebSockets>
#include <QtNetwork/QNetworkAccessManager>
#include "cdpcommand.h"
class CDPCommandManager : public QObject
{
Q_OBJECT
public:
explicit CDPCommandManager(QObject *parent = nullptr);
~CDPCommandManager();
void initialize(QString endpoint);
CDPCommand *sendCommand(QString cmd);
CDPCommand *sendCommend(QString cmd, QVariantMap& params);
signals:
void ready();
void eventReceived(QString eventName, QJsonObject params);
private:
QNetworkAccessManager *networkManager;
QWebSocket *socket;
int commandId = 0;
QHash<int, CDPCommand*> commandPool;
private slots:
void onTextMessageReceived(QString message);
void onSocketDisconnected();
void onSocketError(QAbstractSocket::SocketError error);
};
#endif // CDPCOMMANDMANAGER_H
-38
View File
@@ -1,38 +0,0 @@
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QPushButton>
#include "challengedialog.h"
#include "ui_challengedialog.h"
ChallengeDialog::ChallengeDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChallengeDialog)
{
ui->setupUi(this);
ui->buttonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
}
ChallengeDialog::~ChallengeDialog()
{
delete ui;
}
void ChallengeDialog::setMessage(const QString &message)
{
ui->challengeMessage->setText(message);
}
const QString ChallengeDialog::getChallenge()
{
return ui->challengeInput->text();
}
void ChallengeDialog::on_challengeInput_textChanged(const QString &value)
{
QPushButton *okBtn = ui->buttonBox->button(QDialogButtonBox::Ok);
if (value.isEmpty()) {
okBtn->setDisabled(true);
} else {
okBtn->setEnabled(true);
}
}
-28
View File
@@ -1,28 +0,0 @@
#ifndef CHALLENGEDIALOG_H
#define CHALLENGEDIALOG_H
#include <QDialog>
namespace Ui {
class ChallengeDialog;
}
class ChallengeDialog : public QDialog
{
Q_OBJECT
public:
explicit ChallengeDialog(QWidget *parent = nullptr);
~ChallengeDialog();
void setMessage(const QString &message);
const QString getChallenge();
private slots:
void on_challengeInput_textChanged(const QString &arg1);
private:
Ui::ChallengeDialog *ui;
};
#endif // CHALLENGEDIALOG_H
-111
View File
@@ -1,111 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChallengeDialog</class>
<widget class="QDialog" name="ChallengeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
<string>GlobalProtect Challenge</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,1">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Sign In</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="challengeMessage">
<property name="text">
<string>Duo two-factor login for [redacted] Enter a passcode or select one of the following options: 1. Duo Push to XXX-XXX-[redacted] 2. SMS passcodes to XXX-XXX-[redacted] Passcode or option (1-2): </string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLineEdit" name="challengeInput">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ChallengeDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ChallengeDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
-12
View File
@@ -1,12 +0,0 @@
[Desktop Entry]
Type=Application
Version=1.0
Name=GlobalProtect VPN
Comment=A GlobalProtect VPN client (GUI) for Linux based on OpenConnect and built with Qt5, supports SAML auth mode.
GenericName=GlobalProtect VPN client, supports SAML auth mode
Categories=Network;Dialup;
Exec=env QT_AUTO_SCREEN_SCALE_FACTOR=1 @CMAKE_INSTALL_PREFIX@/bin/gpclient
Icon=com.yuezk.qt.gpclient
Keywords=GlobalProtect;Openconnect;SAML;connection;VPN;
StartupWMClass=gpclient
@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>com.yuezk.qt.gpclient</id>
<name>globalprotect-openconnect</name>
<summary>A GlobalProtect VPN client powered by OpenConnect</summary>
<metadata_license>CC0-1.0</metadata_license>
<project_license>AGPL-3.0-or-later</project_license>
<description>
<p>A GlobalProtect VPN client (GUI) for Linux based on OpenConnect and built with Qt5, supports the SAML auth mode.</p>
</description>
<categories>
<category>Network</category>
</categories>
<update_contact>k3vinyue_AT_gmail.com</update_contact>
<developer_name>Kevin Yue</developer_name>
<url type="homepage">https://github.com/yuezk/GlobalProtect-openconnect</url>
<url type="bugtracker">https://github.com/yuezk/GlobalProtect-openconnect/issues</url>
<url type="help">https://github.com/yuezk/GlobalProtect-openconnect/issues</url>
<keywords>
<keyword>globalprotect</keyword>
<keyword>openconnect</keyword>
<keyword>vpn</keyword>
<keyword>saml</keyword>
</keywords>
<launchable type="desktop-id">com.yuezk.qt.gpclient.desktop</launchable>
<screenshots>
<screenshot type="default">
<image>https://user-images.githubusercontent.com/3297602/133869036-5c02b0d9-c2d9-4f87-8c81-e44f68cfd6ac.png</image>
</screenshot>
</screenshots>
<provides>
<binary>@CMAKE_INSTALL_PREFIX@/bin/gpclient</binary>
<dbus type="system">com.yuezk.qt.GPService</dbus>
</provides>
</component>
-99
View File
@@ -1,99 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
viewBox="0 0 96 96"
style="enable-background:new 0 0 96 96;"
xml:space="preserve"
sodipodi:docname="com.yuezk.qt.gpclient.svg"
inkscape:version="0.92.4 5da689c313, 2019-01-14"><metadata
id="metadata14"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
id="defs12" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1006"
id="namedview10"
showgrid="false"
inkscape:zoom="6.9532168"
inkscape:cx="7.9545315"
inkscape:cy="59.062386"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="g8499" />
<style
type="text/css"
id="style2">
.st0{fill:#2980B9;}
.st1{fill:#3498DB;}
.st2{fill:#2ECC71;}
.st3{fill:#27AE60;}
</style>
<g
id="g8499"
transform="matrix(1.3407388,0,0,1.3407388,-16.409202,-16.355463)"><g
id="XMLID_1_">
<circle
r="32.5"
cy="48"
cx="48"
class="st0"
id="XMLID_3_"
style="fill:#2980b9" />
<path
d="m 48,15.5 v 65 C 65.9,80.5 80.5,65.7 80.5,48 80.5,30 65.9,15.5 48,15.5 Z"
class="st1"
id="XMLID_4_"
inkscape:connector-curvature="0"
style="fill:#3498db" />
<path
d="m 48,15.5 v 0.6 l 1.2,-0.3 c 0.3,-0.3 0.4,-0.3 0.6,-0.3 h -1.1 z m 7.3,0.9 c -0.1,0 0.4,0.9 1.1,1.8 0.8,1.5 1.1,2.1 1.3,2.1 0.3,-0.3 1.9,-1.2 3,-2.1 -1.7,-0.9 -3.5,-1.5 -5.4,-1.8 z m 10.3,6.2 c -0.1,0 -0.4,0 -0.9,0.6 l -0.8,0.9 0.6,0.6 c 0.3,0.6 0.8,0.9 1,1.2 0.5,0.6 0.6,0.6 0.1,1.5 -0.2,0.6 -0.3,0.9 -0.3,0.9 0.1,0.3 0.3,0.3 1.4,0.3 h 1.6 c 0.1,0 0.3,-0.6 0.4,-1.2 l 0.1,-0.9 -1.1,-0.9 c -1,-0.9 -1,-0.9 -1.4,-1.8 -0.3,-0.6 -0.6,-1.2 -0.7,-1.2 z m -3,2.4 c -0.2,0 -1.3,2.1 -1.3,2.4 0,0 0.3,0.6 0.7,0.9 0.4,0.3 0.7,0.6 0.7,0.6 0.1,0 1.2,-1.2 1.4,-1.5 C 64.2,27.1 64,26.8 63.5,26.2 63.1,25.5 62.7,25 62.6,25 Z m 9.5,1.1 0.2,0.3 c 0,0.3 -0.7,0.9 -1.4,1.5 -1.2,0.9 -1.4,1.2 -2,1.2 -0.6,0 -0.9,0.3 -1.8,0.9 -0.6,0.6 -1.2,0.9 -1.2,1.2 0,0 0.2,0.3 0.6,0.9 0.7,0.6 0.7,0.9 0.2,1.8 l -0.4,0.3 h -1.1 c -0.6,0 -1.5,0 -1.8,-0.3 -0.9,0 -0.8,0 -0.1,2.1 1,3 1.1,3.2 1.3,3.2 0.1,0 1.3,-1.2 2.8,-2.4 1.5,-1.2 2.7,-2.4 2.8,-2.4 l 0.6,0.3 c 0.4,0.3 0.5,0 1.3,-0.6 l 0.8,-0.6 0.8,0.6 c 1.9,1.2 2.2,1.5 2.3,2.4 0.2,1.5 0.3,1.8 0.5,1.8 0.1,0 1.3,-1.5 1.6,-1.8 0.1,-0.3 -0.1,-0.6 -1.1,-2.1 -0.7,-0.9 -1.1,-1.8 -1.1,-2.1 0,0 0.1,0 0.3,-0.3 0.2,0 0.4,0.3 1,0.9 -1.6,-2.3 -3.2,-4.7 -5.1,-6.8 z m 2.8,10.7 c -0.2,0 -0.9,0.9 -0.8,1.2 l 0.5,0.3 H 75 c 0.2,0 0.3,0 0.2,-0.3 C 75.1,37.4 75,36.8 74.9,36.8 Z M 72.3,38 h -2.4 l -2.4,0.3 -4.5,3.5 -4.4,3.8 v 3.5 c 0,2.1 0,3.8 0.1,3.8 0.1,0 0.7,0.9 1.5,1.5 0.8,0.9 1.5,1.5 1.8,1.8 0.4,0.3 0.5,0.3 4,0.6 l 3.4,0.3 1.6,0.9 c 0.8,0.6 1.5,1.2 1.6,1.2 0.1,0 -0.3,0.3 -0.6,0.6 l -0.6,0.6 1,1.2 c 0.5,0.6 1.3,1.5 1.7,1.8 l 0.6,0.9 v 1.7 0.9 c 3.7,-5 5.9,-11.5 6.1,-18.3 0.1,-2.7 -0.3,-5.3 -0.8,-8 l -0.6,-0.3 c -0.1,0 -0.5,0.3 -1,0.6 -0.5,0.3 -1,0.9 -1.1,0.9 -0.1,0 -0.8,-0.3 -1.8,-0.6 l -1.8,-0.6 v -0.9 c 0,-0.6 0,-0.9 -0.6,-1.5 z M 48,63.7 V 64 h 0.2 z"
class="st2"
id="XMLID_13_"
inkscape:connector-curvature="0"
style="fill:#2ecc71" />
<path
d="m 48,15.5 c -3.1,0 -6.2,0.5 -9,1.3 0.3,0.4 0.3,0.4 0.6,0.9 1.5,2.5 1.7,2.8 2.1,2.9 0.3,0 0.9,0.1 1.6,0.1 h 1.2 l 0.9,-2 0.8,-1.9 1.8,-0.6 z m -16.9,4.7 c -2.8,1.7 -5.4,3.9 -7.6,6.4 -3.8,4.3 -6.3,9.6 -7.4,15.4 0.5,0 0.9,-0.1 1.8,-0.1 2.8,0.1 2.5,0 3.4,1.4 0.5,0.8 0.6,0.8 1.4,0.8 1,0.1 0.9,0 0.5,-1.6 -0.2,-0.6 -0.3,-1.2 -0.3,-1.4 0,-0.2 0.5,-0.7 1.7,-1.6 1.9,-1.5 1.8,-1.3 1.5,-2.9 -0.1,-0.3 0.1,-0.6 0.6,-1.2 0.7,-0.7 0.7,-0.6 1.4,-0.6 h 0.7 l 0.1,-1.2 c 0.1,-0.7 0.1,-1.3 0.2,-1.3 0,0 1.9,-1.1 4.1,-2.3 2.2,-1.2 4.1,-2.2 4.2,-2.3 0.2,-0.2 -0.3,-0.8 -2.7,-3.8 -1.5,-1.9 -2.8,-3.6 -2.9,-3.7 z m -5.8,23 c -0.1,0 -0.1,0.3 -0.1,0.6 0,0.6 0,0.7 0.6,1 0.8,0.4 0.9,0.5 0.8,0.2 -0.1,-0.4 -1.2,-1.9 -1.3,-1.8 z m -3.4,2.1 -0.5,1.8 c 0.1,0.1 0.9,0.3 1.8,0.5 1,0.2 1.6,0.4 1.8,0.3 l 0.5,-1.3 z m -3.8,1 -1.1,0.6 c -0.6,0.3 -1.2,0.6 -1.4,0.6 h -0.1 c 0,1.4 0.1,2.8 0.3,4.2 l 0.6,0.4 1,-0.1 h 1 l 0.6,1.4 c 0.3,0.7 0.7,1.4 0.8,1.5 0.1,0.1 1,0.1 1.8,0.1 h 1.5 L 23,56.2 c 0,1.2 0,1.3 -0.6,2.2 -0.4,0.5 -0.6,1.2 -0.6,1.4 0,0.2 0.7,2.1 1.6,4.3 l 1.5,4 1.6,0.8 c 1.2,0.6 1.5,0.8 1.5,1 0,0.1 -0.4,2.1 -0.6,3.1 3,2.5 6.4,4.5 10.2,5.8 3.5,-3.6 6.8,-7.1 7.3,-7.6 l 0.7,-0.7 0.2,-1.9 c 0.2,-1.1 0.4,-2.1 0.4,-2.2 0,-0.1 0.5,-0.6 1,-1.2 0.5,-0.5 0.8,-1 0.8,-1.1 v -0.2 c -0.1,-0.1 -1.4,-1.1 -3,-2.2 l -3.1,-2.1 -1.1,-0.1 c -0.8,0 -1.2,0 -1.3,-0.2 C 39.4,59.2 39.2,58.5 39.1,57.7 39,56.9 38.9,56.2 38.8,56.1 38.8,56 38,56 37.1,56 36.2,56 35.4,55.9 35.3,55.8 35.2,55.7 35.2,55.1 35.1,54.3 35,53.6 34.9,53 34.8,52.9 34.7,52.8 33.7,52.7 32.5,52.6 30.5,52.5 30.1,52.5 29.1,52 l -1.2,-0.6 -1.6,0.7 -1.7,0.9 -1.8,-0.1 c -2,0 -1.9,0.2 -2.1,-1.6 C 20.6,50.7 20.6,50.1 20.5,50.1 20.4,50 20,50 19.6,49.9 L 18.9,49.7 19,49.2 c 0,-0.3 0,-1 0.1,-1.4 L 19.2,47 18.7,46.5 Z m 9.1,1.1 C 27.1,47.5 27.1,47.8 27,48 l -0.1,0.5 2.9,1.2 c 2.9,1.1 3.4,1.2 3.9,0.7 0.2,-0.2 0.1,-0.2 -0.3,-0.4 -0.3,-0.1 -1.7,-0.9 -3.2,-1.6 -1.7,-0.7 -2.9,-1.1 -3,-1 z"
class="st3"
id="XMLID_20_"
inkscape:connector-curvature="0"
style="fill:#27ae60" />
</g><g
transform="matrix(1.458069,0,0,1.458069,-22.631538,-19.615144)"
id="g7664"><path
inkscape:connector-curvature="0"
id="XMLID_6_"
class="st3"
d="m 38.8,56.1 c 0,1.2 1,2.2 2.2,2.2 h 15.2 c 1.2,0 2.2,-1 2.2,-2.2 V 45.3 c 0,-1.2 -1,-2.2 -2.2,-2.2 H 40.9 c -1.2,0 -2.2,1 -2.2,2.2 v 10.8 z"
style="fill:#f1aa27;fill-opacity:1" /><path
style="fill:#e6e6e6"
inkscape:connector-curvature="0"
id="XMLID_7_"
class="st4"
d="m 55.5,43.1 h -3.3 v -3.7 c 0,-2.1 -1.7,-3.8 -3.8,-3.8 -2.1,0 -3.8,1.7 -3.8,3.8 v 3.8 h -3.1 v -3.8 c 0,-3.9 3.2,-7 7,-7 3.9,0 7,3.2 7,7 z" /><path
style="fill:#e6e6e6;fill-opacity:1"
inkscape:connector-curvature="0"
id="XMLID_8_"
class="st5"
d="m 50.35,48.2 c 0,-1 -0.8,-1.8 -1.8,-1.8 -1,0 -1.8,0.8 -1.8,1.8 0,0.7 0.4,1.3 1,1.6 l -1,5.2 h 3.6 l -1,-5.2 c 0.6,-0.3 1,-0.9 1,-1.6 z" /></g></g></svg>

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

-31
View File
@@ -1,31 +0,0 @@
#include <QtCore/QProcessEnvironment>
#include <QtWebEngineWidgets/QWebEngineView>
#include "enhancedwebview.h"
#include "cdpcommandmanager.h"
EnhancedWebView::EnhancedWebView(QWidget *parent)
: QWebEngineView(parent)
, cdp(new CDPCommandManager)
{
QObject::connect(cdp, &CDPCommandManager::ready, this, &EnhancedWebView::onCDPReady);
QObject::connect(cdp, &CDPCommandManager::eventReceived, this, &EnhancedWebView::onEventReceived);
}
void EnhancedWebView::initialize()
{
auto port = QProcessEnvironment::systemEnvironment().value(ENV_CDP_PORT);
cdp->initialize("http://127.0.0.1:" + port + "/json");
}
void EnhancedWebView::onCDPReady()
{
cdp->sendCommand("Network.enable");
}
void EnhancedWebView::onEventReceived(QString eventName, QJsonObject params)
{
if (eventName == "Network.responseReceived") {
emit responseReceived(params);
}
}
-29
View File
@@ -1,29 +0,0 @@
#ifndef ENHANCEDWEBVIEW_H
#define ENHANCEDWEBVIEW_H
#include <QtWebEngineWidgets/QWebEngineView>
#include "cdpcommandmanager.h"
#define ENV_CDP_PORT "QTWEBENGINE_REMOTE_DEBUGGING"
class EnhancedWebView : public QWebEngineView
{
Q_OBJECT
public:
explicit EnhancedWebView(QWidget *parent = nullptr);
void initialize();
signals:
void responseReceived(QJsonObject params);
private slots:
void onCDPReady();
void onEventReceived(QString eventName, QJsonObject params);
private:
CDPCommandManager *cdp { nullptr };
};
#endif // ENHANCEDWEBVIEW_H
-226
View File
@@ -1,226 +0,0 @@
#include <QtNetwork/QNetworkReply>
#include <QtCore/QRegularExpression>
#include <QtCore/QRegularExpressionMatch>
#include <plog/Log.h>
#include "gatewayauthenticator.h"
#include "gphelper.h"
#include "loginparams.h"
#include "preloginresponse.h"
#include "challengedialog.h"
using namespace gpclient::helper;
GatewayAuthenticator::GatewayAuthenticator(const QString& gateway, GatewayAuthenticatorParams params)
: QObject()
, gateway(gateway)
, params(params)
, preloginUrl("https://" + gateway + "/ssl-vpn/prelogin.esp?tmp=tmp&kerberos-support=yes&ipv6-support=yes&clientVer=4100")
, loginUrl("https://" + gateway + "/ssl-vpn/login.esp")
{
if (!params.clientos().isEmpty()) {
preloginUrl = preloginUrl + "&clientos=" + params.clientos();
}
}
void GatewayAuthenticator::authenticate()
{
LOGI << "Start gateway authentication...";
LoginParams loginParams { params.clientos() };
loginParams.setUser(params.username());
loginParams.setPassword(params.password());
loginParams.setUserAuthCookie(params.userAuthCookie());
loginParams.setInputStr(params.inputStr());
login(loginParams);
}
void GatewayAuthenticator::login(const LoginParams &loginParams)
{
LOGI << QString("Trying to login the gateway at %1, with %2").arg(loginUrl).arg(QString(loginParams.toUtf8()));
auto *reply = createRequest(loginUrl, loginParams.toUtf8());
connect(reply, &QNetworkReply::finished, this, &GatewayAuthenticator::onLoginFinished);
}
void GatewayAuthenticator::onLoginFinished()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
QByteArray response = reply->readAll();
if (reply->error() || response.contains("Authentication failure")) {
LOGE << QString("Failed to login the gateway at %1, %2").arg(loginUrl, reply->errorString());
if (standardLoginWindow) {
standardLoginWindow->setProcessing(false);
openMessageBox("Gateway login failed.", "Please check your credentials and try again.");
} else {
doAuth();
}
return;
}
// 2FA
if (response.contains("Challenge")) {
LOGI << "The server need input the challenge...";
showChallenge(response);
return;
}
if (standardLoginWindow) {
standardLoginWindow->close();
}
const auto params = gpclient::helper::parseGatewayResponse(response);
emit success(params.toString());
}
void GatewayAuthenticator::doAuth()
{
LOGI << "Perform the gateway prelogin at " << preloginUrl;
auto *reply = createRequest(preloginUrl);
connect(reply, &QNetworkReply::finished, this, &GatewayAuthenticator::onPreloginFinished);
}
void GatewayAuthenticator::onPreloginFinished()
{
auto *reply = qobject_cast<QNetworkReply*>(sender());
if (reply->error()) {
LOGE << QString("Failed to prelogin the gateway at %1, %2").arg(preloginUrl, reply->errorString());
emit fail("Error occurred on the gateway prelogin interface.");
return;
}
LOGI << "Gateway prelogin succeeded.";
auto response = PreloginResponse::parse(reply->readAll());
if (response.hasSamlAuthFields()) {
samlAuth(response.samlMethod(), response.samlRequest(), reply->url().toString());
} else if (response.hasNormalAuthFields()) {
normalAuth(response.labelUsername(), response.labelPassword(), response.authMessage());
} else {
LOGE << QString("Unknown prelogin response for %1, got %2").arg(preloginUrl, QString::fromUtf8(response.rawResponse()));
emit fail("Unknown response for gateway prelogin interface.");
}
delete reply;
}
void GatewayAuthenticator::normalAuth(QString labelUsername, QString labelPassword, QString authMessage)
{
LOGI << QString("Trying to perform the normal login with %1 / %2 credentials").arg(labelUsername, labelPassword);
standardLoginWindow = new StandardLoginWindow {gateway, labelUsername, labelPassword, authMessage};
// Do login
connect(standardLoginWindow, &StandardLoginWindow::performLogin, this, &GatewayAuthenticator::onPerformStandardLogin);
connect(standardLoginWindow, &StandardLoginWindow::rejected, this, &GatewayAuthenticator::onLoginWindowRejected);
connect(standardLoginWindow, &StandardLoginWindow::finished, this, &GatewayAuthenticator::onLoginWindowFinished);
standardLoginWindow->show();
}
void GatewayAuthenticator::onPerformStandardLogin(const QString &username, const QString &password)
{
LOGI << "Start to perform normal login...";
standardLoginWindow->setProcessing(true);
params.setUsername(username);
params.setPassword(password);
authenticate();
}
void GatewayAuthenticator::onLoginWindowRejected()
{
emit fail();
}
void GatewayAuthenticator::onLoginWindowFinished()
{
delete standardLoginWindow;
standardLoginWindow = nullptr;
}
void GatewayAuthenticator::samlAuth(QString samlMethod, QString samlRequest, QString preloginUrl)
{
LOGI << "Trying to perform SAML login with saml-method " << samlMethod;
auto *loginWindow = new SAMLLoginWindow;
connect(loginWindow, &SAMLLoginWindow::success, [this, loginWindow](const QMap<QString, QString> &samlResult) {
this->onSAMLLoginSuccess(samlResult);
loginWindow->deleteLater();
});
connect(loginWindow, &SAMLLoginWindow::fail, [this, loginWindow](const QString &code, const QString &error) {
this->onSAMLLoginFail(code, error);
loginWindow->deleteLater();
});
connect(loginWindow, &SAMLLoginWindow::rejected, [this, loginWindow]() {
this->onLoginWindowRejected();
loginWindow->deleteLater();
});
loginWindow->login(samlMethod, samlRequest, preloginUrl);
}
void GatewayAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> &samlResult)
{
if (samlResult.contains("preloginCookie")) {
LOGI << "SAML login succeeded, got the prelogin-cookie " << samlResult.value("preloginCookie");
} else {
LOGI << "SAML login succeeded, got the portal-userauthcookie " << samlResult.value("userAuthCookie");
}
LoginParams loginParams { params.clientos() };
loginParams.setUser(samlResult.value("username"));
loginParams.setPreloginCookie(samlResult.value("preloginCookie"));
loginParams.setUserAuthCookie(samlResult.value("userAuthCookie"));
login(loginParams);
}
void GatewayAuthenticator::onSAMLLoginFail(const QString &code, const QString &msg)
{
emit fail(msg);
}
void GatewayAuthenticator::showChallenge(const QString &responseText)
{
QRegularExpression re("\"(.*?)\";");
QRegularExpressionMatchIterator i = re.globalMatch(responseText);
i.next(); // Skip the status value
QString message = i.next().captured(1);
QString inputStr = i.next().captured(1);
// update the inputSrc field
params.setInputStr(inputStr);
challengeDialog = new ChallengeDialog;
challengeDialog->setMessage(message);
connect(challengeDialog, &ChallengeDialog::accepted, this, [this] {
params.setPassword(challengeDialog->getChallenge());
LOGI << "Challenge submitted, try to re-authenticate...";
authenticate();
});
connect(challengeDialog, &ChallengeDialog::rejected, this, [this] {
if (standardLoginWindow) {
standardLoginWindow->close();
}
emit fail();
});
connect(challengeDialog, &ChallengeDialog::finished, this, [this] {
delete challengeDialog;
challengeDialog = nullptr;
});
challengeDialog->show();
}
-48
View File
@@ -1,48 +0,0 @@
#ifndef GATEWAYAUTHENTICATOR_H
#define GATEWAYAUTHENTICATOR_H
#include <QtCore/QObject>
#include "standardloginwindow.h"
#include "challengedialog.h"
#include "loginparams.h"
#include "gatewayauthenticatorparams.h"
class GatewayAuthenticator : public QObject
{
Q_OBJECT
public:
explicit GatewayAuthenticator(const QString &gateway, GatewayAuthenticatorParams params);
void authenticate();
signals:
void success(const QString &authCookie);
void fail(const QString &msg = "");
private slots:
void onLoginFinished();
void onPreloginFinished();
void onPerformStandardLogin(const QString &username, const QString &password);
void onLoginWindowRejected();
void onLoginWindowFinished();
void onSAMLLoginSuccess(const QMap<QString, QString> &samlResult);
void onSAMLLoginFail(const QString &code, const QString &msg);
private:
QString gateway;
GatewayAuthenticatorParams params;
QString preloginUrl;
QString loginUrl;
StandardLoginWindow *standardLoginWindow { nullptr };
ChallengeDialog *challengeDialog { nullptr };
void login(const LoginParams& loginParams);
void doAuth();
void normalAuth(QString labelUsername, QString labelPassword, QString authMessage);
void samlAuth(QString samlMethod, QString samlRequest, QString preloginUrl = "");
void showChallenge(const QString &responseText);
};
#endif // GATEWAYAUTHENTICATOR_H
-67
View File
@@ -1,67 +0,0 @@
#include "gatewayauthenticatorparams.h"
GatewayAuthenticatorParams::GatewayAuthenticatorParams()
{
}
GatewayAuthenticatorParams GatewayAuthenticatorParams::fromPortalConfigResponse(const PortalConfigResponse &portalConfig)
{
GatewayAuthenticatorParams params;
params.setUsername(portalConfig.username());
params.setPassword(portalConfig.password());
params.setUserAuthCookie(portalConfig.userAuthCookie());
return params;
}
const QString &GatewayAuthenticatorParams::username() const
{
return m_username;
}
void GatewayAuthenticatorParams::setUsername(const QString &newUsername)
{
m_username = newUsername;
}
const QString &GatewayAuthenticatorParams::password() const
{
return m_password;
}
void GatewayAuthenticatorParams::setPassword(const QString &newPassword)
{
m_password = newPassword;
}
const QString &GatewayAuthenticatorParams::userAuthCookie() const
{
return m_userAuthCookie;
}
void GatewayAuthenticatorParams::setUserAuthCookie(const QString &newUserAuthCookie)
{
m_userAuthCookie = newUserAuthCookie;
}
const QString &GatewayAuthenticatorParams::clientos() const
{
return m_clientos;
}
void GatewayAuthenticatorParams::setClientos(const QString &newClientos)
{
m_clientos = newClientos;
}
const QString &GatewayAuthenticatorParams::inputStr() const
{
return m_inputStr;
}
void GatewayAuthenticatorParams::setInputStr(const QString &inputStr)
{
m_inputStr = inputStr;
}
-38
View File
@@ -1,38 +0,0 @@
#ifndef GATEWAYAUTHENTICATORPARAMS_H
#define GATEWAYAUTHENTICATORPARAMS_H
#include <QtCore/QString>
#include "portalconfigresponse.h"
class GatewayAuthenticatorParams
{
public:
GatewayAuthenticatorParams();
static GatewayAuthenticatorParams fromPortalConfigResponse(const PortalConfigResponse &portalConfig);
const QString &username() const;
void setUsername(const QString &newUsername);
const QString &password() const;
void setPassword(const QString &newPassword);
const QString &userAuthCookie() const;
void setUserAuthCookie(const QString &newUserAuthCookie);
const QString &clientos() const;
void setClientos(const QString &newClientos);
const QString &inputStr() const;
void setInputStr(const QString &inputStr);
private:
QString m_username;
QString m_password;
QString m_userAuthCookie;
QString m_clientos;
QString m_inputStr;
};
#endif // GATEWAYAUTHENTICATORPARAMS_H
-519
View File
@@ -1,519 +0,0 @@
#include <QtGui/QIcon>
#include <plog/Log.h>
#include "gpclient.h"
#include "gphelper.h"
#include "ui_gpclient.h"
#include "portalauthenticator.h"
#include "gatewayauthenticator.h"
#include "settingsdialog.h"
#include "gatewayauthenticatorparams.h"
using namespace gpclient::helper;
GPClient::GPClient(QWidget *parent, IVpn *vpn)
: QMainWindow(parent)
, ui(new Ui::GPClient)
, vpn(vpn)
, settingsDialog(new SettingsDialog(this))
{
ui->setupUi(this);
setWindowTitle("GlobalProtect");
setFixedSize(width(), height());
gpclient::helper::moveCenter(this);
setupSettings();
// Restore portal from the previous settings
this->portal(settings::get("portal", "").toString());
// DBus service setup
QObject *ov = dynamic_cast<QObject*>(vpn);
connect(ov, SIGNAL(connected()), this, SLOT(onVPNConnected()));
connect(ov, SIGNAL(disconnected()), this, SLOT(onVPNDisconnected()));
connect(ov, SIGNAL(error(QString)), this, SLOT(onVPNError(QString)));
connect(ov, SIGNAL(logAvailable(QString)), this, SLOT(onVPNLogAvailable(QString)));
// Initialize the context menu of system tray.
initSystemTrayIcon();
initVpnStatus();
}
void GPClient::setupSettings()
{
settingsButton = new QPushButton(this);
settingsButton->setIcon(QIcon(":/images/settings_icon.png"));
settingsButton->setFixedSize(QSize(28, 28));
QRect rect = this->geometry();
settingsButton->setGeometry(
rect.width() - settingsButton->width() - 15,
15,
settingsButton->geometry().width(),
settingsButton->geometry().height()
);
connect(settingsButton, &QPushButton::clicked, this, &GPClient::onSettingsButtonClicked);
connect(settingsDialog, &QDialog::accepted, this, &GPClient::onSettingsAccepted);
}
void GPClient::onSettingsButtonClicked()
{
settingsDialog->setClientos(settings::get("clientos", "Linux").toString());
settingsDialog->setOsVersion(settings::get("os-version", QSysInfo::prettyProductName()).toString());
settingsDialog->show();
}
void GPClient::onSettingsAccepted()
{
settings::save("clientos", settingsDialog->clientos());
settings::save("os-version", settingsDialog->osVersion());
}
void GPClient::on_connectButton_clicked()
{
doConnect();
}
void GPClient::on_portalInput_returnPressed()
{
doConnect();
}
void GPClient::on_portalInput_editingFinished()
{
populateGatewayMenu();
}
void GPClient::initSystemTrayIcon()
{
systemTrayIcon = new QSystemTrayIcon(this);
contextMenu = new QMenu("GlobalProtect", this);
gatewaySwitchMenu = new QMenu("Switch Gateway", this);
gatewaySwitchMenu->setIcon(QIcon::fromTheme("network-workgroup"));
populateGatewayMenu();
systemTrayIcon->setIcon(QIcon(":/images/not_connected.png"));
systemTrayIcon->setToolTip("GlobalProtect");
systemTrayIcon->setContextMenu(contextMenu);
connect(systemTrayIcon, &QSystemTrayIcon::activated, this, &GPClient::onSystemTrayActivated);
connect(gatewaySwitchMenu, &QMenu::triggered, this, &GPClient::onGatewayChanged);
openAction = contextMenu->addAction(QIcon::fromTheme("window-new"), "Open", this, &GPClient::activate);
connectAction = contextMenu->addAction(QIcon::fromTheme("preferences-system-network"), "Connect", this, &GPClient::doConnect);
contextMenu->addMenu(gatewaySwitchMenu);
contextMenu->addSeparator();
clearAction = contextMenu->addAction(QIcon::fromTheme("edit-clear"), "Reset", this, &GPClient::reset);
quitAction = contextMenu->addAction(QIcon::fromTheme("application-exit"), "Quit", this, &GPClient::quit);
systemTrayIcon->show();
}
void GPClient::initVpnStatus() {
int status = vpn->status();
if (status == 1) {
ui->statusLabel->setText("Connecting...");
updateConnectionStatus(VpnStatus::pending);
} else if (status == 2) {
updateConnectionStatus(VpnStatus::connected);
} else if (status == 3) {
ui->statusLabel->setText("Disconnecting...");
updateConnectionStatus(VpnStatus::pending);
} else {
updateConnectionStatus(VpnStatus::disconnected);
}
}
void GPClient::populateGatewayMenu()
{
LOGI << "Populating the Switch Gateway menu...";
const QList<GPGateway> gateways = allGateways();
gatewaySwitchMenu->clear();
if (gateways.isEmpty()) {
gatewaySwitchMenu->addAction("<None>")->setData(-1);
return;
}
const QString currentGatewayName = currentGateway().name();
for (int i = 0; i < gateways.length(); i++) {
const GPGateway g = gateways.at(i);
QString iconImage = ":/images/radio_unselected.png";
if (g.name() == currentGatewayName) {
iconImage = ":/images/radio_selected.png";
}
gatewaySwitchMenu->addAction(QIcon(iconImage), QString("%1 (%2)").arg(g.name(), g.address()))->setData(i);
}
}
void GPClient::updateConnectionStatus(const GPClient::VpnStatus &status)
{
switch (status) {
case VpnStatus::disconnected:
ui->statusLabel->setText("Not Connected");
ui->statusImage->setStyleSheet("image: url(:/images/not_connected.png); padding: 15;");
ui->connectButton->setText("Connect");
ui->connectButton->setDisabled(false);
ui->portalInput->setReadOnly(false);
systemTrayIcon->setIcon(QIcon{ ":/images/not_connected.png" });
connectAction->setEnabled(true);
connectAction->setText("Connect");
gatewaySwitchMenu->setEnabled(true);
clearAction->setEnabled(true);
break;
case VpnStatus::pending:
ui->statusImage->setStyleSheet("image: url(:/images/pending.png); padding: 15;");
ui->connectButton->setDisabled(true);
ui->portalInput->setReadOnly(true);
systemTrayIcon->setIcon(QIcon{ ":/images/pending.png" });
connectAction->setEnabled(false);
gatewaySwitchMenu->setEnabled(false);
clearAction->setEnabled(false);
break;
case VpnStatus::connected:
ui->statusLabel->setText("Connected");
ui->statusImage->setStyleSheet("image: url(:/images/connected.png); padding: 15;");
ui->connectButton->setText("Disconnect");
ui->connectButton->setDisabled(false);
ui->portalInput->setReadOnly(true);
systemTrayIcon->setIcon(QIcon{ ":/images/connected.png" });
connectAction->setEnabled(true);
connectAction->setText("Disconnect");
gatewaySwitchMenu->setEnabled(true);
clearAction->setEnabled(false);
break;
default:
break;
}
}
void GPClient::onSystemTrayActivated(QSystemTrayIcon::ActivationReason reason)
{
switch (reason) {
case QSystemTrayIcon::Trigger:
case QSystemTrayIcon::DoubleClick:
this->activate();
break;
default:
break;
}
}
void GPClient::onGatewayChanged(QAction *action)
{
const int index = action->data().toInt();
if (index == -1) {
return;
}
const auto g = allGateways().at(index);
// If the selected gateway is the same as the current gateway
if (g.name() == currentGateway().name()) {
return;
}
setCurrentGateway(g);
if (connected()) {
ui->statusLabel->setText("Switching Gateway...");
ui->connectButton->setEnabled(false);
vpn->disconnect();
isSwitchingGateway = true;
}
}
void GPClient::doConnect()
{
LOGI << "Start connecting...";
const auto btnText = ui->connectButton->text();
const auto portal = this->portal();
// Display the main window if portal is empty
if (portal.isEmpty()) {
activate();
return;
}
if (btnText.endsWith("Connect")) {
settings::save("portal", portal);
// Login to the previously saved gateway
if (!currentGateway().name().isEmpty()) {
LOGI << "Start gateway login using the previously saved gateway...";
isQuickConnect = true;
gatewayLogin();
} else {
// Perform the portal login
LOGI << "Start portal login...";
portalLogin();
}
} else {
LOGI << "Start disconnecting the VPN...";
ui->statusLabel->setText("Disconnecting...");
updateConnectionStatus(VpnStatus::pending);
vpn->disconnect();
}
}
// Login to the portal interface to get the portal config and preferred gateway
void GPClient::portalLogin()
{
auto *portalAuth = new PortalAuthenticator(portal(), settings::get("clientos", "Linux").toString());
connect(portalAuth, &PortalAuthenticator::success, [this, portalAuth](const PortalConfigResponse response, const QString region) {
this->onPortalSuccess(response, region);
portalAuth->deleteLater();
});
// Prelogin failed on the portal interface, try to treat the portal as a gateway interface
connect(portalAuth, &PortalAuthenticator::preloginFailed, [this, portalAuth](const QString msg) {
this->onPortalPreloginFail(msg);
portalAuth->deleteLater();
});
connect(portalAuth, &PortalAuthenticator::portalConfigFailed, [this, portalAuth](const QString msg) {
this->onPortalConfigFail(msg);
portalAuth->deleteLater();
});
// Portal login failed
connect(portalAuth, &PortalAuthenticator::fail, [this, portalAuth](const QString &msg) {
this->onPortalFail(msg);
portalAuth->deleteLater();
});
ui->statusLabel->setText("Authenticating...");
updateConnectionStatus(VpnStatus::pending);
portalAuth->authenticate();
}
void GPClient::onPortalSuccess(const PortalConfigResponse portalConfig, const QString region)
{
LOGI << "Portal authentication succeeded.";
// No gateway found in portal configuration
if (portalConfig.allGateways().size() == 0) {
LOGI << "No gateway found in portal configuration, treat the portal address as a gateway.";
tryGatewayLogin();
return;
}
GPGateway gateway = filterPreferredGateway(portalConfig.allGateways(), region);
setAllGateways(portalConfig.allGateways());
setCurrentGateway(gateway);
this->portalConfig = portalConfig;
gatewayLogin();
}
void GPClient::onPortalPreloginFail(const QString msg)
{
LOGI << "Portal prelogin failed, treat the portal address as a gateway." << msg;
tryGatewayLogin();
}
void GPClient::onPortalConfigFail(const QString msg)
{
LOGI << "Failed to get the portal configuration, " << msg << " Treat the portal address as gateway.";
tryGatewayLogin();
}
void GPClient::onPortalFail(const QString &msg)
{
if (!msg.isEmpty()) {
openMessageBox("Portal authentication failed.", msg);
}
updateConnectionStatus(VpnStatus::disconnected);
}
void GPClient::tryGatewayLogin()
{
LOGI << "Try to preform login on the the gateway interface...";
// Treat the portal input as the gateway address
GPGateway g;
g.setName(portal());
g.setAddress(portal());
QList<GPGateway> gateways;
gateways.append(g);
setAllGateways(gateways);
setCurrentGateway(g);
gatewayLogin();
}
// Login to the gateway
void GPClient::gatewayLogin()
{
LOGI << "Performing gateway login...";
GatewayAuthenticatorParams params = GatewayAuthenticatorParams::fromPortalConfigResponse(portalConfig);
params.setClientos(settings::get("clientos", "Linux").toString());
GatewayAuthenticator *gatewayAuth;
gatewayAuth = new GatewayAuthenticator(currentGateway().address(), params);
connect(gatewayAuth, &GatewayAuthenticator::success, [this, gatewayAuth](const QString &authToken) {
this->onGatewaySuccess(authToken);
gatewayAuth->deleteLater();
});
connect(gatewayAuth, &GatewayAuthenticator::fail, [this, gatewayAuth](const QString &msg) {
this->onGatewayFail(msg);
gatewayAuth->deleteLater();
});
ui->statusLabel->setText("Authenticating...");
updateConnectionStatus(VpnStatus::pending);
gatewayAuth->authenticate();
}
void GPClient::onGatewaySuccess(const QString &authCookie)
{
LOGI << "Gateway login succeeded, got the cookie " << authCookie;
isQuickConnect = false;
QList<QString> gatewayAddresses;
for (GPGateway &gw : allGateways()) {
gatewayAddresses.push_back(gw.address());
}
vpn->connect(currentGateway().address(), gatewayAddresses, portalConfig.username(), authCookie);
ui->statusLabel->setText("Connecting...");
updateConnectionStatus(VpnStatus::pending);
}
void GPClient::onGatewayFail(const QString &msg)
{
// If the quick connect on gateway failed, perform the portal login
if (isQuickConnect && !msg.isEmpty()) {
isQuickConnect = false;
LOGI << "Quick connection failed, trying to portal login...";
portalLogin();
return;
}
if (!msg.isEmpty()) {
openMessageBox("Gateway authentication failed.", msg);
}
updateConnectionStatus(VpnStatus::disconnected);
}
void GPClient::activate()
{
activateWindow();
showNormal();
}
QString GPClient::portal() const
{
const QString input = ui->portalInput->text().trimmed();
if (input.startsWith("http")) {
return QUrl(input).authority();
}
return input;
}
void GPClient::portal(QString p)
{
ui->portalInput->setText(p);
}
bool GPClient::connected() const
{
const QString statusText = ui->statusLabel->text();
return statusText.contains("Connected") && !statusText.contains("Not");
}
QList<GPGateway> GPClient::allGateways() const
{
QList<GPGateway> gateways;
for (auto g :settings::get_all("_gateways$") ){
gateways.append(GPGateway::fromJson(settings::get(g).toString()));
}
return gateways;
}
void GPClient::setAllGateways(QList<GPGateway> gateways)
{
LOGI << "Updating all the gateways...";
settings::save(portal() + "_gateways", GPGateway::serialize(gateways));
populateGatewayMenu();
}
GPGateway GPClient::currentGateway() const
{
const QString selectedGateway = settings::get(portal() + "_selectedGateway").toString();
for (auto g : allGateways()) {
if (g.name() == selectedGateway) {
return g;
}
}
return GPGateway{};
}
void GPClient::setCurrentGateway(const GPGateway gateway)
{
LOGI << "Updating the current gateway to " << gateway.name();
settings::save(portal() + "_selectedGateway", gateway.name());
ui->portalInput->setText(gateway.address());
populateGatewayMenu();
}
void GPClient::reset()
{
settings::clear();
populateGatewayMenu();
ui->portalInput->clear();
}
void GPClient::quit()
{
vpn->disconnect();
QApplication::quit();
}
void GPClient::onVPNConnected()
{
updateConnectionStatus(VpnStatus::connected);
}
void GPClient::onVPNDisconnected()
{
updateConnectionStatus(VpnStatus::disconnected);
if (isSwitchingGateway) {
gatewayLogin();
isSwitchingGateway = false;
}
}
void GPClient::onVPNError(QString errorMessage)
{
updateConnectionStatus(VpnStatus::disconnected);
openMessageBox("Failed to connect", errorMessage);
}
void GPClient::onVPNLogAvailable(QString log)
{
LOGI << log;
}
-104
View File
@@ -1,104 +0,0 @@
#ifndef GPCLIENT_H
#define GPCLIENT_H
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QSystemTrayIcon>
#include <QtWidgets/QMenu>
#include <QtWidgets/QPushButton>
#include "portalconfigresponse.h"
#include "settingsdialog.h"
#include "vpn.h"
#include "gatewayauthenticator.h"
QT_BEGIN_NAMESPACE
namespace Ui { class GPClient; }
QT_END_NAMESPACE
class GPClient : public QMainWindow
{
Q_OBJECT
public:
GPClient(QWidget *parent, IVpn *vpn);
void activate();
void quit();
QString portal() const;
void portal(QString);
GPGateway currentGateway() const;
void setCurrentGateway(const GPGateway gateway);
void doConnect();
void reset();
private slots:
void onSettingsButtonClicked();
void onSettingsAccepted();
void on_connectButton_clicked();
void on_portalInput_returnPressed();
void on_portalInput_editingFinished();
void onSystemTrayActivated(QSystemTrayIcon::ActivationReason reason);
void onGatewayChanged(QAction *action);
void onPortalSuccess(const PortalConfigResponse portalConfig, const QString region);
void onPortalPreloginFail(const QString msg);
void onPortalConfigFail(const QString msg);
void onPortalFail(const QString &msg);
void onGatewaySuccess(const QString &authCookie);
void onGatewayFail(const QString &msg);
void onVPNConnected();
void onVPNDisconnected();
void onVPNError(QString errorMessage);
void onVPNLogAvailable(QString log);
private:
enum class VpnStatus
{
disconnected,
pending,
connected
};
Ui::GPClient *ui;
IVpn *vpn;
QSystemTrayIcon *systemTrayIcon;
QMenu *contextMenu;
QAction *openAction;
QAction *connectAction;
QMenu *gatewaySwitchMenu;
QAction *clearAction;
QAction *quitAction;
SettingsDialog *settingsDialog;
QPushButton *settingsButton;
bool isQuickConnect { false };
bool isSwitchingGateway { false };
PortalConfigResponse portalConfig;
void setupSettings();
void initSystemTrayIcon();
void initVpnStatus();
void populateGatewayMenu();
void updateConnectionStatus(const VpnStatus &status);
void portalLogin();
void tryGatewayLogin();
void gatewayLogin();
bool connected() const;
QList<GPGateway> allGateways() const;
void setAllGateways(QList<GPGateway> gateways);
};
#endif // GPCLIENT_H
-143
View File
@@ -1,143 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GPClient</class>
<widget class="QMainWindow" name="GPClient">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>260</width>
<height>362</height>
</rect>
</property>
<property name="windowTitle">
<string>GlobalProtect OpenConnect</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<normaloff>:/images/logo.svg</normaloff>:/images/logo.svg</iconset>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<widget class="QWidget" name="centralwidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,0,0">
<property name="leftMargin">
<number>15</number>
</property>
<property name="topMargin">
<number>15</number>
</property>
<property name="rightMargin">
<number>15</number>
</property>
<property name="bottomMargin">
<number>15</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
<property name="bottomMargin">
<number>15</number>
</property>
<item>
<widget class="QLabel" name="statusImage">
<property name="styleSheet">
<string notr="true">#statusImage {
image: url(:/images/not_connected.png);
padding: 15
}</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusLabel">
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<bold>false</bold>
<underline>false</underline>
</font>
</property>
<property name="text">
<string>Not Connected</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="portalInput">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Please enter your portal address</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="connectButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Connect</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;https://bit.ly/3g5DHqy&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#4c6b8a;&quot;&gt;Report a bug&lt;/span&gt;&lt;/a&gt; / &lt;a href=&quot;https://bit.ly/3jQYfEi&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#4c6b8a;&quot;&gt;Buy me a coffee&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>
-97
View File
@@ -1,97 +0,0 @@
#include <QtCore/QJsonObject>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonArray>
#include "gpgateway.h"
GPGateway::GPGateway()
{
}
QString GPGateway::name() const
{
return _name;
}
QString GPGateway::address() const
{
return _address;
}
void GPGateway::setName(const QString &name)
{
_name = name;
}
void GPGateway::setAddress(const QString &address)
{
_address = address;
}
void GPGateway::setPriorityRules(const QMap<QString, int> &priorityRules)
{
_priorityRules = priorityRules;
}
int GPGateway::priorityOf(QString ruleName) const
{
if (_priorityRules.contains(ruleName)) {
return _priorityRules.value(ruleName);
}
return 0;
}
QJsonObject GPGateway::toJsonObject() const
{
QJsonObject obj;
obj.insert("name", name());
obj.insert("address", address());
return obj;
}
QString GPGateway::toString() const
{
QJsonDocument jsonDoc{ toJsonObject() };
return QString::fromUtf8(jsonDoc.toJson());
}
QString GPGateway::serialize(QList<GPGateway> &gateways)
{
QJsonArray arr;
for (auto g : gateways) {
arr.append(g.toJsonObject());
}
QJsonDocument jsonDoc{ arr };
return QString::fromUtf8(jsonDoc.toJson());
}
QList<GPGateway> GPGateway::fromJson(const QString &jsonString)
{
QList<GPGateway> gateways;
if (jsonString.isEmpty()) {
return gateways;
}
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonString.toUtf8());
for (auto item : jsonDoc.array()) {
GPGateway g = GPGateway::fromJsonObject(item.toObject());
gateways.append(g);
}
return gateways;
}
GPGateway GPGateway::fromJsonObject(const QJsonObject &jsonObj)
{
GPGateway g;
g.setName(jsonObj.value("name").toString());
g.setAddress(jsonObj.value("address").toString());
return g;
}
-33
View File
@@ -1,33 +0,0 @@
#ifndef GPGATEWAY_H
#define GPGATEWAY_H
#include <QtCore/QString>
#include <QtCore/QMap>
#include <QtCore/QJsonObject>
class GPGateway
{
public:
GPGateway();
QString name() const;
QString address() const;
void setName(const QString &name);
void setAddress(const QString &address);
void setPriorityRules(const QMap<QString, int> &priorityRules);
int priorityOf(QString ruleName) const;
QJsonObject toJsonObject() const;
QString toString() const;
static QString serialize(QList<GPGateway> &gateways);
static QList<GPGateway> fromJson(const QString &jsonString);
static GPGateway fromJsonObject(const QJsonObject &jsonObj);
private:
QString _name;
QString _address;
QMap<QString, int> _priorityRules;
};
#endif // GPGATEWAY_H
-178
View File
@@ -1,178 +0,0 @@
#include <QtCore/QXmlStreamReader>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QApplication>
#include <QtWidgets/QWidget>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QSslConfiguration>
#include <QtNetwork/QSslSocket>
#include <plog/Log.h>
#include <QWebEngineProfile>
#include <QWebEngineCookieStore>
#include <keychain.h>
#include "gphelper.h"
using namespace QKeychain;
QNetworkAccessManager* gpclient::helper::networkManager = new QNetworkAccessManager;
QNetworkReply* gpclient::helper::createRequest(QString url, QByteArray params)
{
QNetworkRequest request(url);
// Skip the ssl verifying
QSslConfiguration conf = request.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
conf.setSslOption(QSsl::SslOptionDisableLegacyRenegotiation, false);
request.setSslConfiguration(conf);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
request.setHeader(QNetworkRequest::UserAgentHeader, UA);
if (params == nullptr) {
return networkManager->post(request, QByteArray(nullptr));
}
return networkManager->post(request, params);
}
GPGateway gpclient::helper::filterPreferredGateway(QList<GPGateway> gateways, const QString ruleName)
{
LOGI << gateways.size() << " gateway(s) available, filter the gateways with rule: " << ruleName;
GPGateway gateway = gateways.first();
for (GPGateway g : gateways) {
if (g.priorityOf(ruleName) > gateway.priorityOf(ruleName)) {
LOGI << "Find a preferred gateway: " << g.name();
gateway = g;
}
}
return gateway;
}
QUrlQuery gpclient::helper::parseGatewayResponse(const QByteArray &xml)
{
LOGI << "Start parsing the gateway response...";
LOGI << "The gateway response is: " << xml;
QXmlStreamReader xmlReader{xml};
QList<QString> args;
while (!xmlReader.atEnd()) {
xmlReader.readNextStartElement();
if (xmlReader.name() == "argument") {
args.append(QUrl::toPercentEncoding(xmlReader.readElementText()));
}
}
QUrlQuery params{};
params.addQueryItem("authcookie", args.at(1));
params.addQueryItem("portal", args.at(3));
params.addQueryItem("user", args.at(4));
params.addQueryItem("domain", args.at(7));
params.addQueryItem("preferred-ip", args.at(15));
params.addQueryItem("computer", QUrl::toPercentEncoding(QSysInfo::machineHostName()));
return params;
}
void gpclient::helper::openMessageBox(const QString &message, const QString& informativeText)
{
QMessageBox msgBox;
msgBox.setWindowTitle("Notice");
msgBox.setText(message);
msgBox.setFixedWidth(500);
msgBox.setStyleSheet("QLabel{min-width: 250px}");
msgBox.setInformativeText(informativeText);
msgBox.exec();
}
void gpclient::helper::moveCenter(QWidget *widget)
{
QDesktopWidget *desktop = QApplication::desktop();
int screenWidth, width;
int screenHeight, height;
int x, y;
QSize windowSize;
screenWidth = desktop->width();
screenHeight = desktop->height();
windowSize = widget->size();
width = windowSize.width();
height = windowSize.height();
x = (screenWidth - width) / 2;
y = (screenHeight - height) / 2;
y -= 50;
widget->move(x, y);
}
QSettings *gpclient::helper::settings::_settings = new QSettings("com.yuezk.qt", "GPClient");
QVariant gpclient::helper::settings::get(const QString &key, const QVariant &defaultValue)
{
return _settings->value(key, defaultValue);
}
QStringList gpclient::helper::settings::get_all(const QString &key, const QVariant &defaultValue)
{
QRegularExpression re(key);
return _settings->allKeys().filter(re);
}
void gpclient::helper::settings::save(const QString &key, const QVariant &value)
{
_settings->setValue(key, value);
}
void gpclient::helper::settings::clear()
{
QStringList keys = _settings->allKeys();
for (const auto &key : qAsConst(keys)) {
if (!reservedKeys.contains(key)) {
_settings->remove(key);
}
}
QWebEngineProfile::defaultProfile()->cookieStore()->deleteAllCookies();
}
bool gpclient::helper::settings::secureSave(const QString &key, const QString &value) {
WritePasswordJob job( QLatin1String("gpclient") );
job.setAutoDelete( false );
job.setKey( key );
job.setTextData( value );
QEventLoop loop;
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()) );
job.start();
loop.exec();
if ( job.error() ) {
return false;
}
return true;
}
bool gpclient::helper::settings::secureGet(const QString &key, QString &value) {
ReadPasswordJob job( QLatin1String("gpclient") );
job.setAutoDelete( false );
job.setKey( key );
QEventLoop loop;
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()) );
job.start();
loop.exec();
const QString pw = job.textData();
if ( job.error() ) {
return false;
}
value = pw;
return true;
}
-47
View File
@@ -1,47 +0,0 @@
#ifndef GPHELPER_H
#define GPHELPER_H
#include <QtCore/QObject>
#include <QtCore/QUrlQuery>
#include <QtCore/QSettings>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include "samlloginwindow.h"
#include "gpgateway.h"
const QString UA = "PAN GlobalProtect";
namespace gpclient {
namespace helper {
extern QNetworkAccessManager *networkManager;
QNetworkReply* createRequest(QString url, QByteArray params = nullptr);
GPGateway filterPreferredGateway(QList<GPGateway> gateways, const QString ruleName);
QUrlQuery parseGatewayResponse(const QByteArray& xml);
void openMessageBox(const QString& message, const QString& informativeText = "");
void moveCenter(QWidget *widget);
namespace settings {
extern QSettings *_settings;
static const QStringList reservedKeys {"extraArgs", "clientos"};
QVariant get(const QString &key, const QVariant &defaultValue = QVariant());
QStringList get_all(const QString &key, const QVariant &defaultValue = QVariant());
void save(const QString &key, const QVariant &value);
void clear();
bool secureSave(const QString &key, const QString &value);
bool secureGet(const QString &key, QString &value);
}
}
}
#endif // GPHELPER_H
-88
View File
@@ -1,88 +0,0 @@
#include <QtCore/QUrlQuery>
#include "loginparams.h"
#include "gphelper.h"
using namespace gpclient::helper;
LoginParams::LoginParams(const QString clientos)
{
params.addQueryItem("prot", QUrl::toPercentEncoding("https:"));
params.addQueryItem("server", "");
params.addQueryItem("inputStr", "");
params.addQueryItem("jnlpReady", "jnlpReady");
params.addQueryItem("user", "");
params.addQueryItem("passwd", "");
params.addQueryItem("computer", QUrl::toPercentEncoding(QSysInfo::machineHostName()));
params.addQueryItem("ok", "Login");
params.addQueryItem("direct", "yes");
params.addQueryItem("clientVer", "4100");
// add the clientos parameter if not empty
if (!clientos.isEmpty()) {
params.addQueryItem("clientos", clientos);
}
auto osVersion = settings::get("os-version", "").toString();
if (osVersion.isEmpty()) {
osVersion = QSysInfo::prettyProductName();
}
params.addQueryItem("os-version", QUrl::toPercentEncoding(osVersion));
params.addQueryItem("portal-userauthcookie", "");
params.addQueryItem("portal-prelogonuserauthcookie", "");
params.addQueryItem("prelogin-cookie", "");
params.addQueryItem("ipv6-support", "yes");
}
LoginParams::~LoginParams()
{
}
void LoginParams::setUser(const QString user)
{
updateQueryItem("user", user);
}
void LoginParams::setServer(const QString server)
{
updateQueryItem("server", server);
}
void LoginParams::setPassword(const QString password)
{
updateQueryItem("passwd", password);
}
void LoginParams::setUserAuthCookie(const QString cookie)
{
updateQueryItem("portal-userauthcookie", cookie);
}
void LoginParams::setPrelogonAuthCookie(const QString cookie)
{
updateQueryItem("portal-prelogonuserauthcookie", cookie);
}
void LoginParams::setPreloginCookie(const QString cookie)
{
updateQueryItem("prelogin-cookie", cookie);
}
void LoginParams::setInputStr(const QString inputStr)
{
updateQueryItem("inputStr", inputStr);
}
QByteArray LoginParams::toUtf8() const
{
return params.toString().toUtf8();
}
void LoginParams::updateQueryItem(const QString key, const QString value)
{
if (params.hasQueryItem(key)) {
params.removeQueryItem(key);
}
params.addQueryItem(key, QUrl::toPercentEncoding(value));
}
-28
View File
@@ -1,28 +0,0 @@
#ifndef LOGINPARAMS_H
#define LOGINPARAMS_H
#include <QtCore/QUrlQuery>
class LoginParams
{
public:
LoginParams(const QString clientos);
~LoginParams();
void setUser(const QString user);
void setServer(const QString server);
void setPassword(const QString password);
void setUserAuthCookie(const QString cookie);
void setPrelogonAuthCookie(const QString cookie);
void setPreloginCookie(const QString cookie);
void setInputStr(const QString inputStr);
QByteArray toUtf8() const;
private:
QUrlQuery params;
void updateQueryItem(const QString key, const QString value);
};
#endif // LOGINPARAMS_H
-96
View File
@@ -1,96 +0,0 @@
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QStandardPaths>
#include <plog/Log.h>
#include <plog/Init.h>
#include <plog/Appenders/ColorConsoleAppender.h>
#include <plog/Formatters/TxtFormatter.h>
#include "singleapplication.h"
#include "gpclient.h"
#include "vpn_dbus.h"
#include "vpn_json.h"
#include "enhancedwebview.h"
#include "sigwatch.h"
#include "version.h"
#define QT_AUTO_SCREEN_SCALE_FACTOR "QT_AUTO_SCREEN_SCALE_FACTOR"
int main(int argc, char *argv[])
{
plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender(plog::streamStdErr);
plog::init(plog::debug, &consoleAppender);
LOGI << "GlobalProtect started, version: " << VERSION;
auto port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT));
auto hidpiSupport = QString::fromLocal8Bit(qgetenv(QT_AUTO_SCREEN_SCALE_FACTOR));
if (port.isEmpty()) {
qputenv(ENV_CDP_PORT, "12315");
}
if (hidpiSupport.isEmpty()) {
qputenv(QT_AUTO_SCREEN_SCALE_FACTOR, "1");
}
SingleApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false);
QCommandLineParser parser;
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("server", "The URL of the VPN server. Optional.");
parser.addPositionalArgument("gateway", "The URL of the specific VPN gateway. Optional.");
parser.addOptions({
{"json", "Write the result of the handshake with the GlobalConnect server to stdout as JSON and terminate. Useful for scripting."},
{"now", "Do not show the dialog with the connect button; connect immediately instead."},
{"start-minimized", "Launch the client minimized."},
{"reset", "Reset the client's settings."},
});
parser.process(app);
const auto positional = parser.positionalArguments();
auto *vpn = parser.isSet("json") // yes it leaks, but this is cleared on exit anyway
? static_cast<IVpn*>(new VpnJson(nullptr)) // Print to stdout and exit
: static_cast<IVpn*>(new VpnDbus(nullptr)); // Contact GPService daemon via dbus
GPClient w(nullptr, vpn);
if (positional.size() > 0) {
w.portal(positional.at(0));
}
if (positional.size() > 1) {
GPGateway gw;
gw.setName(positional.at(1));
gw.setAddress(positional.at(1));
w.setCurrentGateway(gw);
}
QObject::connect(&app, &SingleApplication::instanceStarted, &w, &GPClient::activate);
UnixSignalWatcher sigwatch;
sigwatch.watchForSignal(SIGINT);
sigwatch.watchForSignal(SIGTERM);
sigwatch.watchForSignal(SIGQUIT);
sigwatch.watchForSignal(SIGHUP);
QObject::connect(&sigwatch, &UnixSignalWatcher::unixSignal, &w, &GPClient::quit);
if (parser.isSet("json")) {
QObject::connect(static_cast<VpnJson*>(vpn), &VpnJson::connected, &w, &GPClient::quit);
}
if (parser.isSet("reset")) {
w.reset();
}
if (parser.isSet("now")) {
w.doConnect();
} else if (parser.isSet("start-minimized")) {
w.showMinimized();
} else {
w.show();
}
return app.exec();
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

-219
View File
@@ -1,219 +0,0 @@
#include <QtNetwork/QNetworkReply>
#include <plog/Log.h>
#include "portalauthenticator.h"
#include "gphelper.h"
#include "standardloginwindow.h"
#include "samlloginwindow.h"
#include "loginparams.h"
#include "preloginresponse.h"
#include "portalconfigresponse.h"
#include "gpgateway.h"
using namespace gpclient::helper;
PortalAuthenticator::PortalAuthenticator(const QString& portal, const QString& clientos) : QObject()
, portal(portal)
, clientos(clientos)
, preloginUrl("https://" + portal + "/global-protect/prelogin.esp?tmp=tmp&kerberos-support=yes&ipv6-support=yes&clientVer=4100")
, configUrl("https://" + portal + "/global-protect/getconfig.esp")
{
if (!clientos.isEmpty()) {
preloginUrl = preloginUrl + "&clientos=" + clientos;
}
}
PortalAuthenticator::~PortalAuthenticator()
{
delete standardLoginWindow;
}
void PortalAuthenticator::authenticate()
{
attempts++;
LOGI << QString("(%1/%2) attempts").arg(attempts).arg(MAX_ATTEMPTS) << ", preform portal prelogin at " << preloginUrl;
QNetworkReply *reply = createRequest(preloginUrl);
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onPreloginFinished);
}
void PortalAuthenticator::onPreloginFinished()
{
auto *reply = qobject_cast<QNetworkReply*>(sender());
if (reply->error()) {
LOGE << QString("Error occurred while accessing %1, %2").arg(preloginUrl, reply->errorString());
emit preloginFailed("Error occurred on the portal prelogin interface.");
delete reply;
return;
}
LOGI << "Portal prelogin succeeded.";
preloginResponse = PreloginResponse::parse(reply->readAll());
LOGI << "Finished parsing the prelogin response. The region field is: " << preloginResponse.region();
if (preloginResponse.hasSamlAuthFields()) {
// Do SAML authentication
samlAuth();
} else if (preloginResponse.hasNormalAuthFields()) {
// Do normal username/password authentication
tryAutoLogin();
} else {
LOGE << QString("Unknown prelogin response for %1 got %2").arg(preloginUrl).arg(QString::fromUtf8(preloginResponse.rawResponse()));
emit preloginFailed("Unknown response for portal prelogin interface.");
}
delete reply;
}
void PortalAuthenticator::tryAutoLogin()
{
const QString username = settings::get("username").toString();
const QString password = settings::get("password").toString();
if (!username.isEmpty() && !password.isEmpty()) {
LOGI << "Trying auto login using the saved credentials";
isAutoLogin = true;
fetchConfig(settings::get("username").toString(), settings::get("password").toString());
} else {
normalAuth();
}
}
void PortalAuthenticator::normalAuth()
{
LOGI << "Trying to launch the normal login window...";
standardLoginWindow = new StandardLoginWindow {portal, preloginResponse.labelUsername(), preloginResponse.labelPassword(), preloginResponse.authMessage() };
// Do login
connect(standardLoginWindow, &StandardLoginWindow::performLogin, this, &PortalAuthenticator::onPerformNormalLogin);
connect(standardLoginWindow, &StandardLoginWindow::rejected, this, &PortalAuthenticator::onLoginWindowRejected);
connect(standardLoginWindow, &StandardLoginWindow::finished, this, &PortalAuthenticator::onLoginWindowFinished);
standardLoginWindow->show();
}
void PortalAuthenticator::onPerformNormalLogin(const QString &username, const QString &password)
{
standardLoginWindow->setProcessing(true);
fetchConfig(username, password);
}
void PortalAuthenticator::onLoginWindowRejected()
{
emitFail();
}
void PortalAuthenticator::onLoginWindowFinished()
{
delete standardLoginWindow;
standardLoginWindow = nullptr;
}
void PortalAuthenticator::samlAuth()
{
LOGI << "Trying to perform SAML login with saml-method " << preloginResponse.samlMethod();
auto *loginWindow = new SAMLLoginWindow;
connect(loginWindow, &SAMLLoginWindow::success, [this, loginWindow](const QMap<QString, QString> samlResult) {
this->onSAMLLoginSuccess(samlResult);
loginWindow->deleteLater();
});
connect(loginWindow, &SAMLLoginWindow::fail, [this, loginWindow](const QString &code, const QString msg) {
this->onSAMLLoginFail(code, msg);
loginWindow->deleteLater();
});
connect(loginWindow, &SAMLLoginWindow::rejected, [this, loginWindow]() {
this->onLoginWindowRejected();
loginWindow->deleteLater();
});
loginWindow->login(preloginResponse.samlMethod(), preloginResponse.samlRequest(), preloginUrl);
}
void PortalAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> samlResult)
{
if (samlResult.contains("preloginCookie")) {
LOGI << "SAML login succeeded, got the prelogin-cookie";
} else {
LOGI << "SAML login succeeded, got the portal-userauthcookie";
}
fetchConfig(samlResult.value("username"), "", samlResult.value("preloginCookie"), samlResult.value("userAuthCookie"));
}
void PortalAuthenticator::onSAMLLoginFail(const QString &code, const QString &msg)
{
if (code == "ERR002" && attempts < MAX_ATTEMPTS) {
LOGI << "Failed to authenticate, trying to re-authenticate...";
authenticate();
} else {
emitFail(msg);
}
}
void PortalAuthenticator::fetchConfig(QString username, QString password, QString preloginCookie, QString userAuthCookie)
{
LoginParams loginParams { clientos };
loginParams.setServer(portal);
loginParams.setUser(username);
loginParams.setPassword(password);
loginParams.setPreloginCookie(preloginCookie);
loginParams.setUserAuthCookie(userAuthCookie);
// Save the username and password for future use.
this->username = username;
this->password = password;
LOGI << "Fetching the portal config from " << configUrl;
auto *reply = createRequest(configUrl, loginParams.toUtf8());
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onFetchConfigFinished);
}
void PortalAuthenticator::onFetchConfigFinished()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
if (reply->error()) {
LOGE << QString("Failed to fetch the portal config from %1, %2").arg(configUrl).arg(reply->errorString());
// Login failed, enable the fields of the normal login window
if (standardLoginWindow) {
standardLoginWindow->setProcessing(false);
openMessageBox("Portal login failed.", "Please check your credentials and try again.");
} else if (isAutoLogin) {
isAutoLogin = false;
normalAuth();
} else {
emit portalConfigFailed("Failed to fetch the portal config.");
}
return;
}
LOGI << "Fetch the portal config succeeded.";
PortalConfigResponse response = PortalConfigResponse::parse(reply->readAll());
// Add the username & password to the response object
response.setUsername(username);
response.setPassword(password);
// Close the login window
if (standardLoginWindow) {
LOGI << "Closing the StandardLoginWindow...";
standardLoginWindow->close();
}
emit success(response, preloginResponse.region());
}
void PortalAuthenticator::emitFail(const QString& msg)
{
emit fail(msg);
}
-60
View File
@@ -1,60 +0,0 @@
#ifndef PORTALAUTHENTICATOR_H
#define PORTALAUTHENTICATOR_H
#include <QtCore/QObject>
#include "portalconfigresponse.h"
#include "standardloginwindow.h"
#include "samlloginwindow.h"
#include "preloginresponse.h"
class PortalAuthenticator : public QObject
{
Q_OBJECT
public:
explicit PortalAuthenticator(const QString& portal, const QString& clientos);
~PortalAuthenticator();
void authenticate();
signals:
void success(const PortalConfigResponse response, const QString region);
void fail(const QString& msg);
void preloginFailed(const QString& msg);
void portalConfigFailed(const QString msg);
private slots:
void onPreloginFinished();
void onPerformNormalLogin(const QString &username, const QString &password);
void onLoginWindowRejected();
void onLoginWindowFinished();
void onSAMLLoginSuccess(const QMap<QString, QString> samlResult);
void onSAMLLoginFail(const QString &code, const QString &msg);
void onFetchConfigFinished();
private:
static const auto MAX_ATTEMPTS{ 5 };
QString portal;
QString clientos;
QString preloginUrl;
QString configUrl;
QString username;
QString password;
int attempts{ 0 };
PreloginResponse preloginResponse;
bool isAutoLogin{ false };
StandardLoginWindow *standardLoginWindow { nullptr };
void tryAutoLogin();
void normalAuth();
void samlAuth();
void fetchConfig(QString username, QString password, QString preloginCookie = "", QString userAuthCookie = "");
void emitFail(const QString& msg = "");
};
#endif // PORTALAUTHENTICATOR_H
-175
View File
@@ -1,175 +0,0 @@
#include <QtCore/QXmlStreamReader>
#include <plog/Log.h>
#include "portalconfigresponse.h"
QString PortalConfigResponse::xmlUserAuthCookie = "portal-userauthcookie";
QString PortalConfigResponse::xmlPrelogonUserAuthCookie = "portal-prelogonuserauthcookie";
QString PortalConfigResponse::xmlGateways = "gateways";
PortalConfigResponse::PortalConfigResponse()
{
}
PortalConfigResponse::~PortalConfigResponse()
{
}
PortalConfigResponse PortalConfigResponse::parse(const QByteArray xml)
{
LOGI << "Start parsing the portal configuration...";
QXmlStreamReader xmlReader(xml);
PortalConfigResponse response;
response.setRawResponse(xml);
while (!xmlReader.atEnd()) {
xmlReader.readNextStartElement();
QString name = xmlReader.name().toString();
if (name == xmlUserAuthCookie) {
LOGI << "Start reading " << name;
response.setUserAuthCookie(xmlReader.readElementText());
} else if (name == xmlPrelogonUserAuthCookie) {
LOGI << "Start reading " << name;
response.setPrelogonUserAuthCookie(xmlReader.readElementText());
} else if (name == xmlGateways) {
response.setAllGateways(parseGateways(xmlReader));
}
}
LOGI << "Finished parsing portal configuration.";
return response;
}
const QByteArray PortalConfigResponse::rawResponse() const
{
return m_rawResponse;
}
const QString &PortalConfigResponse::username() const
{
return m_username;
}
QString PortalConfigResponse::password() const
{
return m_password;
}
QList<GPGateway> PortalConfigResponse::parseGateways(QXmlStreamReader &xmlReader)
{
LOGI << "Start parsing the gateways from portal configuration...";
QList<GPGateway> gateways;
while (xmlReader.name() != "external"){
xmlReader.readNext();
}
while (xmlReader.name() != "list"){
xmlReader.readNext();
}
while (xmlReader.name() != xmlGateways || !xmlReader.isEndElement()) {
xmlReader.readNext();
// Parse the gateways -> external -> list -> entry
if (xmlReader.name() == "entry" && xmlReader.isStartElement()) {
GPGateway g;
parseGateway(xmlReader, g);
gateways.append(g);
}
}
LOGI << "Finished parsing the gateways.";
return gateways;
}
void PortalConfigResponse::parseGateway(QXmlStreamReader &reader, GPGateway &gateway) {
LOGI << "Start parsing gateway...";
auto finished = false;
while (!finished) {
if (reader.name() == "entry" && reader.isStartElement()) {
auto address = reader.attributes().value("name").toString();
gateway.setAddress(address);
} else if (reader.name() == "description" && reader.isStartElement()) { // gateway name
gateway.setName(reader.readElementText());
} else if (reader.name() == "priority-rule" && reader.isStartElement()) { // priority rules
parsePriorityRule(reader, gateway);
}
auto result = reader.readNext();
finished = result == QXmlStreamReader::Invalid || (reader.name() == "entry" && reader.isEndElement());
}
}
void PortalConfigResponse::parsePriorityRule(QXmlStreamReader &reader, GPGateway &gateway) {
LOGI << "Start parsing priority rule...";
QMap<QString, int> priorityRules;
auto finished = false;
while (!finished) {
// Parse the priority-rule -> entry
if (reader.name() == "entry" && reader.isStartElement()) {
auto ruleName = reader.attributes().value("name").toString();
// move to the priority value
while (reader.readNextStartElement()) {
if (reader.name() == "priority") {
auto priority = reader.readElementText().toInt();
priorityRules.insert(ruleName, priority);
break;
}
}
}
auto result = reader.readNext();
finished = result == QXmlStreamReader::Invalid || (reader.name() == "priority-rule" && reader.isEndElement());
}
gateway.setPriorityRules(priorityRules);
}
QString PortalConfigResponse::userAuthCookie() const
{
return m_userAuthCookie;
}
QList<GPGateway> PortalConfigResponse::allGateways() const
{
return m_gateways;
}
void PortalConfigResponse::setAllGateways(QList<GPGateway> gateways)
{
m_gateways = gateways;
}
void PortalConfigResponse::setRawResponse(const QByteArray response)
{
m_rawResponse = response;
}
void PortalConfigResponse::setUsername(const QString username)
{
m_username = username;
}
void PortalConfigResponse::setPassword(const QString password)
{
m_password = password;
}
void PortalConfigResponse::setUserAuthCookie(const QString cookie)
{
m_userAuthCookie = cookie;
}
void PortalConfigResponse::setPrelogonUserAuthCookie(const QString cookie)
{
m_prelogonAuthCookie = cookie;
}
-51
View File
@@ -1,51 +0,0 @@
#ifndef PORTALCONFIGRESPONSE_H
#define PORTALCONFIGRESPONSE_H
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtCore/QXmlStreamReader>
#include "gpgateway.h"
class PortalConfigResponse
{
public:
PortalConfigResponse();
~PortalConfigResponse();
static PortalConfigResponse parse(const QByteArray xml);
const QByteArray rawResponse() const;
const QString &username() const;
QString password() const;
QString userAuthCookie() const;
QList<GPGateway> allGateways() const;
void setAllGateways(QList<GPGateway> gateways);
void setUsername(const QString username);
void setPassword(const QString password);
private:
static QString xmlUserAuthCookie;
static QString xmlPrelogonUserAuthCookie;
static QString xmlGateways;
QByteArray m_rawResponse;
QString m_username;
QString m_password;
QString m_userAuthCookie;
QString m_prelogonAuthCookie;
QList<GPGateway> m_gateways;
void setRawResponse(const QByteArray response);
void setUserAuthCookie(const QString cookie);
void setPrelogonUserAuthCookie(const QString cookie);
static QList<GPGateway> parseGateways(QXmlStreamReader &xmlReader);
static void parseGateway(QXmlStreamReader &reader, GPGateway &gateway);
static void parsePriorityRule(QXmlStreamReader &reader, GPGateway &gateway);
};
#endif // PORTALCONFIGRESPONSE_H
-100
View File
@@ -1,100 +0,0 @@
#include <QtCore/QXmlStreamReader>
#include <QtCore/QMap>
#include <plog/Log.h>
#include "preloginresponse.h"
QString PreloginResponse::xmlAuthMessage = "authentication-message";
QString PreloginResponse::xmlLabelUsername = "username-label";
QString PreloginResponse::xmlLabelPassword = "password-label";
QString PreloginResponse::xmlSamlMethod = "saml-auth-method";
QString PreloginResponse::xmlSamlRequest = "saml-request";
QString PreloginResponse::xmlRegion = "region";
PreloginResponse::PreloginResponse()
{
add(xmlAuthMessage, "");
add(xmlLabelUsername, "");
add(xmlLabelPassword, "");
add(xmlSamlMethod, "");
add(xmlSamlRequest, "");
add(xmlRegion, "");
}
PreloginResponse PreloginResponse::parse(const QByteArray& xml)
{
LOGI << "Start parsing the prelogin response...";
QXmlStreamReader xmlReader(xml);
PreloginResponse response;
response.setRawResponse(xml);
while (!xmlReader.atEnd()) {
xmlReader.readNextStartElement();
QString name = xmlReader.name().toString();
if (response.has(name)) {
response.add(name, xmlReader.readElementText());
}
}
return response;
}
const QByteArray& PreloginResponse::rawResponse() const
{
return _rawResponse;
}
QString PreloginResponse::authMessage() const
{
return resultMap.value(xmlAuthMessage);
}
QString PreloginResponse::labelUsername() const
{
return resultMap.value(xmlLabelUsername);
}
QString PreloginResponse::labelPassword() const
{
return resultMap.value(xmlLabelPassword);
}
QString PreloginResponse::samlMethod() const
{
return resultMap.value(xmlSamlMethod);
}
QString PreloginResponse::samlRequest() const
{
return QByteArray::fromBase64(resultMap.value(xmlSamlRequest).toUtf8());
}
QString PreloginResponse::region() const
{
return resultMap.value(xmlRegion);
}
bool PreloginResponse::hasSamlAuthFields() const
{
return !samlMethod().isEmpty() && !samlRequest().isEmpty();
}
bool PreloginResponse::hasNormalAuthFields() const
{
return !labelUsername().isEmpty() && !labelPassword().isEmpty();
}
void PreloginResponse::setRawResponse(const QByteArray response)
{
_rawResponse = response;
}
bool PreloginResponse::has(const QString name) const
{
return resultMap.contains(name);
}
void PreloginResponse::add(const QString name, const QString value)
{
resultMap.insert(name, value);
}
-41
View File
@@ -1,41 +0,0 @@
#ifndef PRELOGINRESPONSE_H
#define PRELOGINRESPONSE_H
#include <QtCore/QString>
#include <QtCore/QMap>
class PreloginResponse
{
public:
PreloginResponse();
static PreloginResponse parse(const QByteArray& xml);
const QByteArray& rawResponse() const;
QString authMessage() const;
QString labelUsername() const;
QString labelPassword() const;
QString samlMethod() const;
QString samlRequest() const;
QString region() const;
bool hasSamlAuthFields() const;
bool hasNormalAuthFields() const;
private:
static QString xmlAuthMessage;
static QString xmlLabelUsername;
static QString xmlLabelPassword;
static QString xmlSamlMethod;
static QString xmlSamlRequest;
static QString xmlRegion;
QMap<QString, QString> resultMap;
QByteArray _rawResponse;
void setRawResponse(const QByteArray response);
void add(const QString name, const QString value);
bool has(const QString name) const;
};
#endif // PRELOGINRESPONSE_H
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 993 B

-11
View File
@@ -1,11 +0,0 @@
<RCC>
<qresource prefix="/images">
<file alias="logo.svg">com.yuezk.qt.gpclient.svg</file>
<file>connected.png</file>
<file>pending.png</file>
<file>not_connected.png</file>
<file>radio_unselected.png</file>
<file>radio_selected.png</file>
<file>settings_icon.png</file>
</qresource>
</RCC>
-136
View File
@@ -1,136 +0,0 @@
#include <QtWidgets/QVBoxLayout>
#include <QtWebEngineWidgets/QWebEngineProfile>
#include <QtWebEngineWidgets/QWebEngineView>
#include <QWebEngineCookieStore>
#include <plog/Log.h>
#include "samlloginwindow.h"
SAMLLoginWindow::SAMLLoginWindow(QWidget *parent)
: QDialog(parent)
, webView(new EnhancedWebView(this))
{
setWindowTitle("GlobalProtect Login");
setModal(true);
resize(700, 550);
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
webView->setUrl(QUrl("about:blank"));
webView->setAttribute(Qt::WA_DeleteOnClose);
verticalLayout->addWidget(webView);
webView->initialize();
connect(webView, &EnhancedWebView::responseReceived, this, &SAMLLoginWindow::onResponseReceived);
connect(webView, &EnhancedWebView::loadFinished, this, &SAMLLoginWindow::onLoadFinished);
// Show the login window automatically when exceeds the MAX_WAIT_TIME
QTimer::singleShot(MAX_WAIT_TIME, this, [this]() {
if (failed) {
return;
}
LOGI << "MAX_WAIT_TIME exceeded, display the login window.";
this->show();
});
}
void SAMLLoginWindow::closeEvent(QCloseEvent *event)
{
event->accept();
reject();
}
void SAMLLoginWindow::login(const QString samlMethod, const QString samlRequest, const QString preloginUrl)
{
webView->page()->profile()->cookieStore()->deleteSessionCookies();
if (samlMethod == "POST") {
webView->setHtml(samlRequest, preloginUrl);
} else if (samlMethod == "REDIRECT") {
LOGI << "Redirect to " << samlRequest;
webView->load(samlRequest);
} else {
LOGE << "Unknown saml-auth-method expected POST or REDIRECT, got " << samlMethod;
failed = true;
emit fail("ERR001", "Unknown saml-auth-method, got " + samlMethod);
}
}
void SAMLLoginWindow::onResponseReceived(QJsonObject params)
{
const auto type = params.value("type").toString();
// Skip non-document response
if (type != "Document") {
return;
}
auto response = params.value("response").toObject();
auto headers = response.value("headers").toObject();
LOGI << "Trying to receive authentication cookie from " << response.value("url").toString();
const auto username = headers.value("saml-username").toString();
const auto preloginCookie = headers.value("prelogin-cookie").toString();
const auto userAuthCookie = headers.value("portal-userauthcookie").toString();
this->checkSamlResult(username, preloginCookie, userAuthCookie);
}
void SAMLLoginWindow::checkSamlResult(QString username, QString preloginCookie, QString userAuthCookie)
{
LOGI << "Checking the authentication result...";
if (!username.isEmpty()) {
samlResult.insert("username", username);
}
if (!preloginCookie.isEmpty()) {
samlResult.insert("preloginCookie", preloginCookie);
}
if (!userAuthCookie.isEmpty()) {
samlResult.insert("userAuthCookie", userAuthCookie);
}
// Check the SAML result
if (samlResult.contains("username")
&& (samlResult.contains("preloginCookie") || samlResult.contains("userAuthCookie"))) {
LOGI << "Got the SAML authentication information successfully. "
<< "username: " << samlResult.value("username")
<< ", preloginCookie: " << samlResult.value("preloginCookie")
<< ", userAuthCookie: " << samlResult.value("userAuthCookie");
emit success(samlResult);
accept();
}
}
void SAMLLoginWindow::onLoadFinished()
{
LOGI << "Load finished " << webView->page()->url().toString();
webView->page()->toHtml([this] (const QString &html) { this->handleHtml(html); });
}
void SAMLLoginWindow::handleHtml(const QString &html)
{
// try to check the html body and extract from there
const auto samlAuthStatus = parseTag("saml-auth-status", html);
if (samlAuthStatus == "1") {
const auto preloginCookie = parseTag("prelogin-cookie", html);
const auto username = parseTag("saml-username", html);
const auto userAuthCookie = parseTag("portal-userauthcookie", html);
checkSamlResult(username, preloginCookie, userAuthCookie);
} else if (samlAuthStatus == "-1") {
LOGI << "SAML authentication failed...";
failed = true;
emit fail("ERR002", "Authentication failed, please try again.");
} else {
show();
}
}
QString SAMLLoginWindow::parseTag(const QString &tag, const QString &html) {
const QRegularExpression expression(QString("<%1>(.*)</%1>").arg(tag));
return expression.match(html).captured(1);
}
-41
View File
@@ -1,41 +0,0 @@
#ifndef SAMLLOGINWINDOW_H
#define SAMLLOGINWINDOW_H
#include <QtCore/QMap>
#include <QtGui/QCloseEvent>
#include <QtWidgets/QDialog>
#include "enhancedwebview.h"
class SAMLLoginWindow : public QDialog
{
Q_OBJECT
public:
explicit SAMLLoginWindow(QWidget *parent = nullptr);
void login(const QString samlMethod, const QString samlRequest, const QString preloginUrl);
signals:
void success(QMap<QString, QString> samlResult);
void fail(const QString code, const QString msg);
private slots:
void onResponseReceived(QJsonObject params);
void onLoadFinished();
void checkSamlResult(QString username, QString preloginCookie, QString userAuthCookie);
private:
static const auto MAX_WAIT_TIME { 10 * 1000 };
bool failed { false };
EnhancedWebView *webView { nullptr };
QMap<QString, QString> samlResult;
void closeEvent(QCloseEvent *event);
void handleHtml(const QString &html);
static QString parseTag(const QString &tag, const QString &html);
};
#endif // SAMLLOGINWINDOW_H
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

-42
View File
@@ -1,42 +0,0 @@
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SettingsDialog)
{
ui->setupUi(this);
}
SettingsDialog::~SettingsDialog()
{
delete ui;
}
void SettingsDialog::setExtraArgs(QString extraArgs)
{
ui->extraArgsInput->setPlainText(extraArgs);
}
QString SettingsDialog::extraArgs()
{
return ui->extraArgsInput->toPlainText().trimmed();
}
void SettingsDialog::setClientos(QString clientos)
{
ui->clientosInput->setText(clientos);
}
QString SettingsDialog::clientos()
{
return ui->clientosInput->text();
}
void SettingsDialog::setOsVersion(QString osVersion) {
ui->osVersionInput->setText(osVersion);
}
QString SettingsDialog::osVersion() {
return ui->osVersionInput->text();
}
-31
View File
@@ -1,31 +0,0 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QtWidgets/QDialog>
namespace Ui {
class SettingsDialog;
}
class SettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit SettingsDialog(QWidget *parent = nullptr);
~SettingsDialog();
void setExtraArgs(QString extraArgs);
QString extraArgs();
void setClientos(QString clientos);
QString clientos();
void setOsVersion(QString osVersion);
QString osVersion();
private:
Ui::SettingsDialog *ui;
};
#endif // SETTINGSDIALOG_H
-117
View File
@@ -1,117 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>488</width>
<height>220</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<normaloff>:/images/connected.png</normaloff>:/images/connected.png</iconset>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Custom Parameters:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPlainTextEdit" name="extraArgsInput">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>The configuration has been moved to &quot;/etc/gpservice/gp.conf&quot;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>clientos:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="clientosInput">
<property name="placeholderText">
<string>e.g., Windows</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="osVersionInput"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>os-version:</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
-60
View File
@@ -1,60 +0,0 @@
#include <QtGui/QCloseEvent>
#include "standardloginwindow.h"
#include "ui_standardloginwindow.h"
#include "gphelper.h"
using namespace gpclient::helper;
StandardLoginWindow::StandardLoginWindow(const QString &portalAddress, const QString &labelUsername,
const QString &labelPassword, const QString &authMessage) :
QDialog(nullptr),
ui(new Ui::StandardLoginWindow) {
ui->setupUi(this);
ui->portalAddress->setText(portalAddress);
ui->username->setPlaceholderText(labelUsername);
ui->password->setPlaceholderText(labelPassword);
ui->authMessage->setText(authMessage);
autocomplete();
setWindowTitle("GlobalProtect Login");
setFixedSize(width(), height());
setModal(true);
}
void StandardLoginWindow::autocomplete() {
QString username, password;
settings::secureGet("username", username);
settings::secureGet("password", password);
if (!username.isEmpty() && !password.isEmpty()) {
ui->username->setText(username);
ui->password->setText(password);
}
}
void StandardLoginWindow::setProcessing(bool isProcessing) {
ui->username->setReadOnly(isProcessing);
ui->password->setReadOnly(isProcessing);
ui->loginButton->setDisabled(isProcessing);
}
void StandardLoginWindow::on_loginButton_clicked() {
const QString username = ui->username->text().trimmed();
const QString password = ui->password->text().trimmed();
if (username.isEmpty() || password.isEmpty()) {
return;
}
settings::secureSave("username", username);
settings::secureSave("password", password);
emit performLogin(username, password);
}
void StandardLoginWindow::closeEvent(QCloseEvent *event) {
event->accept();
reject();
}
-34
View File
@@ -1,34 +0,0 @@
#ifndef STANDARDLOGINWINDOW_H
#define STANDARDLOGINWINDOW_H
#include <QtWidgets/QDialog>
namespace Ui {
class StandardLoginWindow;
}
class StandardLoginWindow : public QDialog {
Q_OBJECT
public:
explicit StandardLoginWindow(const QString &portalAddress, const QString &labelUsername,
const QString &labelPassword, const QString &authMessage);
void setProcessing(bool isProcessing);
private slots:
void on_loginButton_clicked();
signals:
void performLogin(QString username, QString password);
private:
Ui::StandardLoginWindow *ui;
void closeEvent(QCloseEvent *event);
void autocomplete();
};
#endif // STANDARDLOGINWINDOW_H
-148
View File
@@ -1,148 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StandardLoginWindow</class>
<widget class="QDialog" name="StandardLoginWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>255</width>
<height>269</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="windowTitle">
<string>Login</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="1,0,0">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>Login</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="authMessage">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Please enter the login credentials</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="portalLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Portal:</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="portalAddress">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>vpn.example.com</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLineEdit" name="username">
<property name="placeholderText">
<string>Username</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="password">
<property name="text">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>Password</string>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loginButton">
<property name="text">
<string>Login</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
-24
View File
@@ -1,24 +0,0 @@
#ifndef VPN_H
#define VPN_H
#include <QtCore/QObject>
#include <QtCore/QString>
class IVpn
{
public:
virtual ~IVpn() = default;
virtual void connect(const QString &preferredServer, const QList<QString> &servers, const QString &username, const QString &passwd) = 0;
virtual void disconnect() = 0;
virtual int status() = 0;
// signals: // SIGNALS
// virtual void connected();
// virtual void disconnected();
// virtual void error(const QString &errorMessage);
// virtual void logAvailable(const QString &log);
};
Q_DECLARE_INTERFACE(IVpn, "IVpn") // define this out of namespace scope
#endif
-13
View File
@@ -1,13 +0,0 @@
#include "vpn_dbus.h"
void VpnDbus::connect(const QString &preferredServer, const QList<QString> &servers, const QString &username, const QString &passwd) {
inner->connect(preferredServer, username, passwd);
}
void VpnDbus::disconnect() {
inner->disconnect();
}
int VpnDbus::status() {
return inner->status();
}
-33
View File
@@ -1,33 +0,0 @@
#ifndef VPN_DBUS_H
#define VPN_DBUS_H
#include "vpn.h"
#include "gpserviceinterface.h"
class VpnDbus : public QObject, public IVpn
{
Q_OBJECT
Q_INTERFACES(IVpn)
private:
com::yuezk::qt::GPService *inner;
public:
VpnDbus(QObject *parent) : QObject(parent) {
inner = new com::yuezk::qt::GPService("com.yuezk.qt.GPService", "/", QDBusConnection::systemBus(), this);
QObject::connect(inner, &com::yuezk::qt::GPService::connected, this, &VpnDbus::connected);
QObject::connect(inner, &com::yuezk::qt::GPService::disconnected, this, &VpnDbus::disconnected);
QObject::connect(inner, &com::yuezk::qt::GPService::error, this, &VpnDbus::error);
QObject::connect(inner, &com::yuezk::qt::GPService::logAvailable, this, &VpnDbus::logAvailable);
}
void connect(const QString &preferredServer, const QList<QString> &servers, const QString &username, const QString &passwd);
void disconnect();
int status();
signals: // SIGNALS
void connected();
void disconnected();
void error(QString errorMessage);
void logAvailable(QString log);
};
#endif
-24
View File
@@ -1,24 +0,0 @@
#include "vpn_json.h"
#include <QTextStream>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
void VpnJson::connect(const QString &preferredServer, const QList<QString> &servers, const QString &username, const QString &passwd) {
QJsonArray sl;
for (const QString &srv : servers) {
sl.push_back(QJsonValue(srv));
}
QJsonObject j;
j["server"] = preferredServer;
j["availableServers"] = sl;
j["cookie"] = passwd;
QTextStream(stdout) << QJsonDocument(j).toJson(QJsonDocument::Compact) << "\n";
emit connected();
}
void VpnJson::disconnect() { /* nop */ }
int VpnJson::status() {
return 4; // disconnected
}
-23
View File
@@ -1,23 +0,0 @@
#ifndef VPN_JSON_H
#define VPN_JSON_H
#include "vpn.h"
class VpnJson : public QObject, public IVpn
{
Q_OBJECT
Q_INTERFACES(IVpn)
public:
VpnJson(QObject *parent) : QObject(parent) {}
void connect(const QString &preferredServer, const QList<QString> &servers, const QString &username, const QString &passwd);
void disconnect();
int status();
signals: // SIGNALS
void connected();
void disconnected();
void error(const QString &errorMessage);
void logAvailable(const QString &log);
};
#endif
-83
View File
@@ -1,83 +0,0 @@
include("${CMAKE_SOURCE_DIR}/cmake/Add3rdParty.cmake")
project(GPService)
set(gpservice_GENERATED_SOURCES)
execute_process(COMMAND logname OUTPUT_VARIABLE CMAKE_LOGNAME)
string(STRIP "${CMAKE_LOGNAME}" CMAKE_LOGNAME)
message(STATUS "CMAKE_LOGNAME: ${CMAKE_LOGNAME}")
configure_file(dbus/com.yuezk.qt.GPService.conf.in dbus/com.yuezk.qt.GPService.conf)
configure_file(dbus/com.yuezk.qt.GPService.service.in dbus/com.yuezk.qt.GPService.service)
configure_file(systemd/gpservice.service.in systemd/gpservice.service)
# generate the dbus xml definition
qt5_generate_dbus_interface(
gpservice.h
${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml
)
# generate dbus adaptor
qt5_add_dbus_adaptor(
gpservice_GENERATED_SOURCES
${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml
gpservice.h
GPService
)
add_executable(gpservice
gpservice.h
gpservice.cpp
main.cpp
${gpservice_GENERATED_SOURCES}
)
add_3rdparty(
SingleApplication
GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication.git
GIT_TAG v3.3.0
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
-DCMAKE_PREFIX_PATH=$ENV{CMAKE_PREFIX_PATH}
-DQAPPLICATION_CLASS=QCoreApplication
)
ExternalProject_Get_Property(SingleApplication-${PROJECT_NAME} SOURCE_DIR BINARY_DIR)
set(SingleApplication_INCLUDE_DIR ${SOURCE_DIR})
set(SingleApplication_LIBRARY ${BINARY_DIR}/libSingleApplication.a)
add_dependencies(gpservice SingleApplication-${PROJECT_NAME})
target_include_directories(gpservice PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${SingleApplication_INCLUDE_DIR}
)
target_link_libraries(gpservice
${SingleApplication_LIBRARY}
Qt5::Core
Qt5::Network
Qt5::DBus
QtSignals
inih
)
target_compile_definitions(gpservice PUBLIC QAPPLICATION_CLASS=QCoreApplication)
install(TARGETS gpservice DESTINATION bin)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dbus/com.yuezk.qt.GPService.conf" DESTINATION share/dbus-1/system.d )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dbus/com.yuezk.qt.GPService.service" DESTINATION share/dbus-1/system-services)
install(FILES "gp.conf" DESTINATION /etc/gpservice)
if("$ENV{DEBIAN_PACKAGE}")
# Install the systemd unit files to /lib/systemd/system for debian package
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/systemd/gpservice.service" DESTINATION /lib/systemd/system)
else()
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/systemd/gpservice.service" DESTINATION lib/systemd/system)
endif()
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
<allow own="com.yuezk.qt.GPService"/>
</policy>
<policy context="default">
<allow send_destination="com.yuezk.qt.GPService"
send_interface="com.yuezk.qt.GPService"
/>
<allow send_destination="com.yuezk.qt.GPService"
send_interface="org.freedesktop.DBus.Introspectable"
/>
</policy>
</busconfig>
@@ -1,5 +0,0 @@
[D-BUS Service]
Name=com.yuezk.qt.GPService
Exec=@CMAKE_INSTALL_PREFIX@/bin/gpservice
User=root
SystemdService=gpservice.service
-17
View File
@@ -1,17 +0,0 @@
# Configuration file for GlobalProtect-openconnect
#
# Description:
#
# Each section is a VPN gateway address, and [*] is a special section that defines the default configuration.
# See https://github.com/yuezk/GlobalProtect-openconnect/wiki/Configuration for more details.
#
# Example:
#
# [*]
# openconnect-args=<value>
#
# [vpn1.company.com]
# openconnect-args=--script=/path/to/vpnc-script
[*]
openconnect-args=
-229
View File
@@ -1,229 +0,0 @@
#include <QtCore/QFileInfo>
#include <QtCore/QDateTime>
#include <QtCore/QVariant>
#include <QtCore/QRegularExpression>
#include <QtCore/QRegularExpressionMatch>
#include <QtDBus/QtDBus>
#include "INIReader.h"
#include "gpservice.h"
#include "gpserviceadaptor.h"
GPService::GPService(QObject *parent)
: QObject(parent)
, openconnect(new QProcess)
{
// Register the DBus service
new GPServiceAdaptor(this);
QDBusConnection dbus = QDBusConnection::systemBus();
dbus.registerObject("/", this);
dbus.registerService("com.yuezk.qt.GPService");
// Setup the openconnect process
QObject::connect(openconnect, &QProcess::started, this, &GPService::onProcessStarted);
QObject::connect(openconnect, &QProcess::errorOccurred, this, &GPService::onProcessError);
QObject::connect(openconnect, &QProcess::readyReadStandardOutput, this, &GPService::onProcessStdout);
QObject::connect(openconnect, &QProcess::readyReadStandardError, this, &GPService::onProcessStderr);
QObject::connect(openconnect, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &GPService::onProcessFinished);
}
GPService::~GPService()
{
delete openconnect;
}
QString GPService::findBinary()
{
for (int i = 0; i < binaryPaths->length(); i++) {
if (QFileInfo::exists(binaryPaths[i])) {
return binaryPaths[i];
}
}
return nullptr;
}
QString GPService::extraOpenconnectArgs(const QString &gateway)
{
INIReader reader("/etc/gpservice/gp.conf");
if (reader.ParseError() < 0) {
return "";
}
std::string defaultArgs = reader.Get("*", "openconnect-args", "");
std::string extraArgs = reader.Get(gateway.toStdString(), "openconnect-args", defaultArgs);
return QString::fromStdString(extraArgs);
}
/* Port from https://github.com/qt/qtbase/blob/11d1dcc6e263c5059f34b44d531c9ccdf7c0b1d6/src/corelib/io/qprocess.cpp#L2115 */
QStringList GPService::splitCommand(const QString &command)
{
QStringList args;
QString tmp;
int quoteCount = 0;
bool inQuote = false;
// handle quoting. tokens can be surrounded by double quotes
// "hello world". three consecutive double quotes represent
// the quote character itself.
for (int i = 0; i < command.size(); ++i) {
if (command.at(i) == QLatin1Char('"')) {
++quoteCount;
if (quoteCount == 3) {
// third consecutive quote
quoteCount = 0;
tmp += command.at(i);
}
continue;
}
if (quoteCount) {
if (quoteCount == 1)
inQuote = !inQuote;
quoteCount = 0;
}
if (!inQuote && command.at(i).isSpace()) {
if (!tmp.isEmpty()) {
args += tmp;
tmp.clear();
}
} else {
tmp += command.at(i);
}
}
if (!tmp.isEmpty())
args += tmp;
return args;
}
void GPService::quit()
{
if (openconnect->state() == QProcess::NotRunning) {
exit(0);
} else {
aboutToQuit = true;
openconnect->terminate();
}
}
void GPService::connect(QString server, QString username, QString passwd)
{
if (vpnStatus != GPService::VpnNotConnected) {
log("VPN status is: " + QVariant::fromValue(vpnStatus).toString());
return;
}
QString bin = findBinary();
if (bin == nullptr) {
log("Could not find openconnect binary, make sure openconnect is installed, exiting.");
emit error("The OpenConect CLI was not found, make sure it has been installed!");
return;
}
if (!isValidVersion(bin)) {
return;
}
const QString extraArgs = extraOpenconnectArgs(server);
log(QString("Got extra OpenConnect args for server: %1, %2").arg(server, extraArgs.isEmpty() ? "<empty>" : extraArgs));
QStringList args;
args << QCoreApplication::arguments().mid(1)
<< "--protocol=gp"
<< splitCommand(extraArgs)
<< "-u" << username
<< "--cookie-on-stdin"
<< server;
log("Start process with arugments: " + args.join(", "));
openconnect->start(bin, args);
openconnect->write((passwd + "\n").toUtf8());
}
bool GPService::isValidVersion(QString &bin) {
QProcess p;
p.start(bin, QStringList("--version"));
p.waitForFinished();
QString output = p.readAllStandardError() + p.readAllStandardOutput();
QRegularExpression re("v(\\d+).*?(\\s|\\n)");
QRegularExpressionMatch match = re.match(output);
if (match.hasMatch()) {
log("Output of `openconnect --version`: " + output);
QString fullVersion = match.captured(0);
QString majorVersion = match.captured(1);
if (majorVersion.toInt() < 8) {
emit error("The OpenConnect version must greater than v8.0.0, got " + fullVersion);
return false;
}
} else {
log("Failed to parse the OpenConnect version from " + output);
}
return true;
}
void GPService::disconnect()
{
if (openconnect->state() != QProcess::NotRunning) {
vpnStatus = GPService::VpnDisconnecting;
openconnect->terminate();
}
}
int GPService::status()
{
return vpnStatus;
}
void GPService::onProcessStarted()
{
log("Openconnect started successfully, PID=" + QString::number(openconnect->processId()));
vpnStatus = GPService::VpnConnecting;
}
void GPService::onProcessError(QProcess::ProcessError error)
{
log("Error occurred: " + QVariant::fromValue(error).toString());
vpnStatus = GPService::VpnNotConnected;
emit disconnected();
}
void GPService::onProcessStdout()
{
QString output = openconnect->readAllStandardOutput();
log(output);
if (output.indexOf("Connected as") >= 0 ||
output.indexOf("Configured as") >= 0 ||
output.indexOf("Configurado como") >= 0) {
vpnStatus = GPService::VpnConnected;
emit connected();
}
}
void GPService::onProcessStderr()
{
log(openconnect->readAllStandardError());
}
void GPService::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
log("Openconnect process exited with code " + QString::number(exitCode) + " and exit status " + QVariant::fromValue(exitStatus).toString());
vpnStatus = GPService::VpnNotConnected;
emit disconnected();
if (aboutToQuit) {
exit(0);
};
}
void GPService::log(QString msg)
{
emit logAvailable(msg);
}
-63
View File
@@ -1,63 +0,0 @@
#ifndef GLOBALPROTECTSERVICE_H
#define GLOBALPROTECTSERVICE_H
#include <QtCore/QObject>
#include <QtCore/QProcess>
static const QString binaryPaths[] {
"/usr/local/bin/openconnect",
"/usr/local/sbin/openconnect",
"/usr/bin/openconnect",
"/usr/sbin/openconnect",
"/opt/bin/openconnect",
"/opt/sbin/openconnect"
};
class GPService : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.yuezk.qt.GPService")
public:
explicit GPService(QObject *parent = nullptr);
~GPService();
void quit();
enum VpnStatus {
VpnNotConnected,
VpnConnecting,
VpnConnected,
VpnDisconnecting,
};
signals:
void connected();
void disconnected();
void error(QString errorMessage);
void logAvailable(QString log);
public slots:
void connect(QString server, QString username, QString passwd);
void disconnect();
int status();
private slots:
void onProcessStarted();
void onProcessError(QProcess::ProcessError error);
void onProcessStdout();
void onProcessStderr();
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
private:
QProcess *openconnect;
bool aboutToQuit = false;
int vpnStatus = GPService::VpnNotConnected;
void log(QString msg);
bool isValidVersion(QString &bin);
static QString findBinary();
static QString extraOpenconnectArgs(const QString &gateway);
static QStringList splitCommand(const QString &command);
};
#endif // GLOBALPROTECTSERVICE_H
-27
View File
@@ -1,27 +0,0 @@
#include <QtDBus/QtDBus>
#include "gpservice.h"
#include "singleapplication.h"
#include "sigwatch.h"
int main(int argc, char *argv[])
{
SingleApplication app(argc, argv);
if (!QDBusConnection::systemBus().isConnected()) {
qWarning("Cannot connect to the D-Bus session bus.\n"
"Please check your system settings and try again.\n");
return 1;
}
GPService service;
UnixSignalWatcher sigwatch;
sigwatch.watchForSignal(SIGINT);
sigwatch.watchForSignal(SIGTERM);
sigwatch.watchForSignal(SIGQUIT);
sigwatch.watchForSignal(SIGHUP);
QObject::connect(&sigwatch, &UnixSignalWatcher::unixSignal, &service, &GPService::quit);
return app.exec();
}
-11
View File
@@ -1,11 +0,0 @@
[Unit]
Description=GlobalProtect openconnect DBus service
[Service]
Environment="LANG=en_US.utf8"
Type=dbus
BusName=com.yuezk.qt.GPService
ExecStart=@CMAKE_INSTALL_PREFIX@/bin/gpservice
[Install]
WantedBy=multi-user.target
+507
View File
@@ -0,0 +1,507 @@
SHELL := /bin/sh
.SHELLFLAGS := -ec
INCLUDE_GUI ?= 0
CARGO ?= cargo
CARGO_TARGET_DIR ?= target
CARGO_RELEASE_DIR ?= $(CARGO_TARGET_DIR)/$(if $(CARGO_BUILD_TARGET),$(CARGO_BUILD_TARGET)/)release
DISABLE_RUST_TOOLCHAIN ?= 0
RUST_VERSION ?= 1.91
IGNORE_RUST_VERSION ?= 0
VERSION = $(shell grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')
SOURCE_COMMIT_VALUE := $(shell \
if [ -n "$$SOURCE_GIT_COMMIT" ]; then \
printf '%s' "$$SOURCE_GIT_COMMIT" | cut -c1-9; \
elif [ -n "$$GITHUB_SHA" ]; then \
printf '%s' "$$GITHUB_SHA" | cut -c1-9; \
elif [ -f SOURCE_COMMIT ]; then \
head -n1 SOURCE_COMMIT | tr -d '[:space:]' | cut -c1-9; \
else \
git rev-parse --short=9 HEAD 2>/dev/null || printf unknown; \
fi)
GUI_LIBC_SUFFIX ?= $(shell ldd --version 2>&1 | grep -qi musl && echo -musl || true)
REVISION ?= 1
RPM_SOURCE ?= %{name}.tar.gz
PPA_REVISION ?= 1
PKG_NAME = globalprotect-openconnect
PKG = $(PKG_NAME)-$(VERSION)
SERIES ?= $(shell lsb_release -cs)
PUBLISH ?= 0
# Indicates whether to build the GUI components
BUILD_GUI_HELPER ?= 1
# Indicates whether to build embedded webview auth support into gpauth
BUILD_WEBVIEW_AUTH ?= 1
ifeq ($(shell uname -s),Linux)
PREFIX ?= /usr
GPGUI_BINARY ?= $(wildcard .build/gpgui/gpgui_*/gpgui)
else ifeq ($(shell uname -s)-$(shell uname -m),Darwin-arm64)
PREFIX ?= /opt/homebrew
else
PREFIX ?= /usr/local
endif
BSD_FLAVOR ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
GPGUI_BINARY ?= ../gpgui/target/release/gpgui
export DEBEMAIL = [email protected]
export DEBFULLNAME = Kevin Yue
export SNAPSHOT = $(shell test -f SNAPSHOT && echo "true" || echo "false")
export OFFLINE_BUILD = $(shell test -f OFFLINE_BUILD && echo "1" || echo "0")
# If OFFLINE is not set, use OFFLINE_BUILD
ifndef OFFLINE
OFFLINE = $(OFFLINE_BUILD)
endif
ifeq ($(SNAPSHOT), true)
RELEASE_TAG = snapshot
else
RELEASE_TAG = v$(VERSION)
endif
CARGO_BUILD_ARGS = --release
ifeq ($(OFFLINE), 1)
CARGO_BUILD_ARGS += --frozen
endif
ifeq ($(IGNORE_RUST_VERSION), 1)
CARGO_BUILD_ARGS += --ignore-rust-version
endif
default: build
dev-service:
./scripts/dev-service.sh
version:
@echo $(VERSION)
clean-tarball:
rm -rf .build/tarball
rm -rf .vendor
rm -rf vendor.tar.xz
rm -rf .cargo
rm -f SOURCE_COMMIT
# Create a tarball, include the cargo dependencies if OFFLINE is set to 1
tarball: clean-tarball
mkdir -p .cargo
mkdir -p .build/tarball
printf '%s\n' "$(SOURCE_COMMIT_VALUE)" > SOURCE_COMMIT
# If OFFLINE is set to 1, vendor all cargo dependencies
# Generate a OFFLINE_BUILD file to indicate offline build
if [ $(OFFLINE) -eq 1 ]; then \
$(CARGO) vendor .vendor > .cargo/config.toml; \
tar -cJf vendor.tar.xz .vendor; \
touch OFFLINE_BUILD; \
fi
@echo "Creating tarball..."
tar --exclude .vendor --exclude target --transform 's,^,${PKG}/,' -czf .build/tarball/${PKG}.tar.gz * .cargo
download-gui:
rm -rf .build/gpgui
if [ $(INCLUDE_GUI) -eq 1 ]; then \
echo "Downloading GlobalProtect GUI..."; \
mkdir -p .build/gpgui; \
curl -sSL https://github.com/yuezk/GlobalProtect-openconnect/releases/download/$(RELEASE_TAG)/gpgui_$(shell uname -m)$(GUI_LIBC_SUFFIX).bin.tar.xz \
-o .build/gpgui/gpgui_$(shell uname -m)$(GUI_LIBC_SUFFIX).bin.tar.xz; \
tar -xJf .build/gpgui/*.tar.xz -C .build/gpgui; \
else \
echo "Skipping GlobalProtect GUI download (INCLUDE_GUI=0)"; \
fi
build: download-gui build-rs
build-rs:
if [ $(OFFLINE) -eq 1 ]; then \
tar -xJf vendor.tar.xz; \
fi
# Remove the rust-toolchain.toml if DISABLE_RUST_TOOLCHAIN is set to 1
if [ $(DISABLE_RUST_TOOLCHAIN) -eq 1 ]; then \
rm -vf rust-toolchain.toml; \
fi
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice
# Build gpauth with or without embedded webview auth support
if [ $(BUILD_WEBVIEW_AUTH) -eq 1 ]; then \
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth; \
else \
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth --no-default-features; \
fi
# Only build the GUI components if BUILD_GUI_HELPER is set to 1
if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpgui-helper; \
fi
clean:
$(CARGO) clean
rm -rf .build
rm -rf .vendor
rm -rf apps/gpgui-helper/node_modules
ifeq ($(shell uname -s),Darwin)
install: install-macos
install-gpclient: install-gpclient-macos
else ifneq ($(filter FreeBSD OpenBSD,$(shell uname -s)),)
install: install-bsd
install-gpclient: install-gpclient-unix
else
install: install-linux
install-gpclient: install-gpclient-unix
endif
install-gpclient-unix:
install -d "$(DESTDIR)$(PREFIX)/bin" "$(DESTDIR)$(PREFIX)/libexec/gpclient"
install -m 755 "$(CARGO_RELEASE_DIR)/gpclient" "$(DESTDIR)$(PREFIX)/bin/"
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script "$(DESTDIR)$(PREFIX)/libexec/gpclient/"
install-gpclient-macos:
install -d "$(DESTDIR)$(PREFIX)/bin" "$(DESTDIR)$(PREFIX)/lib/gpclient" "$(DESTDIR)$(PREFIX)/libexec/gpclient"
install -m 755 "$(CARGO_RELEASE_DIR)/gpclient" "$(DESTDIR)$(PREFIX)/bin/"
set -e; library=$$(sh scripts/macos-openconnect-library.sh "$(CARGO_RELEASE_DIR)/gpclient"); \
install -m 755 "$$library" "$(DESTDIR)$(PREFIX)/lib/gpclient/"; \
install_name_tool -delete_rpath "$$(dirname "$$library")" "$(DESTDIR)$(PREFIX)/bin/gpclient"; \
codesign --force --sign - "$(DESTDIR)$(PREFIX)/bin/gpclient"
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script "$(DESTDIR)$(PREFIX)/libexec/gpclient/"
install-macos: install-gpclient-macos
install -m 755 "$(CARGO_RELEASE_DIR)/gpauth" "$(DESTDIR)$(PREFIX)/bin/"
# Common executable and icon installation uses portable install options on Linux/BSD.
install-unix: install-gpclient-unix
set -e; for binary in gpauth gpservice; do \
install -m 755 "$(CARGO_RELEASE_DIR)/$$binary" "$(DESTDIR)$(PREFIX)/bin/"; \
done
set -e; for binary in gp-hip-script-installer gp-vpnc-script-installer; do \
install -m 755 "$(CARGO_RELEASE_DIR)/$$binary" "$(DESTDIR)$(PREFIX)/libexec/gpclient/"; \
done
set -e; if [ "$(BUILD_GUI_HELPER)" = "1" ]; then \
install -m 755 "$(CARGO_RELEASE_DIR)/gpgui-helper" "$(DESTDIR)$(PREFIX)/bin/"; \
fi
set -e; if [ -f "$(GPGUI_BINARY)" ]; then \
install -m 755 "$(GPGUI_BINARY)" "$(DESTDIR)$(PREFIX)/bin/gpgui"; \
fi
set -e; for file in packaging/files/usr/share/icons/hicolor/*/apps/gpgui.* \
packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-*.svg; do \
destination="$(DESTDIR)$(PREFIX)/$${file#packaging/files/usr/}"; \
install -d "$$(dirname "$$destination")"; \
install -m 644 "$$file" "$$destination"; \
done
install-linux: install-unix
@echo "Installing Linux integration under $(PREFIX)..."
set -e; for file in share/applications/gpgui.desktop \
share/polkit-1/actions/com.yuezk.gpgui.policy \
lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \
lib/NetworkManager/dispatcher.d/gpclient-nm-hook; do \
mode=644; case "$$file" in lib/*) mode=755 ;; esac; \
destination="$(DESTDIR)$(PREFIX)/$$file"; \
install -d "$$(dirname "$$destination")"; \
install -m "$$mode" "packaging/files/usr/$$file" "$$destination"; \
done
sh scripts/relocate-install-paths.sh "$(PREFIX)" /usr "$(DESTDIR)$(PREFIX)"
install-bsd: install-unix
@echo "Installing BSD integration under $(PREFIX)..."
install -d "$(DESTDIR)$(PREFIX)/share/applications" "$(DESTDIR)$(PREFIX)/share/polkit-1/actions"
install -m 644 packaging/bsd/gpgui.desktop "$(DESTDIR)$(PREFIX)/share/applications/"
install -m 644 packaging/bsd/com.yuezk.gpgui.policy "$(DESTDIR)$(PREFIX)/share/polkit-1/actions/"
sh scripts/relocate-install-paths.sh "$(PREFIX)" /usr/local "$(DESTDIR)$(PREFIX)"
clean-bsd-package:
rm -rf .build/$(BSD_FLAVOR)
bsd-gpgui-tarball:
test -x "$(GPGUI_BINARY)"
rm -rf .build/$(BSD_FLAVOR)/gpgui
mkdir -p .build/$(BSD_FLAVOR)/artifacts .build/$(BSD_FLAVOR)/gpgui/gpgui_$(VERSION)
cp "$(GPGUI_BINARY)" .build/$(BSD_FLAVOR)/gpgui/gpgui_$(VERSION)/
tar -cf - -C .build/$(BSD_FLAVOR)/gpgui gpgui_$(VERSION) | xz -c > .build/$(BSD_FLAVOR)/artifacts/gpgui_$(BSD_FLAVOR)_$(shell uname -m).bin.tar.xz
file=.build/$(BSD_FLAVOR)/artifacts/gpgui_$(BSD_FLAVOR)_$(shell uname -m).bin.tar.xz; \
if command -v sha256sum >/dev/null 2>&1; then sha256sum "$$file" | cut -d ' ' -f 1; \
elif command -v sha256 >/dev/null 2>&1; then sha256 -q "$$file"; \
else cksum -a sha256 "$$file" | awk '{print $$1}'; fi > "$$file.sha256"
package-freebsd: BSD_FLAVOR=freebsd
package-freebsd: clean-bsd-package
test -x "$(GPGUI_BINARY)"
mkdir -p .build/freebsd/pkgroot .build/freebsd/artifacts .build/freebsd/metadata
$(MAKE) install-bsd DESTDIR=$(CURDIR)/.build/freebsd/pkgroot PREFIX=$(PREFIX) GPGUI_BINARY="$(GPGUI_BINARY)"
find .build/freebsd/pkgroot$(PREFIX) -type f -print | sed 's|^.build/freebsd/pkgroot$(PREFIX)/||' | sort > .build/freebsd/PLIST
freebsd_major=$$(freebsd-version -u | sed 's/\..*//'); \
freebsd_arch=$$(uname -m | sed -e 's/x86_64/amd64/' -e 's/arm64/aarch64/'); \
sed \
-e 's/@PKG_NAME@/$(PKG_NAME)/g' \
-e 's/@VERSION@/$(VERSION)/g' \
-e "s/@ABI@/FreeBSD:$$freebsd_major:$$freebsd_arch/g" \
-e "s/@ARCH@/freebsd:$$freebsd_major:$$freebsd_arch/g" \
-e 's|@PREFIX@|$(PREFIX)|g' \
packaging/bsd/freebsd/MANIFEST.in > .build/freebsd/metadata/+MANIFEST
cp packaging/bsd/freebsd/POST_DEINSTALL .build/freebsd/metadata/+POST_DEINSTALL
pkg create -r .build/freebsd/pkgroot -M .build/freebsd/metadata -p .build/freebsd/PLIST -o .build/freebsd/artifacts
freebsd_arch=$$(uname -m | sed -e 's/x86_64/amd64/' -e 's/arm64/aarch64/'); \
mv .build/freebsd/artifacts/$(PKG_NAME)-$(VERSION).pkg .build/freebsd/artifacts/$(PKG_NAME)-$(VERSION)-freebsd-$$freebsd_arch.pkg
$(MAKE) bsd-gpgui-tarball BSD_FLAVOR=freebsd GPGUI_BINARY="$(GPGUI_BINARY)"
package-openbsd: BSD_FLAVOR=openbsd
package-openbsd: clean-bsd-package
test -x "$(GPGUI_BINARY)"
mkdir -p .build/openbsd/pkgroot .build/openbsd/artifacts
$(MAKE) install-bsd DESTDIR=$(CURDIR)/.build/openbsd/pkgroot PREFIX=$(PREFIX) GPGUI_BINARY="$(GPGUI_BINARY)"
cp packaging/bsd/openbsd/COMMENT .build/openbsd/+COMMENT
cp packaging/bsd/openbsd/DESC .build/openbsd/+DESC
{ \
echo '@unexec-delete /bin/rm -f /usr/local/libexec/gpclient/gpgui /var/db/gpclient/scripts/vpnc-script /var/db/gpclient/scripts/vpnc-script.metadata || echo "Warning: failed to remove gpclient runtime files" >&2'; \
echo '@unexec-delete /bin/rmdir /usr/local/libexec/gpclient 2>/dev/null || true'; \
echo '@unexec-delete /bin/rmdir /var/db/gpclient/scripts 2>/dev/null || true'; \
echo '@unexec-delete /bin/rmdir /var/db/gpclient 2>/dev/null || true'; \
find .build/openbsd/pkgroot$(PREFIX) -type f -print | sed 's|^.build/openbsd/pkgroot$(PREFIX)/||' | sort; \
} > .build/openbsd/PLIST
comment=$$(cat .build/openbsd/+COMMENT); \
openbsd_arch=$$(uname -m | sed 's/x86_64/amd64/'); \
gnome_keyring_pkg=$$(pkg_info -e 'gnome-keyring-*' | sed 's/^inst://' | head -n 1); \
dbus_pkg=$$(pkg_info -e 'dbus-*' | sed 's/^inst://' | head -n 1); \
polkit_pkg=$$(pkg_info -e 'polkit-*' | sed 's/^inst://' | head -n 1); \
webkitgtk_pkg=$$(pkg_info -e 'webkitgtk41-*' | sed 's/^inst://' | head -n 1); \
xdg_utils_pkg=$$(pkg_info -e 'xdg-utils-*' | sed 's/^inst://' | head -n 1); \
pkg_create \
-B .build/openbsd/pkgroot \
-D COMMENT="$$comment" \
-d .build/openbsd/+DESC \
-f .build/openbsd/PLIST \
-p $(PREFIX) \
-P x11/gnome/keyring:gnome-keyring-*:$$gnome_keyring_pkg \
-P x11/dbus:dbus-*:$$dbus_pkg \
-P sysutils/polkit:polkit-*:$$polkit_pkg \
-P www/webkitgtk4,webkitgtk41:webkitgtk41-*:$$webkitgtk_pkg \
-P devel/xdg-utils:xdg-utils-*:$$xdg_utils_pkg \
.build/openbsd/artifacts/$(PKG_NAME)-$(VERSION)-openbsd-$$openbsd_arch.tgz
$(MAKE) bsd-gpgui-tarball BSD_FLAVOR=openbsd GPGUI_BINARY="$(GPGUI_BINARY)"
ifeq ($(shell uname -s),Darwin)
uninstall: uninstall-macos
else ifneq ($(filter FreeBSD OpenBSD,$(shell uname -s)),)
uninstall: uninstall-bsd
else
uninstall: uninstall-linux
endif
.PHONY: install install-gpclient install-macos install-unix install-linux install-bsd \
install-gpclient-macos install-gpclient-unix \
uninstall uninstall-macos uninstall-unix uninstall-linux uninstall-bsd
uninstall-macos:
@echo "Uninstalling $(PKG_NAME) for macOS under $(PREFIX)..."
rm -f "$(DESTDIR)$(PREFIX)/bin/gpclient" "$(DESTDIR)$(PREFIX)/bin/gpauth" \
"$(DESTDIR)$(PREFIX)/libexec/gpclient/vpnc-script" \
"$(DESTDIR)$(PREFIX)/lib/gpclient/"libopenconnect.*.dylib
rmdir "$(DESTDIR)$(PREFIX)/lib/gpclient" "$(DESTDIR)$(PREFIX)/libexec/gpclient" 2>/dev/null || true
uninstall-unix:
@echo "Uninstalling $(PKG_NAME) under $(PREFIX)..."
set -e; for binary in gpclient gpauth gpservice gpgui-helper gpgui; do \
rm -f "$(DESTDIR)$(PREFIX)/bin/$$binary"; \
done
set -e; for file in gp-hip-script-installer gp-vpnc-script-installer vpnc-script; do \
rm -f "$(DESTDIR)$(PREFIX)/libexec/gpclient/$$file"; \
done
set -e; for file in packaging/files/usr/share/icons/hicolor/*/apps/gpgui.* \
packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-*.svg; do \
rm -f "$(DESTDIR)$(PREFIX)/$${file#packaging/files/usr/}"; \
done
rm -f "$(DESTDIR)$(PREFIX)/share/applications/gpgui.desktop" \
"$(DESTDIR)$(PREFIX)/share/polkit-1/actions/com.yuezk.gpgui.policy"
rmdir "$(DESTDIR)$(PREFIX)/libexec/gpclient" 2>/dev/null || true
uninstall-linux: uninstall-unix
rm -f "$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down" \
"$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/gpclient-nm-hook"
rm -f "$(DESTDIR)/var/lib/gpclient/gpgui" \
"$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script" \
"$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script.metadata"
rmdir "$(DESTDIR)/var/lib/gpclient/scripts" "$(DESTDIR)/var/lib/gpclient" 2>/dev/null || true
uninstall-bsd: uninstall-unix
rm -f "$(DESTDIR)/usr/local/libexec/gpclient/gpgui" \
"$(DESTDIR)/var/db/gpclient/scripts/vpnc-script" \
"$(DESTDIR)/var/db/gpclient/scripts/vpnc-script.metadata"
rmdir "$(DESTDIR)/var/db/gpclient/scripts" "$(DESTDIR)/var/db/gpclient" 2>/dev/null || true
clean-debian:
rm -rf .build/deb
# Generate the debian package structure, without the changelog
init-debian: clean-debian tarball
mkdir -p .build/deb
cp .build/tarball/${PKG}.tar.gz .build/deb
tar -xzf .build/deb/${PKG}.tar.gz -C .build/deb
cd .build/deb/${PKG} && debmake
cp -f packaging/deb/control.in .build/deb/$(PKG)/debian/control
cp -f packaging/deb/rules.in .build/deb/$(PKG)/debian/rules
cp -f packaging/deb/postrm .build/deb/$(PKG)/debian/postrm
cp -f packaging/deb/compat .build/deb/$(PKG)/debian/compat
sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/control
# Remove the GUI dependencies if neither GUI component is included
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ]; then \
sed -i "/libsecret-1-0/d" .build/deb/$(PKG)/debian/control; \
sed -i "/libayatana-appindicator3-1/d" .build/deb/$(PKG)/debian/control; \
sed -i "/gnome-keyring/d" .build/deb/$(PKG)/debian/control; \
fi
# Remove WebKitGTK only if no included component needs it
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \
sed -i "/libwebkit2gtk-4.1-dev/d" .build/deb/$(PKG)/debian/control; \
fi
sed -i "s/@INCLUDE_GUI@/$(INCLUDE_GUI)/g" .build/deb/$(PKG)/debian/rules
sed -i "s/@BUILD_GUI_HELPER@/$(BUILD_GUI_HELPER)/g" .build/deb/$(PKG)/debian/rules
sed -i "s/@BUILD_WEBVIEW_AUTH@/$(BUILD_WEBVIEW_AUTH)/g" .build/deb/$(PKG)/debian/rules
sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/rules
rm -f .build/deb/$(PKG)/debian/changelog
deb: init-debian
cd .build/deb/$(PKG) && dch --create --distribution unstable --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION) "Bugfix and improvements."
# Install build dependencies
cd .build/deb/$(PKG) && sudo mk-build-deps --install --remove debian/control || echo "mk-build-deps failed, continuing"
cd .build/deb/$(PKG) && debuild --preserve-env -e PATH -us -uc -b -d
check-ppa:
if [ $(OFFLINE) -eq 0 ]; then \
echo "Error: ppa build requires offline mode (OFFLINE=1)"; \
fi
# Usage: make ppa SERIES=focal OFFLINE=1 PUBLISH=1
ppa: check-ppa init-debian
$(eval SERIES_VER = $(shell distro-info --series $(SERIES) -r | cut -d' ' -f1))
@echo "Building for $(SERIES) $(SERIES_VER)"
rm -rf .build/deb/$(PKG)/debian/changelog
cd .build/deb/$(PKG) && dch --create --distribution $(SERIES) --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION)ppa$(PPA_REVISION)~ubuntu$(SERIES_VER) "Bugfix and improvements."
cd .build/deb/$(PKG) && echo "y" | debuild -e PATH -S -sa -k"$(GPG_KEY_ID)" -p"gpg --batch --passphrase $(GPG_KEY_PASS) --pinentry-mode loopback"
if [ $(PUBLISH) -eq 1 ]; then \
cd .build/deb/$(PKG) && dput ppa:yuezk/globalprotect-openconnect ../*.changes; \
else \
echo "Skipping ppa publish (PUBLISH=0)"; \
fi
clean-rpm:
rm -rf .build/rpm
# Generate RPM sepc file
init-rpm: clean-rpm
mkdir -p .build/rpm
cp packaging/rpm/globalprotect-openconnect.spec.in .build/rpm/globalprotect-openconnect.spec
cp packaging/rpm/globalprotect-openconnect.changes.in .build/rpm/globalprotect-openconnect.changes
sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.spec
sed -i "s/@REVISION@/$(REVISION)/g" .build/rpm/globalprotect-openconnect.spec
sed -i "s|@SOURCE@|$(RPM_SOURCE)|g" .build/rpm/globalprotect-openconnect.spec
sed -i "s/@DATE@/$(shell LC_ALL=en.US date "+%a %b %d %Y")/g" .build/rpm/globalprotect-openconnect.spec
sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.changes
sed -i "s/@DATE@/$(shell LC_ALL=en.US date -u "+%a %b %e %T %Z %Y")/g" .build/rpm/globalprotect-openconnect.changes
rpm: init-rpm tarball
rm -rf $(HOME)/rpmbuild
rpmdev-setuptree
cp .build/tarball/${PKG}.tar.gz $(HOME)/rpmbuild/SOURCES/${PKG_NAME}.tar.gz
rpmbuild -ba .build/rpm/globalprotect-openconnect.spec
# Copy RPM package from build directory
cp $(HOME)/rpmbuild/RPMS/$(shell uname -m)/$(PKG_NAME)*.rpm .build/rpm
# Copy the SRPM only for x86_64.
if [ "$(shell uname -m)" = "x86_64" ]; then \
cp $(HOME)/rpmbuild/SRPMS/$(PKG_NAME)*.rpm .build/rpm; \
fi
clean-pkgbuild:
rm -rf .build/pkgbuild
init-pkgbuild: clean-pkgbuild tarball
mkdir -p .build/pkgbuild
cp .build/tarball/${PKG}.tar.gz .build/pkgbuild
cp packaging/pkgbuild/PKGBUILD.in .build/pkgbuild/PKGBUILD
cp packaging/pkgbuild/gp.install .build/pkgbuild/gp.install
sed -i "s/@PKG_NAME@/$(PKG_NAME)/g" .build/pkgbuild/PKGBUILD
sed -i "s/@VERSION@/$(VERSION)/g" .build/pkgbuild/PKGBUILD
sed -i "s/@REVISION@/$(REVISION)/g" .build/pkgbuild/PKGBUILD
pkgbuild: init-pkgbuild
cd .build/pkgbuild && makepkg -s --noconfirm
clean-apk:
rm -rf .build/apk
init-apk: clean-apk tarball
mkdir -p .build/apk
cp .build/tarball/${PKG}.tar.gz .build/apk
cp packaging/apk/APKBUILD.in .build/apk/APKBUILD
cp packaging/apk/post-deinstall .build/apk/$(PKG_NAME).post-deinstall
sed -i "s/@PKG_NAME@/$(PKG_NAME)/g" .build/apk/APKBUILD
sed -i "s/@VERSION@/$(VERSION)/g" .build/apk/APKBUILD
sed -i "s/@REVISION@/$(REVISION)/g" .build/apk/APKBUILD
checksum=$$(sha512sum .build/apk/${PKG}.tar.gz | cut -d' ' -f1); \
sed -i "s/@SHA512@/$$checksum/g" .build/apk/APKBUILD
# Remove the GUI dependencies if neither GUI component is included
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ]; then \
sed -i "/^\tlibayatana-appindicator$$/d" .build/apk/APKBUILD; \
sed -i "/^\tlibsecret$$/d" .build/apk/APKBUILD; \
fi
# Remove WebKitGTK only if no included component needs it
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \
sed -i "/^\twebkit2gtk-4.1$$/d" .build/apk/APKBUILD; \
fi
apk: init-apk
cd .build/apk && abuild -r -P "$(CURDIR)/.build/apk/packages"
find .build/apk/packages -type f -name "$(PKG_NAME)-*.apk" -exec cp {} .build/apk \;
clean-binary:
rm -rf .build/binary
binary: clean-binary tarball
mkdir -p .build/binary
cp .build/tarball/${PKG}.tar.gz .build/binary
tar -xzf .build/binary/${PKG}.tar.gz -C .build/binary
mkdir -p .build/binary/$(PKG_NAME)_$(VERSION)/artifacts
make -C .build/binary/${PKG} build INCLUDE_GUI=$(INCLUDE_GUI)
make -C .build/binary/${PKG} install DESTDIR=$(PWD)/.build/binary/$(PKG_NAME)_$(VERSION)/artifacts
cp packaging/binary/Makefile.in .build/binary/$(PKG_NAME)_$(VERSION)/Makefile
# Create a tarball for the binary package
tar -cJf .build/binary/$(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.xz -C .build/binary $(PKG_NAME)_$(VERSION)
# Generate sha256sum
cd .build/binary && sha256sum $(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.xz | cut -d' ' -f1 > $(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.xz.sha256
Loaded 100 of 545 files, more files were not shown because too many files have changed in this diff. Show more