Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0cee157c8 | ||
|
|
e03a758acb | ||
|
|
16e08c09af | ||
|
|
a949b175d4 | ||
|
|
1202ca6c81 | ||
|
|
0408bcb67f | ||
|
|
a9474d4059 | ||
|
|
5380a5f3c3 | ||
|
|
82c9ba2dcd | ||
|
|
fd08cdbe66 | ||
|
|
d12d677208 | ||
|
|
d15ebdfe3a | ||
|
|
4f8f828a0b | ||
|
|
c3188ce1c8 | ||
|
|
e509cbccdb | ||
|
|
1ea9327f18 | ||
|
|
69e4183202 | ||
|
|
4b61c84c37 | ||
|
|
3a8080eb2f | ||
|
|
6040ced26b | ||
|
|
ddd2137143 | ||
|
|
915c130c70 | ||
|
|
9b297b14a6 | ||
|
|
69d67721a6 | ||
|
|
935240f9b5 | ||
|
|
e15422a64f | ||
|
|
dfab3882e1 | ||
|
|
4cf17f6256 | ||
|
|
ac81463a3b | ||
|
|
4faa2ecb0d | ||
|
|
56751a755c | ||
|
|
18ed6bac1a | ||
|
|
10139e0f2c | ||
|
|
ff1ea259d9 | ||
|
|
57322e3cf3 | ||
|
|
9532374805 | ||
|
|
90faa58811 | ||
|
|
93504eaec2 | ||
|
|
d73b712dd3 | ||
|
|
be111a671a | ||
|
|
f9965f8a35 | ||
|
|
f7649898fd | ||
|
|
e6910060df | ||
|
|
f41a429a5e | ||
|
|
888f288c0d | ||
|
|
f0292a9292 | ||
|
|
580b81e7bb | ||
|
|
8724ed3b37 | ||
|
|
01075cb6dc | ||
|
|
b7b708e9cd | ||
|
|
0425ee6ddb | ||
|
|
9e4f45997e | ||
|
|
3882e29b0e | ||
|
|
32bac9b675 | ||
|
|
0e1aedce82 | ||
|
|
8eb4d48887 | ||
|
|
87f91e3c13 | ||
|
|
f9f9dd8abe | ||
|
|
2283d4a076 | ||
|
|
d75e422c1d | ||
|
|
0c2d4830b5 | ||
|
|
3c49eab0c8 | ||
|
|
13ec7dfc37 | ||
|
|
e98fd7894a | ||
|
|
6f860d3dff | ||
|
|
5902bee5ff | ||
|
|
66f48b3ff6 | ||
|
|
0f7d065628 | ||
|
|
494e4a5331 | ||
|
|
b5b71df6e6 | ||
|
|
49f410e63b | ||
|
|
225acf13aa | ||
|
|
61d2b702c0 | ||
|
|
3276ac0f9a | ||
|
|
0b037e158c | ||
|
|
10e94e0b81 | ||
|
|
0f76539075 | ||
|
|
f9b8c55924 | ||
|
|
a708ce0115 | ||
|
|
b3f4ba0a32 | ||
|
|
02cf4a0b26 | ||
|
|
370189cbee | ||
|
|
6746cf64c3 | ||
|
|
40739739b5 | ||
|
|
dc7a200b93 | ||
|
|
f49b6471f3 | ||
|
|
4da922aa3b | ||
|
|
ecc9c9f09c | ||
|
|
b32002710b | ||
|
|
7b6d20a003 | ||
|
|
d27029fad8 | ||
|
|
1b488ba696 | ||
|
|
f78f7c9bc8 | ||
|
|
7e11693ce3 | ||
|
|
c601fa9aa2 | ||
|
|
536a43773f | ||
|
|
ae4cbedd3b | ||
|
|
fe55d11fc4 | ||
|
|
34f1feaf43 | ||
|
|
f640b4d325 | ||
|
|
a35b4a289e | ||
|
|
a7a5d9bf96 | ||
|
|
888dc93643 | ||
|
|
f98e0336dc | ||
|
|
7a571f9b27 | ||
|
|
67de92044f | ||
|
|
7d63836e35 | ||
|
|
3e23fc7d22 | ||
|
|
8bf05d381e | ||
|
|
1ab36a1137 | ||
|
|
18b788e664 | ||
|
|
ebadab8f06 | ||
|
|
81d13deaab | ||
|
|
6f91a79081 | ||
|
|
4d252fa31c | ||
|
|
398475c649 | ||
|
|
13d4aa398c | ||
|
|
9423665fe5 | ||
|
|
5e8dbfa26d | ||
|
|
d96b3f9c0d | ||
|
|
7720942681 | ||
|
|
f129ca7ea1 | ||
|
|
628d0febdd | ||
|
|
add284d3b4 | ||
|
|
a3f2224952 | ||
|
|
966bcc554b | ||
|
|
d6e3a212f2 | ||
|
|
e45b4a4145 | ||
|
|
93a7f4bd10 | ||
|
|
d1401171d8 | ||
|
|
9591ca287e | ||
|
|
46c80ecc93 | ||
|
|
99d2a26d45 | ||
|
|
067037517e | ||
|
|
c04b49fe11 | ||
|
|
a044cb35ad | ||
|
|
ac4b6240ef | ||
|
|
0c3af0d60d | ||
|
|
6289e1539a | ||
|
|
08a77f9d38 | ||
|
|
fb6db0dc12 | ||
|
|
731a0d895c | ||
|
|
ab58dd6cec | ||
|
|
cdcf03ff2f | ||
|
|
1d715f059d | ||
|
|
88951d863b | ||
|
|
0d5d06ead0 | ||
|
|
3171bb9fd1 | ||
|
|
d48b29025e | ||
|
|
d06ce925ac | ||
|
|
5ace087f92 | ||
|
|
a51f034036 | ||
|
|
982562874a | ||
|
|
45fe7165f3 | ||
|
|
d0f6a67be1 | ||
|
|
8461c73bc3 | ||
|
|
238a4ee1e3 | ||
|
|
253f995dc6 | ||
|
|
0972c89ee1 | ||
|
|
13a4b928ed | ||
|
|
c6b47eef6a | ||
|
|
a1afe3f1e3 | ||
|
|
a3672ba764 | ||
|
|
d01ef9d394 | ||
|
|
dad4f13f64 | ||
|
|
4f477901d9 | ||
|
|
d3ffefa897 | ||
|
|
93f786452d | ||
|
|
635fd9f8bf | ||
|
|
e4295a6ce8 | ||
|
|
e4426df6a2 | ||
|
|
65a93041aa | ||
|
|
8287a669fb | ||
|
|
48d96dbb9d | ||
|
|
bd613382bc | ||
|
|
3eda3afba4 | ||
|
|
d7ec1c16a2 | ||
|
|
d241d48f52 | ||
|
|
67954d7c4b | ||
|
|
977725868a | ||
|
|
e2acdd7df2 | ||
|
|
ae50155fbd | ||
|
|
24f9bbbccb | ||
|
|
1b4ea720a6 | ||
|
|
7d87442f73 | ||
|
|
f398ccadb7 | ||
|
|
740c79af9b | ||
|
|
d0096c6cb2 | ||
|
|
e4701c1bd8 | ||
|
|
a08ae655cf | ||
|
|
a917e16e62 | ||
|
|
8ed3304e61 | ||
|
|
c40fd051e5 | ||
|
|
09cd8ecb18 | ||
|
|
a4e1743691 | ||
|
|
801a339525 | ||
|
|
49a7cbfe99 | ||
|
|
603975bfe0 | ||
|
|
49fe7447ff | ||
|
|
7048248268 | ||
|
|
cad5ca3d68 | ||
|
|
9e9ab6fb7d | ||
|
|
8e55698271 | ||
|
|
47338b21a8 | ||
|
|
4c307e05f5 | ||
|
|
b56659b0b4 | ||
|
|
e3c3b6e89e | ||
|
|
f1a8a3c19a | ||
|
|
986b63391a | ||
|
|
9b180ad90c | ||
|
|
6079dc6aee | ||
|
|
2bd7371c7a | ||
|
|
e1eb191def | ||
|
|
a9d2de06b5 | ||
|
|
2aa875a626 | ||
|
|
e4fa429dcc | ||
|
|
5ba7bf2e18 | ||
|
|
11925a372d | ||
|
|
e1eb9e20f1 | ||
|
|
1d3aa889d5 | ||
|
|
c1ab26aef3 | ||
|
|
ea9819d161 | ||
|
|
dc9480fd71 | ||
|
|
fa2849a080 | ||
|
|
c70c7ee5b9 | ||
|
|
fe3d3df662 | ||
|
|
2f90b73683 | ||
|
|
5186e80c6f | ||
|
|
4ff1c1dc1f | ||
|
|
c1427040f6 | ||
|
|
a7ad02acb6 | ||
|
|
b188d61be1 | ||
|
|
ec85e857bc | ||
|
|
d37ccafdc2 | ||
|
|
0c9b8e6c63 | ||
|
|
8f8ad466f4 | ||
|
|
0f67be465b | ||
|
|
ed7c8ca1a1 | ||
|
|
f71e29de5c | ||
|
|
a641453388 | ||
|
|
366b95ce1f | ||
|
|
136c870d1f | ||
|
|
0c411a542f | ||
|
|
1e70dd088f | ||
|
|
2dc7f97ff0 | ||
|
|
6542d677a9 | ||
|
|
222fe26cea | ||
|
|
ed413ee029 | ||
|
|
516d685c9e | ||
|
|
54e2371022 | ||
|
|
511cc5ebd7 | ||
|
|
30bec40338 | ||
|
|
0bb9353a11 | ||
|
|
80134f5a2b | ||
|
|
57e20fe478 | ||
|
|
9317430968 | ||
|
|
f92b04e99a | ||
|
|
a1c63f8498 | ||
|
|
9460d498fc | ||
|
|
c2a6a436a5 | ||
|
|
c578e35178 | ||
|
|
90cd9a46f6 | ||
|
|
6616389a5f | ||
|
|
f5f5d358b4 | ||
|
|
5cb9432f21 | ||
|
|
fb8fb21450 | ||
|
|
370a32f1b5 | ||
|
|
68227b64a2 | ||
|
|
2a0880bfee | ||
|
|
26dbd8d312 | ||
|
|
6357a4087d | ||
|
|
f482bd077b | ||
|
|
148468eee3 | ||
|
|
79083e5664 | ||
|
|
c52d2bc0b6 | ||
|
|
54d4f2ec57 | ||
|
|
a25b5cb894 | ||
|
|
6caa8fcd84 | ||
|
|
66270eee77 | ||
|
|
6119976027 | ||
|
|
a286b5e418 | ||
|
|
882ab4001d | ||
|
|
52b6fa6fbd | ||
|
|
3bb115bd2d | ||
|
|
e08f239176 | ||
|
|
a01c55e38d | ||
|
|
af51bc257b | ||
|
|
90a8c11acb | ||
|
|
92b858884c | ||
|
|
159673652c | ||
|
|
200d13ef15 | ||
|
|
ddeef46d2e | ||
|
|
97c3998383 | ||
|
|
93aea4ee60 | ||
|
|
546dbf542e | ||
|
|
005410d40b | ||
|
|
3b384a199a | ||
|
|
b62b024a8b | ||
|
|
4fbd373e29 | ||
|
|
ae211a923a | ||
|
|
d94d730a44 | ||
|
|
18ae1c5fa5 | ||
|
|
a0afabeb04 | ||
|
|
1158ab9095 | ||
|
|
54ccb761e5 | ||
|
|
f72dbd1dec | ||
|
|
0814c3153a | ||
|
|
9f085e8b8c | ||
|
|
0188752c0a | ||
|
|
a884c41813 | ||
|
|
879b977321 | ||
|
|
e9cb253be1 | ||
|
|
07eacae385 | ||
|
|
8446874290 | ||
|
|
c347f97b95 | ||
|
|
29cfa9e24b | ||
|
|
1b1ce882a5 | ||
|
|
e9f2dbf9ea | ||
|
|
7c6ae315e1 | ||
|
|
cec0d22dc8 | ||
|
|
b2ca82e105 | ||
|
|
5ba6b1d5fc | ||
|
|
a96e77c758 | ||
|
|
79e0f0c7c1 | ||
|
|
187ca778f2 | ||
|
|
2d1aa3ba8c | ||
|
|
08bd4efefa | ||
|
|
558485f5a9 | ||
|
|
cff2ff9dbe | ||
|
|
d5d92cfbee | ||
|
|
a00f6a8cba | ||
|
|
59dee3d767 | ||
|
|
e94661b213 | ||
|
|
9dea81bdff | ||
|
|
6ff552c1ec | ||
|
|
c1b1ea1a67 | ||
|
|
167a8f4037 | ||
|
|
47776d54d9 | ||
|
|
5767c252b7 | ||
|
|
a2efcada02 | ||
|
|
e68aa0ffa6 | ||
|
|
66bcccabe4 | ||
|
|
3736189308 | ||
|
|
c408482c55 | ||
|
|
00b0b8eb84 | ||
|
|
b14294f131 | ||
|
|
db9249bd61 | ||
|
|
662e4d0b8a | ||
|
|
13be9179f5 | ||
|
|
0a55506077 | ||
|
|
8860efa82e | ||
|
|
9bc0994a8e | ||
|
|
1f50e4d82b | ||
|
|
995d1216ea | ||
|
|
196e91289c | ||
|
|
b2bb35994f | ||
|
|
6fe6a1387a | ||
|
|
aac401e7ee | ||
|
|
9655b735a1 | ||
|
|
c3bd7aeb93 | ||
|
|
0b55a80317 | ||
|
|
c6315bf384 | ||
|
|
87b965f80c | ||
|
|
b09b21ae0f | ||
|
|
7e372cd113 | ||
|
|
1e211e8912 | ||
|
|
8bc4049a0f | ||
|
|
03f8c98cb5 | ||
|
|
5c56acc677 | ||
|
|
2d8393dcf7 | ||
|
|
04a916a3e1 | ||
|
|
edc13ed14d | ||
|
|
dd737bc8c5 | ||
|
|
939f2bd94a | ||
|
|
abffa21268 | ||
|
|
705b03c0bb | ||
|
|
7bef2ccc68 | ||
|
|
bffc5d733b | ||
|
|
8ca2610550 | ||
|
|
acf184134a | ||
|
|
4a3f74f1c3 | ||
|
|
b39983a0f8 | ||
|
|
d6fa32d95d | ||
|
|
7c299f6e68 | ||
|
|
25e8ccd07e | ||
|
|
092123b075 | ||
|
|
feb2956cc1 | ||
|
|
d356839859 | ||
|
|
2ff39fd14e | ||
|
|
c3d300c807 | ||
|
|
ef43d10a70 | ||
|
|
bd73466e48 | ||
|
|
cc2c0ae34e | ||
|
|
9207f7a798 | ||
|
|
2069b7fd8e | ||
|
|
f552ef6204 | ||
|
|
2761f7521a | ||
|
|
c3939a774b | ||
|
|
49e5242bf2 | ||
|
|
3181d37b20 | ||
|
|
6d788a5e91 | ||
|
|
74c7549444 | ||
|
|
c52ccb87f1 | ||
|
|
fab25848e1 | ||
|
|
75a24c89cd | ||
|
|
15a73b7dba | ||
|
|
0adeaf9c28 | ||
|
|
fe64b2cd19 | ||
|
|
5788474d7e | ||
|
|
3559834762 | ||
|
|
f9926b4026 | ||
|
|
cb457c4b09 | ||
|
|
5ebfe9b0f4 | ||
|
|
35266dd8bf | ||
|
|
bf03d375e0 | ||
|
|
6cf909e34f | ||
|
|
343a6d03c1 | ||
|
|
fab8e7591e | ||
|
|
5a485197b7 | ||
|
|
7bc02a4208 | ||
|
|
3067e6e911 | ||
|
|
5db77e8404 | ||
|
|
5714063457 | ||
|
|
41f88ed2e0 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 8
|
||||
TabWidth: 8
|
||||
UseTab: Always
|
||||
ColumnLimit: 80
|
||||
BreakBeforeBraces: Linux
|
||||
@@ -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;
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
},
|
||||
"runArgs": [
|
||||
"--privileged",
|
||||
"--cap-add=NET_ADMIN",
|
||||
"--device=/dev/net/tun"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
.build
|
||||
.git
|
||||
.vendor
|
||||
apps/gpgui-helper/node_modules
|
||||
target
|
||||
vendor.tar.xz
|
||||
@@ -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
|
||||
@@ -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.
|
||||
@@ -0,0 +1,35 @@
|
||||
name: Checkout private source quietly
|
||||
description: Fetch private source without printing Git diagnostics or retaining credentials.
|
||||
inputs:
|
||||
token:
|
||||
required: true
|
||||
description: Token with read access to the private repository
|
||||
ref:
|
||||
required: true
|
||||
description: Branch, tag, or full commit SHA
|
||||
path:
|
||||
required: true
|
||||
description: Destination within the workspace
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- shell: bash
|
||||
env:
|
||||
PRIVATE_TOKEN: ${{ inputs.token }}
|
||||
PRIVATE_REF: ${{ inputs.ref }}
|
||||
PRIVATE_PATH: ${{ inputs.path }}
|
||||
run: |
|
||||
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Private source checkout failed; diagnostics suppressed."; fi' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
export GIT_TERMINAL_PROMPT=0
|
||||
export GIT_CONFIG_COUNT=1
|
||||
export GIT_CONFIG_KEY_0=http.https://github.com/.extraheader
|
||||
GIT_CONFIG_VALUE_0="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$PRIVATE_TOKEN" | base64 | tr -d '\n')"
|
||||
export GIT_CONFIG_VALUE_0
|
||||
git init "$PRIVATE_PATH"
|
||||
git -C "$PRIVATE_PATH" remote add origin https://github.com/yuezk/gpgui
|
||||
git -C "$PRIVATE_PATH" fetch --no-tags --depth=1 -- origin "$PRIVATE_REF"
|
||||
git -C "$PRIVATE_PATH" checkout --detach FETCH_HEAD
|
||||
) >/dev/null 2>&1
|
||||
echo "Private source checkout passed."
|
||||
@@ -0,0 +1,64 @@
|
||||
name: Prepare cached macOS native dependencies
|
||||
description: Cache only the completed public native-library prefix, without private source or app outputs.
|
||||
inputs:
|
||||
gpgui-directory:
|
||||
description: Private checkout containing the native dependency builder
|
||||
required: true
|
||||
outputs:
|
||||
prefix:
|
||||
description: Validated native dependency installation prefix
|
||||
value: ${{ steps.identity.outputs.path }}
|
||||
cache-hit:
|
||||
description: Whether the exact dependency cache was restored
|
||||
value: ${{ steps.restore.outputs.cache-hit }}
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Identify native dependency cache
|
||||
id: identity
|
||||
shell: bash
|
||||
env:
|
||||
GPGUI_DIRECTORY: ${{ inputs.gpgui-directory }}
|
||||
GPGUI_MACOS_DEPS_CACHE_DIR: ${{ runner.tool_cache }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Native dependency cache identification failed; diagnostics suppressed."; fi' EXIT
|
||||
metadata="$("$GPGUI_DIRECTORY/scripts/build-macos-native-deps.sh" --cache-info 2>/dev/null)"
|
||||
key="$(printf '%s\n' "$metadata" | sed -n 's/^key=//p')"
|
||||
prefix="$(printf '%s\n' "$metadata" | sed -n 's/^path=//p')"
|
||||
# Emit only an opaque identity and one dependency directory outside the checkout.
|
||||
if [[ "$key" =~ ^[0-9a-f]{64}$ ]] &&
|
||||
[[ "$metadata" == "key=$key"$'\n'"path=$prefix" ]] &&
|
||||
[[ "${prefix%/*}" == "$RUNNER_TOOL_CACHE/gpgui-macos-native-deps" ]] &&
|
||||
[[ "${prefix##*/}" == macos-*-"$key" ]]; then
|
||||
printf 'key=macos-native-deps-%s\npath=%s\n' "$key" "$prefix" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Restore public native libraries
|
||||
id: restore
|
||||
uses: actions/cache/restore@v5
|
||||
with:
|
||||
path: ${{ steps.identity.outputs.path }}
|
||||
key: ${{ steps.identity.outputs.key }}
|
||||
|
||||
- name: Build or validate native libraries
|
||||
shell: bash
|
||||
env:
|
||||
GPGUI_DIRECTORY: ${{ inputs.gpgui-directory }}
|
||||
GPGUI_MACOS_DEPS_CACHE_DIR: ${{ runner.tool_cache }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Native dependency preparation failed; diagnostics suppressed."; fi' EXIT
|
||||
started=$SECONDS
|
||||
"$GPGUI_DIRECTORY/scripts/build-macos-native-deps.sh" >/dev/null 2>&1
|
||||
echo "Native dependency preparation passed in $((SECONDS - started)) seconds."
|
||||
|
||||
# Save before any private application compilation or signing credential import.
|
||||
- name: Save public native libraries
|
||||
if: steps.restore.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v5
|
||||
with:
|
||||
path: ${{ steps.identity.outputs.path }}
|
||||
key: ${{ steps.identity.outputs.key }}
|
||||
@@ -0,0 +1,127 @@
|
||||
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 CI helpers
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: .ci
|
||||
persist-credentials: false
|
||||
- name: Checkout gpgui
|
||||
uses: ./.ci/.github/actions/checkout-private
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
ref: ${{ inputs.gpgui_ref }}
|
||||
path: gpgui-source/gpgui
|
||||
- name: Verify Linux desktop assets
|
||||
if: matrix.os.arch == 'amd64' && inputs.verify_desktop_assets
|
||||
run: |
|
||||
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Private operation failed; diagnostics suppressed."; fi' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
gpgui-source/gp/scripts/verify-linux-desktop-assets.sh gpgui-source/gpgui
|
||||
) >/dev/null 2>&1
|
||||
echo "Private operation passed."
|
||||
|
||||
- name: Tarball
|
||||
run: |
|
||||
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Private operation failed; diagnostics suppressed."; fi' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
cd gpgui-source
|
||||
tar -czf gpgui.tar.gz gpgui gp
|
||||
) >/dev/null 2>&1
|
||||
echo "Private operation passed."
|
||||
|
||||
- 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: |
|
||||
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Private operation failed; diagnostics suppressed."; fi' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
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"
|
||||
) >/dev/null 2>&1
|
||||
echo "Private operation passed."
|
||||
|
||||
- name: Install gpgui in Docker
|
||||
env:
|
||||
GPGUI_BUILDER: ${{ inputs.builder }}
|
||||
run: |
|
||||
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Private operation failed; diagnostics suppressed."; fi' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
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"
|
||||
) >/dev/null 2>&1
|
||||
echo "Private operation passed."
|
||||
|
||||
- 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
|
||||
@@ -0,0 +1,109 @@
|
||||
name: Build Linux Native Shell
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
gp_ref:
|
||||
required: true
|
||||
type: string
|
||||
gpgui_ref:
|
||||
required: true
|
||||
type: string
|
||||
channel:
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
GH_PAT:
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- runner: ubuntu-24.04
|
||||
arch: x86_64
|
||||
- runner: ubuntu-24.04-arm
|
||||
arch: aarch64
|
||||
runs-on: ${{ matrix.runner }}
|
||||
name: build (${{ matrix.arch }})
|
||||
timeout-minutes: 90
|
||||
env:
|
||||
CARGO_INCREMENTAL: '0'
|
||||
CARGO_BUILD_JOBS: '2'
|
||||
GPGUI_BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
|
||||
GPGUI_GIT_COMMIT: ${{ inputs.gpgui_ref }}
|
||||
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
|
||||
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ inputs.gp_ref }}
|
||||
path: source/gp
|
||||
submodules: recursive
|
||||
persist-credentials: false
|
||||
- name: Checkout CI helpers
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: .ci
|
||||
persist-credentials: false
|
||||
- name: Checkout gpgui
|
||||
uses: ./.ci/.github/actions/checkout-private
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
ref: ${{ inputs.gpgui_ref }}
|
||||
path: source/gpgui
|
||||
- name: Install Ubuntu 24.04 dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y autoconf automake gettext libtool pkg-config \
|
||||
clang libclang-dev libgtk-4-dev libxml2-dev \
|
||||
libgnutls28-dev liblz4-dev libwayland-dev libxkbcommon-dev libdbus-1-dev
|
||||
pkg-config --exists gtk4 gnutls dbus-1 wayland-client xkbcommon
|
||||
- name: Install the NSH compiler
|
||||
run: rustup toolchain install 1.97.0 --profile minimal
|
||||
- name: Cache public crate downloads
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry/cache
|
||||
~/.cargo/registry/index
|
||||
key: nsh-crates-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('source/gpgui/apps/desktop-nsh/Cargo.lock') }}
|
||||
restore-keys: nsh-crates-${{ runner.os }}-${{ runner.arch }}-
|
||||
- name: Build and package Native Shell
|
||||
run: |
|
||||
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::Native Shell build failed; diagnostics suppressed."; fi' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
cd source/gpgui
|
||||
cargo +1.97.0 build --manifest-path apps/desktop-nsh/Cargo.toml --locked \
|
||||
--release --bin gpgui-nsh --target-dir target
|
||||
target/release/gpgui-nsh --version
|
||||
version="$(cargo +1.97.0 metadata --manifest-path apps/desktop-nsh/Cargo.toml --no-deps --format-version 1 \
|
||||
| jq -r '.packages[] | select(.name == "gpgui-nsh") | .version')"
|
||||
directory="gpgui-nsh_$version"
|
||||
archive="gpgui-nsh_$(uname -m).bin.tar.xz"
|
||||
mkdir -p ".build/package/$directory"
|
||||
cp target/release/gpgui-nsh ".build/package/$directory/"
|
||||
cp apps/desktop-nsh/ICU4X-LICENSE.txt ".build/package/$directory/ICU4X-LICENSE.txt"
|
||||
if ldd target/release/gpgui-nsh | grep -q 'libicu'; then
|
||||
echo "The release executable must not depend on ICU4C." >&2
|
||||
exit 1
|
||||
fi
|
||||
tar -cJf ".build/package/$archive" -C .build/package "$directory"
|
||||
sha256sum ".build/package/$archive" | cut -d ' ' -f 1 > ".build/package/$archive.sha256"
|
||||
) >/dev/null 2>&1
|
||||
echo "Native Shell build and version check passed."
|
||||
- name: Upload Native Shell
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: artifact-gpgui-nsh-${{ matrix.arch }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
source/gpgui/.build/package/*.bin.tar.xz
|
||||
source/gpgui/.build/package/*.bin.tar.xz.sha256
|
||||
@@ -1,273 +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
|
||||
|
||||
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
|
||||
@@ -0,0 +1,67 @@
|
||||
name: Check macOS native dependency cache
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
gpgui_ref:
|
||||
description: Full gpgui commit SHA
|
||||
required: true
|
||||
type: string
|
||||
workflow_call:
|
||||
inputs:
|
||||
gpgui_ref:
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
GH_PAT:
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ${{ vars.MACOS_RUNNER || 'macos-15' }}
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Require immutable source ref
|
||||
env:
|
||||
GPGUI_REF: ${{ inputs.gpgui_ref }}
|
||||
run: test "${#GPGUI_REF}" -eq 40 && [[ "$GPGUI_REF" != *[!0-9a-f]* ]]
|
||||
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
path: .ci
|
||||
persist-credentials: false
|
||||
|
||||
- name: Checkout gpgui quietly
|
||||
uses: ./.ci/.github/actions/checkout-private
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
ref: ${{ inputs.gpgui_ref }}
|
||||
path: source/gpgui
|
||||
|
||||
- name: Select release toolchain and install native build tools
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer
|
||||
run: |
|
||||
test "$(uname -m)" = arm64
|
||||
xcodebuild -version
|
||||
echo "DEVELOPER_DIR=$DEVELOPER_DIR" >> "$GITHUB_ENV"
|
||||
brew install autoconf automake gettext libtool meson ninja pkgconf
|
||||
|
||||
- name: Prepare cached native dependencies
|
||||
id: native
|
||||
uses: ./.ci/.github/actions/macos-native-deps
|
||||
with:
|
||||
gpgui-directory: source/gpgui
|
||||
|
||||
- name: Record cache result
|
||||
env:
|
||||
CACHE_HIT: ${{ steps.native.outputs.cache-hit }}
|
||||
run: |
|
||||
if [[ "$CACHE_HIT" == true ]]; then
|
||||
echo "Validated an exact native dependency cache hit." >> "$GITHUB_STEP_SUMMARY"
|
||||
else
|
||||
echo "Built and validated native dependencies after a cache miss." >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
@@ -0,0 +1,139 @@
|
||||
name: Check NSH
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
gp_ref:
|
||||
description: 'Full GlobalProtect-openconnect commit SHA'
|
||||
required: true
|
||||
type: string
|
||||
gpgui_ref:
|
||||
description: 'Full gpgui commit SHA'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
workflow_call:
|
||||
inputs:
|
||||
gp_ref:
|
||||
required: true
|
||||
type: string
|
||||
gpgui_ref:
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
GH_PAT:
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: NSH (${{ matrix.platform }})
|
||||
runs-on: ${{ matrix.runner }}
|
||||
timeout-minutes: 90
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux
|
||||
runner: ubuntu-24.04
|
||||
- platform: macos
|
||||
runner: ${{ vars.MACOS_RUNNER || 'macos-15' }}
|
||||
env:
|
||||
CARGO_INCREMENTAL: '0'
|
||||
CARGO_BUILD_JOBS: '2'
|
||||
steps:
|
||||
- name: Require immutable source refs
|
||||
env:
|
||||
GP_REF: ${{ inputs.gp_ref }}
|
||||
GPGUI_REF: ${{ inputs.gpgui_ref }}
|
||||
run: |
|
||||
[[ "$GP_REF" =~ ^[0-9a-f]{40}$ && "$GPGUI_REF" =~ ^[0-9a-f]{40}$ ]] || {
|
||||
echo "Both source refs must be full commit SHAs."
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ inputs.gp_ref }}
|
||||
path: source/gp
|
||||
submodules: recursive
|
||||
persist-credentials: false
|
||||
- name: Checkout CI helpers
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: .ci
|
||||
persist-credentials: false
|
||||
- name: Checkout gpgui
|
||||
uses: ./.ci/.github/actions/checkout-private
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
ref: ${{ inputs.gpgui_ref }}
|
||||
path: source/gpgui
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: matrix.platform == 'linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y autoconf automake gettext libtool pkg-config \
|
||||
clang libclang-dev libgtk-4-dev libxml2-dev \
|
||||
libgnutls28-dev liblz4-dev libwayland-dev libxkbcommon-dev libdbus-1-dev
|
||||
pkg-config --exists gtk4 gnutls dbus-1 wayland-client xkbcommon
|
||||
- name: Install macOS dependencies
|
||||
if: matrix.platform == 'macos'
|
||||
env:
|
||||
DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer
|
||||
run: |
|
||||
xcodebuild -version
|
||||
echo "DEVELOPER_DIR=$DEVELOPER_DIR" >> "$GITHUB_ENV"
|
||||
brew install autoconf automake gettext libtool pkgconf gnutls libxml2 lz4
|
||||
echo "$(brew --prefix gettext)/bin" >> "$GITHUB_PATH"
|
||||
echo "ACLOCAL_PATH=$(brew --prefix gettext)/share/aclocal" >> "$GITHUB_ENV"
|
||||
echo "PKG_CONFIG_PATH=$(brew --prefix libxml2)/lib/pkgconfig:$(brew --prefix gnutls)/lib/pkgconfig" >> "$GITHUB_ENV"
|
||||
- name: Install the NSH compiler
|
||||
run: rustup toolchain install 1.97.0 --profile minimal
|
||||
- name: Cache public crate downloads
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
# Private source and build outputs stay out of the public cache.
|
||||
path: |
|
||||
~/.cargo/registry/cache
|
||||
~/.cargo/registry/index
|
||||
key: nsh-crates-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('source/gpgui/apps/desktop-nsh/Cargo.lock') }}
|
||||
restore-keys: nsh-crates-${{ runner.os }}-${{ runner.arch }}-
|
||||
|
||||
- name: Check demo-free NSH production
|
||||
timeout-minutes: 30
|
||||
run: |
|
||||
diagnostics="$(mktemp)"
|
||||
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::NSH production check failed; diagnostics suppressed."; python3 .ci/scripts/private-ci-diagnostics.py compile "$diagnostics" || true; fi; rm -f "$diagnostics"' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
cd source/gpgui
|
||||
cargo +1.97.0 check --manifest-path apps/desktop-nsh/Cargo.toml --locked --bin gpgui-nsh
|
||||
) >"$diagnostics" 2>&1
|
||||
echo "NSH production check passed."
|
||||
- name: Compile NSH tests
|
||||
timeout-minutes: 30
|
||||
run: |
|
||||
diagnostics="$(mktemp)"
|
||||
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::NSH test compilation failed; diagnostics suppressed."; python3 .ci/scripts/private-ci-diagnostics.py compile "$diagnostics" || true; fi; rm -f "$diagnostics"' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
cd source/gpgui
|
||||
cargo +1.97.0 test --manifest-path apps/desktop-nsh/Cargo.toml --locked --features demo --no-run
|
||||
) >"$diagnostics" 2>&1
|
||||
echo "NSH test compilation passed."
|
||||
- name: Run NSH tests
|
||||
timeout-minutes: 10
|
||||
run: |
|
||||
diagnostics="$(mktemp)"
|
||||
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::NSH tests failed; diagnostics suppressed."; python3 .ci/scripts/private-ci-diagnostics.py tests "$diagnostics" || true; fi; rm -f "$diagnostics"' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
cd source/gpgui
|
||||
cargo +1.97.0 test --manifest-path apps/desktop-nsh/Cargo.toml --locked --features demo -- --test-threads=1
|
||||
) >"$diagnostics" 2>&1
|
||||
echo "NSH tests passed."
|
||||
@@ -0,0 +1,34 @@
|
||||
name: Desktop icon compatibility
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/desktop-icons.yaml'
|
||||
- 'scripts/tests/test_desktop_icon.py'
|
||||
- 'packaging/files/usr/share/icons/**'
|
||||
- 'apps/gpgui-helper/src-tauri/icons/**'
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- '.github/workflows/desktop-icons.yaml'
|
||||
- 'scripts/tests/test_desktop_icon.py'
|
||||
- 'packaging/files/usr/share/icons/**'
|
||||
- 'apps/gpgui-helper/src-tauri/icons/**'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
render:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-22.04, ubuntu-24.04]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Install the distro SVG loader
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-gi gir1.2-gdkpixbuf-2.0 librsvg2-common
|
||||
- name: Render desktop icons
|
||||
run: /usr/bin/python3 -m unittest discover -s scripts/tests -p test_desktop_icon.py
|
||||
@@ -0,0 +1,128 @@
|
||||
name: Nix
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "Cargo.toml"
|
||||
- "scripts/validate-release-version.py"
|
||||
- "flake.nix"
|
||||
- "flake.lock"
|
||||
- "nix/**"
|
||||
- ".github/workflows/nix.yaml"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "Cargo.toml"
|
||||
- "scripts/validate-release-version.py"
|
||||
- "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: Check installed release versions
|
||||
run: python3 scripts/validate-release-version.py --package result
|
||||
|
||||
- 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: Check installed release versions
|
||||
run: python3 scripts/validate-release-version.py --package result
|
||||
|
||||
- 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
|
||||
@@ -1,31 +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
|
||||
@@ -0,0 +1,185 @@
|
||||
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 \
|
||||
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
|
||||
@@ -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"
|
||||
@@ -0,0 +1,143 @@
|
||||
name: Publish macOS assets
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
build_run_id:
|
||||
description: 'Public gp Build run ID with a successful build-macos job'
|
||||
required: true
|
||||
type: string
|
||||
release_tag:
|
||||
description: 'Existing public release tag (vX.Y.Z or snapshot)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
expected_gui:
|
||||
description: 'Expected macOS shell in the selected build artifact'
|
||||
required: true
|
||||
default: nsh
|
||||
type: choice
|
||||
options: [tauri, nsh]
|
||||
|
||||
concurrency:
|
||||
group: publish-macos-assets
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
actions: read
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
environment: macos-release
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Check completed build and public release
|
||||
id: build
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
BUILD_REPOSITORY: yuezk/GlobalProtect-openconnect
|
||||
BUILD_RUN_ID: ${{ inputs.build_run_id }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
[[ "$BUILD_RUN_ID" =~ ^[0-9]+$ ]]
|
||||
[[ "$RELEASE_TAG" == snapshot || "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
|
||||
run="$(gh api "repos/$BUILD_REPOSITORY/actions/runs/$BUILD_RUN_ID")"
|
||||
jq -e '(.event == "workflow_dispatch" or .event == "push") and
|
||||
.path == ".github/workflows/build.yaml"' <<<"$run" >/dev/null
|
||||
attempt="$(jq -r '.run_attempt' <<<"$run")"
|
||||
artifact_name="$(bash scripts/select-macos-artifact.sh "$BUILD_REPOSITORY" "$BUILD_RUN_ID" "$attempt")"
|
||||
{
|
||||
echo "artifact=$artifact_name"
|
||||
echo "workflow_commit=$(jq -r '.head_sha' <<<"$run")"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
gh release view "$RELEASE_TAG" \
|
||||
--repo yuezk/GlobalProtect-openconnect --json isDraft,isPrerelease \
|
||||
--jq 'select(.isDraft == false and .isPrerelease == false)' | jq -e .
|
||||
|
||||
- name: Download completed build artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
github-token: ${{ github.token }}
|
||||
run-id: ${{ inputs.build_run_id }}
|
||||
name: ${{ steps.build.outputs.artifact }}
|
||||
path: release-assets
|
||||
|
||||
- name: Validate build identity and checksums
|
||||
id: metadata
|
||||
env:
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
WORKFLOW_COMMIT: ${{ steps.build.outputs.workflow_commit }}
|
||||
ARTIFACT_NAME: ${{ steps.build.outputs.artifact }}
|
||||
EXPECTED_GUI: ${{ inputs.expected_gui }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
metadata="$(python3 scripts/validate-macos-release.py release-assets \
|
||||
--release-tag "$RELEASE_TAG" --workflow-commit "$WORKFLOW_COMMIT" --gui "$EXPECTED_GUI")"
|
||||
[[ "$ARTIFACT_NAME" == "macos-release-$(jq -r '.request_id' <<<"$metadata")" ]]
|
||||
{
|
||||
echo "gp_ref=$(jq -r '.gp_ref' <<<"$metadata")"
|
||||
echo "gpgui_ref=$(jq -r '.gpgui_ref' <<<"$metadata")"
|
||||
echo "channel=$(jq -r '.channel' <<<"$metadata")"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Checkout public upload helper
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ steps.metadata.outputs.gp_ref }}
|
||||
path: gp-release
|
||||
|
||||
- name: Check stable tags
|
||||
if: ${{ steps.metadata.outputs.channel == 'stable' }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
GP_REF: ${{ steps.metadata.outputs.gp_ref }}
|
||||
GPGUI_REF: ${{ steps.metadata.outputs.gpgui_ref }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git -C gp-release fetch --no-tags origin "refs/tags/$RELEASE_TAG"
|
||||
if [[ "$(git -C gp-release rev-parse 'FETCH_HEAD^{commit}')" != "$GP_REF" ]]; then
|
||||
echo "gp source commit does not match $RELEASE_TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! tagged_gui_commit="$(gh api "repos/yuezk/gpgui/commits/$RELEASE_TAG" --jq .sha 2>/dev/null)"; then
|
||||
echo "Private source tag verification failed; diagnostics suppressed." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$tagged_gui_commit" != "$GPGUI_REF" ]]; then
|
||||
echo "gpgui source commit does not match $RELEASE_TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Publish and verify macOS assets
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_REPOSITORY: yuezk/GlobalProtect-openconnect
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
CHANNEL: ${{ steps.metadata.outputs.channel }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
files=(release-assets/*.dmg release-assets/*.zip release-assets/*.sha256)
|
||||
args=()
|
||||
if [[ "$CHANNEL" == snapshot ]]; then
|
||||
args+=(--clobber)
|
||||
fi
|
||||
gp-release/scripts/upload-release-assets.sh "${args[@]}" "$RELEASE_TAG" "${files[@]}"
|
||||
gh release download "$RELEASE_TAG" --repo yuezk/GlobalProtect-openconnect \
|
||||
--pattern 'GPConnect_*_arm64.*' --dir published-assets
|
||||
python3 - <<'PY'
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
metadata = json.loads(Path("release-assets/release-build.json").read_text())
|
||||
for name, digest in metadata["assets"].items():
|
||||
if hashlib.sha256((Path("published-assets") / name).read_bytes()).hexdigest() != digest:
|
||||
raise SystemExit(f"Published asset checksum mismatch: {name}")
|
||||
PY
|
||||
echo "Published verified macOS assets to $RELEASE_TAG" >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -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
|
||||
@@ -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}"
|
||||
@@ -0,0 +1,642 @@
|
||||
name: Publish update feeds
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
GH_PAT:
|
||||
required: true
|
||||
CLOUDFLARE_ACCOUNT_ID:
|
||||
required: false
|
||||
CLOUDFLARE_API_TOKEN:
|
||||
required: false
|
||||
SPARKLE_PRIVATE_KEY:
|
||||
required: false
|
||||
inputs:
|
||||
gpgui_ref:
|
||||
required: true
|
||||
type: string
|
||||
channel:
|
||||
required: true
|
||||
type: string
|
||||
release_tag:
|
||||
required: true
|
||||
type: string
|
||||
archive_name:
|
||||
required: false
|
||||
type: string
|
||||
gp_ref:
|
||||
required: true
|
||||
type: string
|
||||
expected_gui:
|
||||
required: false
|
||||
default: nsh
|
||||
type: string
|
||||
highlights:
|
||||
required: false
|
||||
type: string
|
||||
unix_platforms:
|
||||
required: false
|
||||
default: linux,freebsd,openbsd
|
||||
type: string
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
gpgui_ref:
|
||||
description: gpgui ref containing the update feed Worker
|
||||
required: true
|
||||
default: main
|
||||
type: string
|
||||
channel:
|
||||
description: Update channel
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- stable
|
||||
- snapshot
|
||||
release_tag:
|
||||
description: Release containing the macOS update archive
|
||||
required: true
|
||||
type: string
|
||||
archive_name:
|
||||
description: Exact ZIP asset name; leave empty when the release has one macOS update archive
|
||||
required: false
|
||||
type: string
|
||||
gp_ref:
|
||||
description: GlobalProtect-openconnect ref containing release helpers
|
||||
required: true
|
||||
default: main
|
||||
type: string
|
||||
expected_gui:
|
||||
description: Expected macOS shell in the selected update archive
|
||||
required: true
|
||||
default: nsh
|
||||
type: choice
|
||||
options: [tauri, nsh]
|
||||
highlights:
|
||||
description: Stable release highlights, one per line
|
||||
required: false
|
||||
type: string
|
||||
unix_platforms:
|
||||
description: Comma-separated Unix platforms with published assets (linux,freebsd,openbsd)
|
||||
required: true
|
||||
default: linux,freebsd,openbsd
|
||||
type: string
|
||||
|
||||
concurrency:
|
||||
group: update-feeds
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ${{ vars.MACOS_RUNNER || 'macos-15' }}
|
||||
environment: macos-release
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
REPOSITORY: yuezk/GlobalProtect-openconnect
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
CHANNEL: ${{ inputs.channel }}
|
||||
REQUESTED_ARCHIVE: ${{ inputs.archive_name }}
|
||||
FEED_URL: ${{ vars.SPARKLE_FEED_URL }}
|
||||
EXPECTED_TEAM_ID: ${{ vars.MACOS_TEAM_ID }}
|
||||
EXPECTED_GUI: ${{ inputs.expected_gui }}
|
||||
UPDATES_WORKER_NAME: ${{ vars.UPDATES_WORKER_NAME || 'gp-updates' }}
|
||||
SPARKLE_VERSION: 2.9.2
|
||||
UPDATE_HIGHLIGHTS: ${{ inputs.highlights }}
|
||||
UNIX_PLATFORMS: ${{ inputs.unix_platforms }}
|
||||
SPARKLE_ARCHIVE_SHA256: b83e37436774556ed055e0244b297ef2c790e0737393bf65bf495fcbba6eed65
|
||||
steps:
|
||||
- name: Validate inputs
|
||||
env:
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "$CHANNEL" != "stable" && "$CHANNEL" != "snapshot" ]]; then
|
||||
echo "channel must be stable or snapshot" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$EXPECTED_GUI" != "tauri" && "$EXPECTED_GUI" != "nsh" ]]; then
|
||||
echo "expected_gui must be tauri or nsh" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! "$UNIX_PLATFORMS" =~ ^(linux|freebsd|openbsd)(,(linux|freebsd|openbsd))*$ ]]; then
|
||||
echo "unix_platforms must list published Unix targets separated by commas" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$CHANNEL" == "snapshot" && "$RELEASE_TAG" != "snapshot" ]]; then
|
||||
echo "The snapshot channel must publish to the snapshot release" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$CHANNEL" == "stable" && "$RELEASE_TAG" == "snapshot" ]]; then
|
||||
echo "The stable channel cannot publish to the snapshot release" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$CHANNEL" == "stable" && -z "${UPDATE_HIGHLIGHTS//[$'\t\r\n ']/}" ]]; then
|
||||
echo "Stable updates require at least one release highlight" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "$SPARKLE_PRIVATE_KEY" ]]; then
|
||||
echo "SPARKLE_PRIVATE_KEY is not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "$EXPECTED_TEAM_ID" ]]; then
|
||||
echo "MACOS_TEAM_ID is not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
for variable in CLOUDFLARE_ACCOUNT_ID CLOUDFLARE_API_TOKEN; do
|
||||
if [[ -z "${!variable:-}" ]]; then
|
||||
echo "$variable is not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
if [[ "$FEED_URL" != https://*/appcast.xml ]]; then
|
||||
echo "SPARKLE_FEED_URL must be an HTTPS URL ending in /appcast.xml" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Checkout release infrastructure
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Checkout public release helpers
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ inputs.gp_ref }}
|
||||
path: gp-release
|
||||
|
||||
- name: Checkout update feed Worker
|
||||
uses: ./.github/actions/checkout-private
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
ref: ${{ inputs.gpgui_ref }}
|
||||
path: gpgui
|
||||
|
||||
- uses: pnpm/action-setup@v5
|
||||
with:
|
||||
version: 9.15.1
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Install Worker tooling
|
||||
run: |
|
||||
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Private operation failed; diagnostics suppressed."; fi' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
pnpm --dir gpgui/apps/update-feed-worker install --frozen-lockfile --ignore-scripts
|
||||
) >/dev/null 2>&1
|
||||
echo "Private operation passed."
|
||||
|
||||
|
||||
- name: Prepare Sparkle tools
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
archive="$RUNNER_TEMP/Sparkle.zip"
|
||||
curl --fail --location --silent --show-error \
|
||||
"https://github.com/sparkle-project/Sparkle/releases/download/$SPARKLE_VERSION/Sparkle-for-Swift-Package-Manager.zip" \
|
||||
--output "$archive"
|
||||
echo "$SPARKLE_ARCHIVE_SHA256 $archive" | shasum -a 256 --check
|
||||
ditto -x -k "$archive" "$RUNNER_TEMP/sparkle"
|
||||
test -x "$RUNNER_TEMP/sparkle/bin/generate_appcast"
|
||||
|
||||
- name: Validate GitHub release
|
||||
id: release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
release="$(gh release view "$RELEASE_TAG" --repo "$REPOSITORY" \
|
||||
--json tagName,isDraft,isPrerelease,publishedAt)"
|
||||
if [[ "$(jq -r '.tagName' <<<"$release")" != "$RELEASE_TAG" ]] || \
|
||||
[[ "$(jq -r '.isDraft' <<<"$release")" != "false" ]]; then
|
||||
echo "Release must be published with the requested tag" >&2
|
||||
exit 1
|
||||
fi
|
||||
is_prerelease="$(jq -r '.isPrerelease' <<<"$release")"
|
||||
if [[ "$is_prerelease" != "false" ]]; then
|
||||
echo "Updates require a non-prerelease GitHub release" >&2
|
||||
exit 1
|
||||
fi
|
||||
published_at="$(jq -r '.publishedAt' <<<"$release")"
|
||||
if [[ ! "$published_at" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}T ]]; then
|
||||
echo "Release has no valid publication date" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "released_at=${published_at%%T*}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Download update archive
|
||||
id: archive
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
mkdir -p "$RUNNER_TEMP/updates"
|
||||
archive_name="$REQUESTED_ARCHIVE"
|
||||
if [[ -z "$archive_name" ]]; then
|
||||
archive_name="$(gh release view "$RELEASE_TAG" --repo "$REPOSITORY" --json assets \
|
||||
--jq '[.assets[] | select(.name | test("^GPConnect_[0-9A-Za-z._-]+_arm64\\.zip$"))] | sort_by(.createdAt) | last | .name // ""')"
|
||||
if [[ -z "$archive_name" ]]; then
|
||||
echo "No macOS update archive found on $RELEASE_TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! "$archive_name" =~ ^GPConnect_[0-9A-Za-z._-]+_arm64\.zip$ ]]; then
|
||||
echo "Invalid macOS update archive name: $archive_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gh release download "$RELEASE_TAG" --repo "$REPOSITORY" \
|
||||
--pattern "$archive_name" \
|
||||
--pattern "$archive_name.sha256" \
|
||||
--dir "$RUNNER_TEMP/updates"
|
||||
{
|
||||
echo "name=$archive_name"
|
||||
echo "path=$RUNNER_TEMP/updates/$archive_name"
|
||||
echo "checksum_path=$RUNNER_TEMP/updates/$archive_name.sha256"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Verify update archive
|
||||
id: bundle
|
||||
env:
|
||||
ARCHIVE_PATH: ${{ steps.archive.outputs.path }}
|
||||
CHECKSUM_PATH: ${{ steps.archive.outputs.checksum_path }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
expected_digest="$(awk 'NR == 1 { print $1 }' "$CHECKSUM_PATH")"
|
||||
actual_digest="$(shasum -a 256 "$ARCHIVE_PATH" | awk '{ print $1 }')"
|
||||
if [[ -z "$expected_digest" || "$actual_digest" != "$expected_digest" ]]; then
|
||||
echo "Update archive checksum does not match its release checksum" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extract_dir="$RUNNER_TEMP/extracted"
|
||||
ditto -x -k "$ARCHIVE_PATH" "$extract_dir"
|
||||
app="$extract_dir/GP Connect.app"
|
||||
test -d "$app"
|
||||
codesign --verify --deep --strict --verbose=2 "$app"
|
||||
|
||||
signing_info="$(codesign -d --verbose=4 "$app" 2>&1)"
|
||||
xcrun stapler validate "$app"
|
||||
grep -q '^Authority=Developer ID Application:' <<<"$signing_info"
|
||||
grep -q '^CodeDirectory .*flags=.*runtime' <<<"$signing_info"
|
||||
team_identifier="$(sed -n 's/^TeamIdentifier=//p' <<<"$signing_info")"
|
||||
if [[ "$team_identifier" != "$EXPECTED_TEAM_ID" ]]; then
|
||||
echo "Unexpected Apple Team Identifier: $team_identifier" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
identifier="$(sed -n 's/^Identifier=//p' <<<"$signing_info")"
|
||||
if [[ "$identifier" != "com.yuezk.gpgui" ]]; then
|
||||
echo "Unexpected bundle identifier: $identifier" >&2
|
||||
exit 1
|
||||
fi
|
||||
file "$app/Contents/MacOS/gpgui" | grep -q 'arm64'
|
||||
|
||||
desktop_shell="$(plutil -extract GPDesktopShell raw "$app/Contents/Info.plist")"
|
||||
if [[ "$desktop_shell" != "$EXPECTED_GUI" ]]; then
|
||||
echo "Update archive desktop shell does not match the selected GUI" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
feed_url="$(plutil -extract SUFeedURL raw "$app/Contents/Info.plist")"
|
||||
if [[ "$feed_url" != "$FEED_URL" ]]; then
|
||||
echo "Unexpected Sparkle feed URL: $feed_url" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
update_channel="$(plutil -extract GPUpdateChannel raw "$app/Contents/Info.plist")"
|
||||
if [[ "$update_channel" != "$CHANNEL" ]]; then
|
||||
echo "Unexpected update channel: $update_channel" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bundle_version="$(plutil -extract CFBundleVersion raw "$app/Contents/Info.plist")"
|
||||
short_version="$(plutil -extract CFBundleShortVersionString raw "$app/Contents/Info.plist")"
|
||||
if [[ ! "$bundle_version" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]]; then
|
||||
echo "Invalid bundle version: $bundle_version" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$CHANNEL" == "stable" ]]; then
|
||||
expected_tag="v$short_version"
|
||||
expected_archive="GPConnect_${short_version}_arm64.zip"
|
||||
else
|
||||
expected_tag="snapshot"
|
||||
expected_archive="GPConnect_${short_version}-snapshot.${bundle_version}_arm64.zip"
|
||||
fi
|
||||
if [[ "$RELEASE_TAG" != "$expected_tag" ]]; then
|
||||
echo "Release tag $RELEASE_TAG does not match $expected_tag" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${{ steps.archive.outputs.name }}" != "$expected_archive" ]]; then
|
||||
echo "Archive name does not match packaged version: $expected_archive" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "version=$bundle_version" >> "$GITHUB_OUTPUT"
|
||||
echo "short_version=$short_version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Prepare Unix update manifest
|
||||
env:
|
||||
RELEASED_AT: ${{ steps.release.outputs.released_at }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
manifest="$RUNNER_TEMP/updates/latest.json"
|
||||
current_manifest="$RUNNER_TEMP/current-latest.json"
|
||||
latest_url="${FEED_URL%/appcast.xml}/latest.json"
|
||||
status="$(curl --location --silent --show-error \
|
||||
--output "$current_manifest" --write-out '%{http_code}' "$latest_url")"
|
||||
generate_args=(
|
||||
--repository "$REPOSITORY"
|
||||
--channel "$CHANNEL"
|
||||
--version "${{ steps.bundle.outputs.short_version }}"
|
||||
)
|
||||
IFS=',' read -r -a platforms <<<"$UNIX_PLATFORMS"
|
||||
for platform in "${platforms[@]}"; do
|
||||
generate_args+=(--platform "$platform")
|
||||
done
|
||||
case "$status" in
|
||||
200)
|
||||
python3 scripts/validate-update-manifest.py validate "$current_manifest" \
|
||||
--repository "$REPOSITORY"
|
||||
generate_args+=(--input "$current_manifest")
|
||||
;;
|
||||
404)
|
||||
;;
|
||||
*)
|
||||
echo "Could not check the current Unix update manifest: HTTP $status" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
highlights="$RUNNER_TEMP/update-highlights.txt"
|
||||
if [[ "$CHANNEL" == "stable" ]]; then
|
||||
printf '%s\n' "$UPDATE_HIGHLIGHTS" > "$highlights"
|
||||
released_at="$RELEASED_AT"
|
||||
else
|
||||
printf 'Development snapshot after %s.\n' \
|
||||
"${{ steps.bundle.outputs.short_version }}" > "$highlights"
|
||||
generate_args+=(--build "${{ steps.bundle.outputs.version }}")
|
||||
released_at="$(date -u +%F)"
|
||||
fi
|
||||
|
||||
python3 scripts/validate-update-manifest.py generate \
|
||||
"${generate_args[@]}" \
|
||||
--released-at "$released_at" \
|
||||
--highlights-file "$highlights" \
|
||||
--output "$manifest"
|
||||
|
||||
- name: Fetch current appcast
|
||||
id: current-appcast
|
||||
env:
|
||||
ARCHIVE_NAME: ${{ steps.archive.outputs.name }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
appcast="$RUNNER_TEMP/updates/appcast.xml"
|
||||
archive_url="https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/$ARCHIVE_NAME"
|
||||
status="$(curl --location --silent --show-error \
|
||||
--output "$appcast" --write-out '%{http_code}' "$FEED_URL")"
|
||||
case "$status" in
|
||||
200)
|
||||
test -s "$appcast"
|
||||
decision="$(python3 scripts/validate-macos-appcast.py status "$appcast" \
|
||||
--repository "$REPOSITORY" \
|
||||
--build-version "${{ steps.bundle.outputs.version }}")"
|
||||
if [[ "$decision" == "older" ]]; then
|
||||
echo "Candidate build is older than the published appcast" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$decision" == "same" ]]; then
|
||||
python3 scripts/validate-macos-appcast.py validate "$appcast" \
|
||||
--repository "$REPOSITORY" \
|
||||
--build-version "${{ steps.bundle.outputs.version }}" \
|
||||
--short-version "${{ steps.bundle.outputs.short_version }}" \
|
||||
--channel "$CHANNEL" \
|
||||
--archive-url "$archive_url"
|
||||
fi
|
||||
echo "decision=$decision" >> "$GITHUB_OUTPUT"
|
||||
;;
|
||||
404)
|
||||
rm -f "$appcast"
|
||||
echo "decision=newer" >> "$GITHUB_OUTPUT"
|
||||
;;
|
||||
*)
|
||||
echo "Could not fetch the current appcast: HTTP $status" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Generate appcast
|
||||
if: ${{ steps.current-appcast.outputs.decision == 'newer' }}
|
||||
env:
|
||||
ARCHIVE_NAME: ${{ steps.archive.outputs.name }}
|
||||
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
embedded_public_key="$(plutil -extract SUPublicEDKey raw \
|
||||
"$RUNNER_TEMP/extracted/GP Connect.app/Contents/Info.plist")"
|
||||
derived_public_key="$(swift -e '
|
||||
import Foundation
|
||||
import CryptoKit
|
||||
let encoded = ProcessInfo.processInfo.environment["SPARKLE_PRIVATE_KEY"]!
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let privateKey = try Curve25519.Signing.PrivateKey(
|
||||
rawRepresentation: Data(base64Encoded: encoded)!)
|
||||
print(privateKey.publicKey.rawRepresentation.base64EncodedString())
|
||||
')"
|
||||
if [[ "$derived_public_key" != "$embedded_public_key" ]]; then
|
||||
echo "Sparkle private key does not match the public key embedded in the application" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
download_prefix="https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/"
|
||||
generate_args=(
|
||||
--download-url-prefix "$download_prefix"
|
||||
--full-release-notes-url "https://github.com/$REPOSITORY/releases/tag/$RELEASE_TAG"
|
||||
--maximum-deltas 0
|
||||
--maximum-versions 1
|
||||
--versions "${{ steps.bundle.outputs.version }}"
|
||||
--ed-key-file -
|
||||
)
|
||||
if [[ "$CHANNEL" == "snapshot" ]]; then
|
||||
generate_args+=(--channel snapshot)
|
||||
fi
|
||||
printf '%s' "$SPARKLE_PRIVATE_KEY" | \
|
||||
"$RUNNER_TEMP/sparkle/bin/generate_appcast" \
|
||||
"${generate_args[@]}" "$RUNNER_TEMP/updates"
|
||||
|
||||
appcast="$RUNNER_TEMP/updates/appcast.xml"
|
||||
test -s "$appcast"
|
||||
python3 scripts/validate-macos-appcast.py validate "$appcast" \
|
||||
--repository "$REPOSITORY" \
|
||||
--build-version "${{ steps.bundle.outputs.version }}" \
|
||||
--short-version "${{ steps.bundle.outputs.short_version }}" \
|
||||
--channel "$CHANNEL" \
|
||||
--archive-url "$download_prefix$ARCHIVE_NAME"
|
||||
|
||||
- name: Publish appcast
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
appcast="$RUNNER_TEMP/updates/appcast.xml"
|
||||
archive_url="https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/${{ steps.archive.outputs.name }}"
|
||||
if [[ "$CHANNEL" == "stable" ]] && \
|
||||
gh release view "$RELEASE_TAG" --repo "$REPOSITORY" --json assets \
|
||||
--jq '.assets[].name' | grep -Fx appcast.xml >/dev/null; then
|
||||
existing="$RUNNER_TEMP/existing-release-appcast.xml"
|
||||
gh release download "$RELEASE_TAG" --repo "$REPOSITORY" \
|
||||
--pattern appcast.xml --output "$existing"
|
||||
python3 scripts/validate-macos-appcast.py validate "$existing" \
|
||||
--repository "$REPOSITORY" \
|
||||
--build-version "${{ steps.bundle.outputs.version }}" \
|
||||
--short-version "${{ steps.bundle.outputs.short_version }}" \
|
||||
--channel "$CHANNEL" \
|
||||
--archive-url "$archive_url"
|
||||
cp "$existing" "$appcast"
|
||||
else
|
||||
if [[ "$CHANNEL" == "snapshot" ]]; then
|
||||
RELEASE_REPOSITORY="$REPOSITORY" \
|
||||
gp-release/scripts/upload-release-assets.sh \
|
||||
--clobber "$RELEASE_TAG" "$appcast"
|
||||
else
|
||||
RELEASE_REPOSITORY="$REPOSITORY" \
|
||||
gp-release/scripts/upload-release-assets.sh "$RELEASE_TAG" "$appcast"
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Validate final appcast
|
||||
env:
|
||||
ARCHIVE_NAME: ${{ steps.archive.outputs.name }}
|
||||
run: |
|
||||
python3 scripts/validate-macos-appcast.py validate \
|
||||
"$RUNNER_TEMP/updates/appcast.xml" \
|
||||
--repository "$REPOSITORY" \
|
||||
--build-version "${{ steps.bundle.outputs.version }}" \
|
||||
--short-version "${{ steps.bundle.outputs.short_version }}" \
|
||||
--channel "$CHANNEL" \
|
||||
--archive-url "https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/$ARCHIVE_NAME"
|
||||
|
||||
- name: Deploy update feed worker
|
||||
env:
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
run: |
|
||||
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Private operation failed; diagnostics suppressed."; fi' EXIT
|
||||
(
|
||||
set -euo pipefail
|
||||
|
||||
cp "$RUNNER_TEMP/updates/appcast.xml" gpgui/apps/update-feed-worker/public/appcast.xml
|
||||
if [[ -f "$RUNNER_TEMP/updates/latest.json" ]]; then
|
||||
cp "$RUNNER_TEMP/updates/latest.json" gpgui/apps/update-feed-worker/public/latest.json
|
||||
fi
|
||||
pnpm --dir gpgui/apps/update-feed-worker exec wrangler deploy \
|
||||
--config wrangler.jsonc \
|
||||
--name "$UPDATES_WORKER_NAME"
|
||||
) >/dev/null 2>&1
|
||||
echo "Private operation passed."
|
||||
|
||||
- name: Verify published appcast
|
||||
env:
|
||||
ARCHIVE_NAME: ${{ steps.archive.outputs.name }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
published_appcast="$RUNNER_TEMP/published-appcast.xml"
|
||||
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
||||
if curl --fail --location --silent --show-error \
|
||||
--output "$published_appcast" "$FEED_URL" && \
|
||||
python3 scripts/validate-macos-appcast.py validate "$published_appcast" \
|
||||
--repository "$REPOSITORY" \
|
||||
--build-version "${{ steps.bundle.outputs.version }}" \
|
||||
--short-version "${{ steps.bundle.outputs.short_version }}" \
|
||||
--channel "$CHANNEL" \
|
||||
--archive-url "https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/$ARCHIVE_NAME"; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 3
|
||||
done
|
||||
echo "Published appcast did not become available at $FEED_URL" >&2
|
||||
exit 1
|
||||
|
||||
- name: Verify published Unix update manifest
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
latest_url="${FEED_URL%/appcast.xml}/latest.json"
|
||||
published_manifest="$RUNNER_TEMP/published-latest.json"
|
||||
expected=(
|
||||
--channel "$CHANNEL"
|
||||
--version "${{ steps.bundle.outputs.short_version }}"
|
||||
)
|
||||
if [[ "$CHANNEL" == "snapshot" ]]; then
|
||||
expected+=(--build "${{ steps.bundle.outputs.version }}")
|
||||
fi
|
||||
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
||||
if curl --fail --location --silent --show-error \
|
||||
--output "$published_manifest" "$latest_url" && \
|
||||
python3 scripts/validate-update-manifest.py validate "$published_manifest" \
|
||||
--repository "$REPOSITORY" "${expected[@]}"; then
|
||||
if ! cmp --silent "$RUNNER_TEMP/updates/latest.json" "$published_manifest"; then
|
||||
sleep 3
|
||||
continue
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
sleep 3
|
||||
done
|
||||
echo "Published Unix update manifest did not become available at $latest_url" >&2
|
||||
exit 1
|
||||
|
||||
- name: Prune expired snapshot assets
|
||||
if: ${{ inputs.channel == 'snapshot' }}
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
assets="$RUNNER_TEMP/snapshot-assets.json"
|
||||
delete_list="$RUNNER_TEMP/delete-snapshot-assets.txt"
|
||||
gh release view snapshot --repo "$REPOSITORY" --json assets > "$assets"
|
||||
ASSETS="$assets" python3 - <<'PY' > "$delete_list"
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
|
||||
with open(os.environ["ASSETS"], encoding="utf-8") as file:
|
||||
assets = json.load(file)["assets"]
|
||||
|
||||
archive_pattern = re.compile(
|
||||
r"^(GPConnect_.+-snapshot\.(\d+(?:\.\d+){1,2}))_arm64\.zip$"
|
||||
)
|
||||
asset_pattern = re.compile(
|
||||
r"^(GPConnect_.+-snapshot\.\d+(?:\.\d+){1,2})_arm64\.(?:zip|dmg)(?:\.sha256)?$"
|
||||
)
|
||||
builds = []
|
||||
for asset in assets:
|
||||
match = archive_pattern.match(asset["name"])
|
||||
if match:
|
||||
builds.append((tuple(map(int, match.group(2).split("."))), match.group(1)))
|
||||
keep = {stem for _, stem in sorted(builds, reverse=True)[:2]}
|
||||
for asset in assets:
|
||||
match = asset_pattern.match(asset["name"])
|
||||
if match and not any(asset["name"].startswith(stem + "_arm64.") for stem in keep):
|
||||
print(asset["name"])
|
||||
PY
|
||||
|
||||
while IFS= read -r asset; do
|
||||
if [[ -n "$asset" ]] && ! gh release delete-asset snapshot "$asset" \
|
||||
--repo "$REPOSITORY" --yes; then
|
||||
echo "::warning::Could not remove expired snapshot asset: $asset" >&2
|
||||
fi
|
||||
done < "$delete_list"
|
||||
@@ -0,0 +1,77 @@
|
||||
name: Release infrastructure checks
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- '.github/actions/**'
|
||||
- 'scripts/record-build-sources.py'
|
||||
- 'scripts/validate-release-version.py'
|
||||
- 'scripts/publish-flake-test-branch.sh'
|
||||
- 'scripts/prepare-release-promotion.sh'
|
||||
- 'scripts/tests/test_release_flow.py'
|
||||
- 'scripts/select-macos-artifact.sh'
|
||||
- 'scripts/test-private-desktop.sh'
|
||||
- 'scripts/tests/test_private_ci.py'
|
||||
- 'scripts/wait-for-publication.py'
|
||||
- 'scripts/select-publication-targets.py'
|
||||
- 'scripts/verify-docker-publication.sh'
|
||||
- 'scripts/tests/test_*publication.py'
|
||||
- 'scripts/validate-macos-release.py'
|
||||
- 'scripts/validate-macos-appcast.py'
|
||||
- 'scripts/validate-update-manifest.py'
|
||||
- 'scripts/tests/test_validate_*.py'
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- '.github/actions/**'
|
||||
- 'scripts/record-build-sources.py'
|
||||
- 'scripts/validate-release-version.py'
|
||||
- 'scripts/publish-flake-test-branch.sh'
|
||||
- 'scripts/prepare-release-promotion.sh'
|
||||
- 'scripts/tests/test_release_flow.py'
|
||||
- 'scripts/select-macos-artifact.sh'
|
||||
- 'scripts/test-private-desktop.sh'
|
||||
- 'scripts/tests/test_private_ci.py'
|
||||
- 'scripts/wait-for-publication.py'
|
||||
- 'scripts/select-publication-targets.py'
|
||||
- 'scripts/verify-docker-publication.sh'
|
||||
- 'scripts/tests/test_*publication.py'
|
||||
- 'scripts/validate-macos-release.py'
|
||||
- 'scripts/validate-macos-appcast.py'
|
||||
- 'scripts/validate-update-manifest.py'
|
||||
- 'scripts/tests/test_validate_*.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'
|
||||
- name: Test macOS publication and update feed validation
|
||||
run: python3 -m unittest discover -s scripts/tests -p 'test_validate_*.py'
|
||||
- name: Check private CI and macOS artifact selection
|
||||
run: |
|
||||
bash -n scripts/select-macos-artifact.sh
|
||||
shellcheck scripts/select-macos-artifact.sh scripts/test-private-desktop.sh
|
||||
bash -n scripts/test-private-desktop.sh
|
||||
python3 -m unittest discover -s scripts/tests -p 'test_private_ci.py'
|
||||
- name: Test release promotion and source selection
|
||||
run: |
|
||||
bash -n scripts/prepare-release-promotion.sh scripts/publish-flake-test-branch.sh
|
||||
shellcheck scripts/prepare-release-promotion.sh scripts/publish-flake-test-branch.sh
|
||||
python3 -m unittest discover -s scripts/tests -p 'test_release_flow.py'
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Release version consistency
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
release-version:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# The default PR checkout is the candidate merged with the current base.
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Check main release version
|
||||
env:
|
||||
BASE_REF: ${{ github.event.pull_request.base.sha || github.event.before }}
|
||||
run: python3 scripts/validate-release-version.py --base-ref "$BASE_REF"
|
||||
@@ -0,0 +1,355 @@
|
||||
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 }}
|
||||
docker_matrix: ${{ steps.set-matrix.outputs.docker_matrix }}
|
||||
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 docker = [
|
||||
{ runner: 'ubuntu-latest', platform: 'linux/amd64' },
|
||||
{ runner: 'ubuntu-24.04-arm', platform: 'linux/arm64' },
|
||||
].filter(item => osMap[arch].includes(item.runner))
|
||||
core.setOutput('docker_matrix', JSON.stringify({ include: docker }))
|
||||
|
||||
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
|
||||
- setup-matrix
|
||||
if: ${{ inputs.release-docker }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.setup-matrix.outputs.docker_matrix) }}
|
||||
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: |
|
||||
# Reject an incomplete or unexpected selection before writing any tag.
|
||||
shopt -s nullglob
|
||||
digest_files=(*)
|
||||
expected_count=1
|
||||
if [[ "${{ inputs.arch }}" == all ]]; then
|
||||
expected_count=2
|
||||
fi
|
||||
[[ ${#digest_files[@]} -eq $expected_count ]]
|
||||
for digest in "${digest_files[@]}"; do
|
||||
[[ "$digest" =~ ^[0-9a-f]{64}$ ]]
|
||||
done
|
||||
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
|
||||
uses: ./.github/workflows/update-flake-hashes.yaml
|
||||
with:
|
||||
version: ${{ needs.gh-release.outputs.stable_version }}
|
||||
release_tag: ${{ inputs.tag }}
|
||||
@@ -0,0 +1,190 @@
|
||||
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
|
||||
|
||||
jobs:
|
||||
update-flake-hashes:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.release.outputs.version }}
|
||||
release_tag: ${{ steps.release.outputs.release_tag }}
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
|
||||
- name: Resolve candidate release
|
||||
id: release
|
||||
env:
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
run: |
|
||||
python3 - <<'PYRELEASE'
|
||||
import json, os, re, runpy, subprocess
|
||||
from pathlib import Path
|
||||
helpers = runpy.run_path('scripts/validate-release-version.py')
|
||||
version = os.environ['RELEASE_VERSION'].removeprefix('v') or helpers['cargo_version'](Path('.'))
|
||||
tag = os.environ['RELEASE_TAG'] or f'v{version}'
|
||||
if not re.fullmatch(r'(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)', version) or tag not in (f'v{version}', 'snapshot'):
|
||||
raise SystemExit('Expected a stable version and its matching release tag, or snapshot')
|
||||
source_slug = re.sub(r'[^A-Za-z0-9._-]', '', re.sub(r'[/\s]+', '-', os.environ['GITHUB_REF_NAME'])).strip('-')
|
||||
test_branch = f'chore/flake-{source_slug}'
|
||||
expected_head = ''
|
||||
if tag == 'snapshot':
|
||||
remote = subprocess.check_output(['git', 'ls-remote', '--heads', 'origin', f'refs/heads/{test_branch}'], text=True)
|
||||
expected_head = remote.split()[0] if remote.strip() else ''
|
||||
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
|
||||
output.write(f'version={version}\nrelease_tag={tag}\n')
|
||||
Path('release-candidate.json').write_text(json.dumps({
|
||||
'version': version, 'releaseTag': tag, 'sourceSha': os.environ['GITHUB_SHA'],
|
||||
'workflowRunId': os.environ['GITHUB_RUN_ID'],
|
||||
'testBranch': test_branch, 'expectedTestHead': expected_head,
|
||||
}, indent=2) + '\n')
|
||||
PYRELEASE
|
||||
|
||||
- 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: ${{ steps.release.outputs.version }}
|
||||
RELEASE_TAG: ${{ steps.release.outputs.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
|
||||
release-candidate.json
|
||||
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
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
|
||||
- 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: Validate installed release versions
|
||||
run: |
|
||||
python3 scripts/validate-release-version.py \
|
||||
--version '${{ needs.update-flake-hashes.outputs.version }}' \
|
||||
--release-tag '${{ needs.update-flake-hashes.outputs.release_tag }}' --package result
|
||||
|
||||
- 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
|
||||
|
||||
publish-test-branch:
|
||||
if: needs.update-flake-hashes.outputs.release_tag == 'snapshot'
|
||||
needs: [update-flake-hashes, validate-nix-prebuilt]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
|
||||
- name: Download updated flake
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: updated-flake
|
||||
path: .
|
||||
|
||||
- name: Publish branch for snapshot testing
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: scripts/publish-flake-test-branch.sh
|
||||
@@ -1,70 +1,21 @@
|
||||
# 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
|
||||
# Nix files
|
||||
result
|
||||
|
||||
# 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*
|
||||
# Packages & test assets
|
||||
*.ipa
|
||||
@@ -1,7 +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 "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
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"rust-lang.rust-analyzer",
|
||||
"tamasfe.even-better-toml",
|
||||
"eamodio.gitlens",
|
||||
"EditorConfig.EditorConfig",
|
||||
"streetsidesoftware.code-spell-checker",
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
},
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10.0)
|
||||
|
||||
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")
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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,14 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.1.0)
|
||||
|
||||
project(QtSignals LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
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)
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -1,37 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10.0)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
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
|
||||
)
|
||||
|
||||
add_subdirectory(3rdparty/qt-unix-signals)
|
||||
add_subdirectory(3rdparty/inih)
|
||||
add_subdirectory(GPService)
|
||||
add_subdirectory(GPClient)
|
||||
add_dependencies(gpclient gpservice)
|
||||
@@ -0,0 +1,82 @@
|
||||
[workspace]
|
||||
resolver = "3"
|
||||
|
||||
members = [
|
||||
"crates/*",
|
||||
"apps/gpclient",
|
||||
"apps/gpservice",
|
||||
"apps/gpauth",
|
||||
"apps/gpgui-helper/src-tauri",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
rust-version = "1.91"
|
||||
version = "3.3.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 = ["rustls-no-provider", "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"
|
||||
tokio-tungstenite = "0.30"
|
||||
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.47"
|
||||
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 and apply fixed-size windows before first configure.
|
||||
tao = { git = "https://github.com/yuezk/tao", rev = "bba0f1c4e86d697b173c75280d1651f408b8023c" }
|
||||
# Use one macro source for Tao and Wry so Cargo can vendor the workspace.
|
||||
tao-macros = { git = "https://github.com/yuezk/tao", rev = "bba0f1c4e86d697b173c75280d1651f408b8023c" }
|
||||
|
||||
[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*
|
||||
@@ -1,104 +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
|
||||
normalloginwindow.cpp
|
||||
portalauthenticator.cpp
|
||||
portalconfigresponse.cpp
|
||||
preloginresponse.cpp
|
||||
samlloginwindow.cpp
|
||||
gpclient.cpp
|
||||
settingsdialog.cpp
|
||||
gpclient.ui
|
||||
normalloginwindow.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}
|
||||
)
|
||||
|
||||
target_link_libraries(gpclient
|
||||
${SingleApplication_LIBRARY}
|
||||
Qt5::Widgets
|
||||
Qt5::Network
|
||||
Qt5::WebSockets
|
||||
Qt5::WebEngine
|
||||
Qt5::WebEngineWidgets
|
||||
Qt5::DBus
|
||||
QtSignals
|
||||
)
|
||||
|
||||
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)
|
||||
@@ -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(¶ms)
|
||||
{
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -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
|
||||
@@ -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()) {
|
||||
PLOGE << "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 ¶ms)
|
||||
{
|
||||
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()
|
||||
{
|
||||
PLOGI << "WebSocket disconnected";
|
||||
}
|
||||
|
||||
void CDPCommandManager::onSocketError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
PLOGE << "WebSocket error" << error;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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 |
|
Before Width: | Height: | Size: 18 KiB |
@@ -1,36 +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);
|
||||
}
|
||||
|
||||
EnhancedWebView::~EnhancedWebView()
|
||||
{
|
||||
delete cdp;
|
||||
}
|
||||
|
||||
void EnhancedWebView::initialize()
|
||||
{
|
||||
QString 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);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +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);
|
||||
~EnhancedWebView();
|
||||
|
||||
void initialize();
|
||||
|
||||
signals:
|
||||
void responseReceived(QJsonObject params);
|
||||
|
||||
private slots:
|
||||
void onCDPReady();
|
||||
void onEventReceived(QString eventName, QJsonObject params);
|
||||
|
||||
private:
|
||||
CDPCommandManager *cdp;
|
||||
};
|
||||
|
||||
#endif // ENHANCEDWEBVIEW_H
|
||||
@@ -1,235 +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();
|
||||
}
|
||||
}
|
||||
|
||||
GatewayAuthenticator::~GatewayAuthenticator()
|
||||
{
|
||||
delete normalLoginWindow;
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::authenticate()
|
||||
{
|
||||
PLOGI << "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)
|
||||
{
|
||||
PLOGI << "Trying to login the gateway at " << loginUrl << " with " << loginParams.toUtf8();
|
||||
|
||||
QNetworkReply *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")) {
|
||||
PLOGE << QString("Failed to login the gateway at %1, %2").arg(loginUrl, reply->errorString());
|
||||
|
||||
if (normalLoginWindow) {
|
||||
normalLoginWindow->setProcessing(false);
|
||||
openMessageBox("Gateway login failed.", "Please check your credentials and try again.");
|
||||
} else {
|
||||
doAuth();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 2FA
|
||||
if (response.contains("Challenge")) {
|
||||
PLOGI << "The server need input the challenge...";
|
||||
showChallenge(response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (normalLoginWindow) {
|
||||
normalLoginWindow->close();
|
||||
}
|
||||
|
||||
const QUrlQuery params = gpclient::helper::parseGatewayResponse(response);
|
||||
emit success(params.toString());
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::doAuth()
|
||||
{
|
||||
PLOGI << "Perform the gateway prelogin at " << preloginUrl;
|
||||
|
||||
QNetworkReply *reply = createRequest(preloginUrl);
|
||||
connect(reply, &QNetworkReply::finished, this, &GatewayAuthenticator::onPreloginFinished);
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::onPreloginFinished()
|
||||
{
|
||||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||
|
||||
if (reply->error()) {
|
||||
PLOGE << QString("Failed to prelogin the gateway at %1, %2").arg(preloginUrl, reply->errorString());
|
||||
|
||||
emit fail("Error occurred on the gateway prelogin interface.");
|
||||
return;
|
||||
}
|
||||
|
||||
PLOGI << "Gateway prelogin succeeded.";
|
||||
|
||||
PreloginResponse 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 {
|
||||
PLOGE << 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)
|
||||
{
|
||||
PLOGI << QString("Trying to perform the normal login with %1 / %2 credentials").arg(labelUsername, labelPassword);
|
||||
|
||||
normalLoginWindow = new NormalLoginWindow;
|
||||
normalLoginWindow->setPortalAddress(gateway);
|
||||
normalLoginWindow->setAuthMessage(authMessage);
|
||||
normalLoginWindow->setUsernameLabel(labelUsername);
|
||||
normalLoginWindow->setPasswordLabel(labelPassword);
|
||||
|
||||
// Do login
|
||||
connect(normalLoginWindow, &NormalLoginWindow::performLogin, this, &GatewayAuthenticator::onPerformNormalLogin);
|
||||
connect(normalLoginWindow, &NormalLoginWindow::rejected, this, &GatewayAuthenticator::onLoginWindowRejected);
|
||||
connect(normalLoginWindow, &NormalLoginWindow::finished, this, &GatewayAuthenticator::onLoginWindowFinished);
|
||||
|
||||
normalLoginWindow->show();
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::onPerformNormalLogin(const QString &username, const QString &password)
|
||||
{
|
||||
PLOGI << "Start to perform normal login...";
|
||||
|
||||
normalLoginWindow->setProcessing(true);
|
||||
params.setUsername(username);
|
||||
params.setPassword(password);
|
||||
|
||||
authenticate();
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::onLoginWindowRejected()
|
||||
{
|
||||
emit fail();
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::onLoginWindowFinished()
|
||||
{
|
||||
delete normalLoginWindow;
|
||||
normalLoginWindow = nullptr;
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::samlAuth(QString samlMethod, QString samlRequest, QString preloginUrl)
|
||||
{
|
||||
PLOGI << "Trying to perform SAML login with saml-method " << samlMethod;
|
||||
|
||||
SAMLLoginWindow *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 &error) {
|
||||
this->onSAMLLoginFail(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")) {
|
||||
PLOGI << "SAML login succeeded, got the prelogin-cookie " << samlResult.value("preloginCookie");
|
||||
} else {
|
||||
PLOGI << "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 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());
|
||||
PLOGI << "Challenge submitted, try to re-authenticate...";
|
||||
authenticate();
|
||||
});
|
||||
|
||||
connect(challengeDialog, &ChallengeDialog::rejected, this, [this] {
|
||||
if (normalLoginWindow) {
|
||||
normalLoginWindow->close();
|
||||
}
|
||||
emit fail();
|
||||
});
|
||||
|
||||
connect(challengeDialog, &ChallengeDialog::finished, this, [this] {
|
||||
delete challengeDialog;
|
||||
challengeDialog = nullptr;
|
||||
});
|
||||
|
||||
challengeDialog->show();
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
#ifndef GATEWAYAUTHENTICATOR_H
|
||||
#define GATEWAYAUTHENTICATOR_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include "normalloginwindow.h"
|
||||
#include "challengedialog.h"
|
||||
#include "loginparams.h"
|
||||
#include "gatewayauthenticatorparams.h"
|
||||
|
||||
class GatewayAuthenticator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GatewayAuthenticator(const QString& gateway, GatewayAuthenticatorParams params);
|
||||
~GatewayAuthenticator();
|
||||
|
||||
void authenticate();
|
||||
|
||||
signals:
|
||||
void success(const QString& authCookie);
|
||||
void fail(const QString& msg = "");
|
||||
|
||||
private slots:
|
||||
void onLoginFinished();
|
||||
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 msg);
|
||||
|
||||
private:
|
||||
QString gateway;
|
||||
GatewayAuthenticatorParams params;
|
||||
QString preloginUrl;
|
||||
QString loginUrl;
|
||||
|
||||
NormalLoginWindow *normalLoginWindow{ 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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -1,516 +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();
|
||||
}
|
||||
|
||||
GPClient::~GPClient()
|
||||
{
|
||||
delete ui;
|
||||
delete vpn;
|
||||
delete settingsDialog;
|
||||
delete settingsButton;
|
||||
}
|
||||
|
||||
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->show();
|
||||
}
|
||||
|
||||
void GPClient::onSettingsAccepted()
|
||||
{
|
||||
settings::save("clientos", settingsDialog->clientos());
|
||||
}
|
||||
|
||||
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 Settings", this, &GPClient::clearSettings);
|
||||
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()
|
||||
{
|
||||
PLOGI << "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 GPGateway 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()
|
||||
{
|
||||
PLOGI << "Start connecting...";
|
||||
|
||||
const QString btnText = ui->connectButton->text();
|
||||
const QString 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()) {
|
||||
PLOGI << "Start gateway login using the previously saved gateway...";
|
||||
isQuickConnect = true;
|
||||
gatewayLogin();
|
||||
} else {
|
||||
// Perform the portal login
|
||||
PLOGI << "Start portal login...";
|
||||
portalLogin();
|
||||
}
|
||||
} else {
|
||||
PLOGI << "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()
|
||||
{
|
||||
PortalAuthenticator *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)
|
||||
{
|
||||
PLOGI << "Portal authentication succeeded.";
|
||||
|
||||
// No gateway found in protal configuration
|
||||
if (portalConfig.allGateways().size() == 0) {
|
||||
PLOGI << "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)
|
||||
{
|
||||
PLOGI << "Portal prelogin failed: " << msg;
|
||||
tryGatewayLogin();
|
||||
}
|
||||
|
||||
void GPClient::onPortalConfigFail(const QString msg)
|
||||
{
|
||||
PLOGI << "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()
|
||||
{
|
||||
PLOGI << "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()
|
||||
{
|
||||
PLOGI << "Performing gateway login...";
|
||||
|
||||
GatewayAuthenticatorParams params = GatewayAuthenticatorParams::fromPortalConfigResponse(portalConfig);
|
||||
params.setClientos(settings::get("clientos", "Linux").toString());
|
||||
|
||||
GatewayAuthenticator *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)
|
||||
{
|
||||
PLOGI << "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;
|
||||
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
|
||||
{
|
||||
const QString gatewaysJson = settings::get(portal() + "_gateways").toString();
|
||||
return GPGateway::fromJson(gatewaysJson);
|
||||
}
|
||||
|
||||
void GPClient::setAllGateways(QList<GPGateway> gateways)
|
||||
{
|
||||
PLOGI << "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)
|
||||
{
|
||||
PLOGI << "Updating the current gateway to " << gateway.name();
|
||||
|
||||
settings::save(portal() + "_selectedGateway", gateway.name());
|
||||
populateGatewayMenu();
|
||||
}
|
||||
|
||||
void GPClient::clearSettings()
|
||||
{
|
||||
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)
|
||||
{
|
||||
PLOGI << log;
|
||||
}
|
||||
@@ -1,108 +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);
|
||||
~GPClient();
|
||||
|
||||
void activate();
|
||||
void quit();
|
||||
|
||||
QString portal() const;
|
||||
void portal(QString);
|
||||
|
||||
GPGateway currentGateway() const;
|
||||
void setCurrentGateway(const GPGateway gateway);
|
||||
|
||||
void doConnect();
|
||||
|
||||
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;
|
||||
|
||||
GatewayAuthenticator *gatewayAuthenticator;
|
||||
|
||||
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);
|
||||
|
||||
void clearSettings();
|
||||
};
|
||||
#endif // GPCLIENT_H
|
||||
@@ -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><html><head/><body><p align="center"><a href="https://bit.ly/3g5DHqy"><span style=" text-decoration: underline; color:#4c6b8a;">Report a bug</span></a> / <a href="https://bit.ly/3jQYfEi"><span style=" text-decoration: underline; color:#4c6b8a;">Buy me a coffee</span></a></p></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -1,130 +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 "gphelper.h"
|
||||
|
||||
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)
|
||||
{
|
||||
PLOGI << gateways.size() << " gateway(s) avaiable, filter the gateways with rule: " << ruleName;
|
||||
|
||||
GPGateway gateway = gateways.first();
|
||||
|
||||
for (GPGateway g : gateways) {
|
||||
if (g.priorityOf(ruleName) > gateway.priorityOf(ruleName)) {
|
||||
PLOGI << "Find a preferred gateway: " << g.name();
|
||||
gateway = g;
|
||||
}
|
||||
}
|
||||
|
||||
return gateway;
|
||||
}
|
||||
|
||||
QUrlQuery gpclient::helper::parseGatewayResponse(const QByteArray &xml)
|
||||
{
|
||||
PLOGI << "Start parsing the gateway response...";
|
||||
PLOGI << "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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +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());
|
||||
void save(const QString &key, const QVariant &value);
|
||||
void clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GPHELPER_H
|
||||
@@ -1,80 +0,0 @@
|
||||
#include <QtCore/QUrlQuery>
|
||||
|
||||
#include "loginparams.h"
|
||||
|
||||
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");
|
||||
params.addQueryItem("os-version", QUrl::toPercentEncoding(QSysInfo::prettyProductName()));
|
||||
|
||||
// add the clientos parameter if not empty
|
||||
if (!clientos.isEmpty()) {
|
||||
params.addQueryItem("clientos", clientos);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
@@ -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
|
||||
@@ -1,87 +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);
|
||||
|
||||
PLOGI << "GlobalProtect started, version: " << VERSION;
|
||||
|
||||
QString port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT));
|
||||
QString 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."},
|
||||
});
|
||||
parser.process(app);
|
||||
|
||||
const QStringList positional = parser.positionalArguments();
|
||||
|
||||
IVpn *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);
|
||||
parser.isSet("start-minimized") ? w.showMinimized() : w.show();
|
||||
|
||||
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("now")) {
|
||||
w.doConnect();
|
||||
}
|
||||
if (parser.isSet("json")) {
|
||||
QObject::connect(static_cast<VpnJson*>(vpn), &VpnJson::connected, &w, &GPClient::quit);
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#include <QtGui/QCloseEvent>
|
||||
|
||||
#include "normalloginwindow.h"
|
||||
#include "ui_normalloginwindow.h"
|
||||
|
||||
NormalLoginWindow::NormalLoginWindow(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NormalLoginWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle("GlobalProtect Login");
|
||||
setFixedSize(width(), height());
|
||||
setModal(true);
|
||||
}
|
||||
|
||||
NormalLoginWindow::~NormalLoginWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void NormalLoginWindow::setAuthMessage(QString message)
|
||||
{
|
||||
ui->authMessage->setText(message);
|
||||
}
|
||||
|
||||
void NormalLoginWindow::setUsernameLabel(QString label)
|
||||
{
|
||||
ui->username->setPlaceholderText(label);
|
||||
}
|
||||
|
||||
void NormalLoginWindow::setPasswordLabel(QString label)
|
||||
{
|
||||
ui->password->setPlaceholderText(label);
|
||||
}
|
||||
|
||||
void NormalLoginWindow::setPortalAddress(QString portal)
|
||||
{
|
||||
ui->portalAddress->setText(portal);
|
||||
}
|
||||
|
||||
void NormalLoginWindow::setProcessing(bool isProcessing)
|
||||
{
|
||||
ui->username->setReadOnly(isProcessing);
|
||||
ui->password->setReadOnly(isProcessing);
|
||||
ui->loginButton->setDisabled(isProcessing);
|
||||
}
|
||||
|
||||
void NormalLoginWindow::on_loginButton_clicked()
|
||||
{
|
||||
const QString username = ui->username->text().trimmed();
|
||||
const QString password = ui->password->text().trimmed();
|
||||
|
||||
if (username.isEmpty() || password.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit performLogin(username, password);
|
||||
}
|
||||
|
||||
void NormalLoginWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
event->accept();
|
||||
reject();
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
#ifndef PORTALAUTHWINDOW_H
|
||||
#define PORTALAUTHWINDOW_H
|
||||
|
||||
#include <QtWidgets/QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class NormalLoginWindow;
|
||||
}
|
||||
|
||||
class NormalLoginWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NormalLoginWindow(QWidget *parent = nullptr);
|
||||
~NormalLoginWindow();
|
||||
|
||||
void setAuthMessage(QString);
|
||||
void setUsernameLabel(QString);
|
||||
void setPasswordLabel(QString);
|
||||
void setPortalAddress(QString);
|
||||
|
||||
void setProcessing(bool isProcessing);
|
||||
|
||||
private slots:
|
||||
void on_loginButton_clicked();
|
||||
|
||||
signals:
|
||||
void performLogin(QString username, QString password);
|
||||
|
||||
private:
|
||||
Ui::NormalLoginWindow *ui;
|
||||
|
||||
void closeEvent(QCloseEvent *event);
|
||||
};
|
||||
|
||||
#endif // PORTALAUTHWINDOW_H
|
||||
@@ -1,148 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NormalLoginWindow</class>
|
||||
<widget class="QDialog" name="NormalLoginWindow">
|
||||
<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>
|
||||
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 16 KiB |
@@ -1,207 +0,0 @@
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <plog/Log.h>
|
||||
|
||||
#include "portalauthenticator.h"
|
||||
#include "gphelper.h"
|
||||
#include "normalloginwindow.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 normalLoginWindow;
|
||||
}
|
||||
|
||||
void PortalAuthenticator::authenticate()
|
||||
{
|
||||
PLOGI << "Preform portal prelogin at " << preloginUrl;
|
||||
|
||||
QNetworkReply *reply = createRequest(preloginUrl);
|
||||
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onPreloginFinished);
|
||||
}
|
||||
|
||||
void PortalAuthenticator::onPreloginFinished()
|
||||
{
|
||||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||
|
||||
if (reply->error()) {
|
||||
PLOGE << QString("Error occurred while accessing %1, %2").arg(preloginUrl, reply->errorString());
|
||||
emit preloginFailed("Error occurred on the portal prelogin interface.");
|
||||
delete reply;
|
||||
return;
|
||||
}
|
||||
|
||||
PLOGI << "Portal prelogin succeeded.";
|
||||
|
||||
preloginResponse = PreloginResponse::parse(reply->readAll());
|
||||
|
||||
PLOGI << "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 {
|
||||
PLOGE << 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()) {
|
||||
PLOGI << "Trying auto login using the saved credentials";
|
||||
isAutoLogin = true;
|
||||
fetchConfig(settings::get("username").toString(), settings::get("password").toString());
|
||||
} else {
|
||||
normalAuth();
|
||||
}
|
||||
}
|
||||
|
||||
void PortalAuthenticator::normalAuth()
|
||||
{
|
||||
PLOGI << "Trying to launch the normal login window...";
|
||||
|
||||
normalLoginWindow = new NormalLoginWindow;
|
||||
normalLoginWindow->setPortalAddress(portal);
|
||||
normalLoginWindow->setAuthMessage(preloginResponse.authMessage());
|
||||
normalLoginWindow->setUsernameLabel(preloginResponse.labelUsername());
|
||||
normalLoginWindow->setPasswordLabel(preloginResponse.labelPassword());
|
||||
|
||||
// Do login
|
||||
connect(normalLoginWindow, &NormalLoginWindow::performLogin, this, &PortalAuthenticator::onPerformNormalLogin);
|
||||
connect(normalLoginWindow, &NormalLoginWindow::rejected, this, &PortalAuthenticator::onLoginWindowRejected);
|
||||
connect(normalLoginWindow, &NormalLoginWindow::finished, this, &PortalAuthenticator::onLoginWindowFinished);
|
||||
|
||||
normalLoginWindow->show();
|
||||
}
|
||||
|
||||
void PortalAuthenticator::onPerformNormalLogin(const QString &username, const QString &password)
|
||||
{
|
||||
normalLoginWindow->setProcessing(true);
|
||||
fetchConfig(username, password);
|
||||
}
|
||||
|
||||
void PortalAuthenticator::onLoginWindowRejected()
|
||||
{
|
||||
emitFail();
|
||||
}
|
||||
|
||||
void PortalAuthenticator::onLoginWindowFinished()
|
||||
{
|
||||
delete normalLoginWindow;
|
||||
normalLoginWindow = nullptr;
|
||||
}
|
||||
|
||||
void PortalAuthenticator::samlAuth()
|
||||
{
|
||||
PLOGI << "Trying to perform SAML login with saml-method " << preloginResponse.samlMethod();
|
||||
|
||||
SAMLLoginWindow *loginWindow = new SAMLLoginWindow;
|
||||
|
||||
connect(loginWindow, &SAMLLoginWindow::success, this, &PortalAuthenticator::onSAMLLoginSuccess);
|
||||
connect(loginWindow, &SAMLLoginWindow::fail, this, &PortalAuthenticator::onSAMLLoginFail);
|
||||
connect(loginWindow, &SAMLLoginWindow::rejected, this, &PortalAuthenticator::onLoginWindowRejected);
|
||||
|
||||
loginWindow->login(preloginResponse.samlMethod(), preloginResponse.samlRequest(), preloginUrl);
|
||||
}
|
||||
|
||||
void PortalAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> samlResult)
|
||||
{
|
||||
if (samlResult.contains("preloginCookie")) {
|
||||
PLOGI << "SAML login succeeded, got the prelogin-cookie " << samlResult.value("preloginCookie");
|
||||
} else {
|
||||
PLOGI << "SAML login succeeded, got the portal-userauthcookie " << samlResult.value("userAuthCookie");
|
||||
}
|
||||
|
||||
fetchConfig(samlResult.value("username"), "", samlResult.value("preloginCookie"), samlResult.value("userAuthCookie"));
|
||||
}
|
||||
|
||||
void PortalAuthenticator::onSAMLLoginFail(const QString msg)
|
||||
{
|
||||
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;
|
||||
|
||||
PLOGI << "Fetching the portal config from " << configUrl << " for user: " << username;
|
||||
|
||||
QNetworkReply *reply = createRequest(configUrl, loginParams.toUtf8());
|
||||
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onFetchConfigFinished);
|
||||
}
|
||||
|
||||
void PortalAuthenticator::onFetchConfigFinished()
|
||||
{
|
||||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||
|
||||
if (reply->error()) {
|
||||
PLOGE << 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 (normalLoginWindow) {
|
||||
normalLoginWindow->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;
|
||||
}
|
||||
|
||||
PLOGI << "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 (normalLoginWindow) {
|
||||
PLOGI << "Closing the NormalLoginWindow...";
|
||||
|
||||
normalLoginWindow->close();
|
||||
}
|
||||
|
||||
emit success(response, preloginResponse.region());
|
||||
}
|
||||
|
||||
void PortalAuthenticator::emitFail(const QString& msg)
|
||||
{
|
||||
emit fail(msg);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
#ifndef PORTALAUTHENTICATOR_H
|
||||
#define PORTALAUTHENTICATOR_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include "portalconfigresponse.h"
|
||||
#include "normalloginwindow.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 msg);
|
||||
void onFetchConfigFinished();
|
||||
|
||||
private:
|
||||
QString portal;
|
||||
QString clientos;
|
||||
QString preloginUrl;
|
||||
QString configUrl;
|
||||
QString username;
|
||||
QString password;
|
||||
|
||||
PreloginResponse preloginResponse;
|
||||
|
||||
bool isAutoLogin { false };
|
||||
|
||||
NormalLoginWindow *normalLoginWindow{ 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
|
||||
@@ -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)
|
||||
{
|
||||
PLOGI << "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) {
|
||||
PLOGI << "Start reading " << name;
|
||||
response.setUserAuthCookie(xmlReader.readElementText());
|
||||
} else if (name == xmlPrelogonUserAuthCookie) {
|
||||
PLOGI << "Start reading " << name;
|
||||
response.setPrelogonUserAuthCookie(xmlReader.readElementText());
|
||||
} else if (name == xmlGateways) {
|
||||
response.setAllGateways(parseGateways(xmlReader));
|
||||
}
|
||||
}
|
||||
|
||||
PLOGI << "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)
|
||||
{
|
||||
PLOGI << "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);
|
||||
}
|
||||
}
|
||||
|
||||
PLOGI << "Finished parsing the gateways.";
|
||||
|
||||
return gateways;
|
||||
}
|
||||
|
||||
void PortalConfigResponse::parseGateway(QXmlStreamReader &reader, GPGateway &gateway) {
|
||||
PLOGI << "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) {
|
||||
PLOGI << "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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
{
|
||||
PLOGI << "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);
|
||||
}
|
||||
@@ -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
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 993 B |
@@ -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>
|
||||
@@ -1,100 +0,0 @@
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWebEngineWidgets/QWebEngineProfile>
|
||||
#include <QtWebEngineWidgets/QWebEngineView>
|
||||
#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);
|
||||
// webView->page()->profile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
|
||||
verticalLayout->addWidget(webView);
|
||||
|
||||
webView->initialize();
|
||||
connect(webView, &EnhancedWebView::responseReceived, this, &SAMLLoginWindow::onResponseReceived);
|
||||
connect(webView, &EnhancedWebView::loadFinished, this, &SAMLLoginWindow::onLoadFinished);
|
||||
}
|
||||
|
||||
SAMLLoginWindow::~SAMLLoginWindow()
|
||||
{
|
||||
delete webView;
|
||||
}
|
||||
|
||||
void SAMLLoginWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
event->accept();
|
||||
reject();
|
||||
}
|
||||
|
||||
void SAMLLoginWindow::login(const QString samlMethod, const QString samlRequest, const QString preloingUrl)
|
||||
{
|
||||
if (samlMethod == "POST") {
|
||||
webView->setHtml(samlRequest, preloingUrl);
|
||||
} else if (samlMethod == "REDIRECT") {
|
||||
webView->load(samlRequest);
|
||||
} else {
|
||||
PLOGE << "Unknown saml-auth-method expected POST or REDIRECT, got " << samlMethod;
|
||||
emit fail("Unknown saml-auth-method, got " + samlMethod);
|
||||
}
|
||||
}
|
||||
|
||||
void SAMLLoginWindow::onResponseReceived(QJsonObject params)
|
||||
{
|
||||
QString type = params.value("type").toString();
|
||||
// Skip non-document response
|
||||
if (type != "Document") {
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject response = params.value("response").toObject();
|
||||
QJsonObject headers = response.value("headers").toObject();
|
||||
|
||||
const QString username = headers.value("saml-username").toString();
|
||||
const QString preloginCookie = headers.value("prelogin-cookie").toString();
|
||||
const QString userAuthCookie = headers.value("portal-userauthcookie").toString();
|
||||
|
||||
LOGI << "Response received from " << response.value("url").toString();
|
||||
|
||||
if (!username.isEmpty()) {
|
||||
LOGI << "Got username from SAML response headers " << username;
|
||||
samlResult.insert("username", username);
|
||||
}
|
||||
|
||||
if (!preloginCookie.isEmpty()) {
|
||||
LOGI << "Got prelogin-cookie from SAML response headers " << preloginCookie;
|
||||
samlResult.insert("preloginCookie", preloginCookie);
|
||||
}
|
||||
|
||||
if (!userAuthCookie.isEmpty()) {
|
||||
LOGI << "Got portal-userauthcookie from SAML response headers " << userAuthCookie;
|
||||
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();
|
||||
} else {
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
|
||||
void SAMLLoginWindow::onLoadFinished()
|
||||
{
|
||||
LOGI << "Load finished " << this->webView->page()->url().toString();
|
||||
}
|
||||
@@ -1,35 +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);
|
||||
~SAMLLoginWindow();
|
||||
|
||||
void login(const QString samlMethod, const QString samlRequest, const QString preloingUrl);
|
||||
|
||||
signals:
|
||||
void success(QMap<QString, QString> samlResult);
|
||||
void fail(const QString msg);
|
||||
|
||||
private slots:
|
||||
void onResponseReceived(QJsonObject params);
|
||||
void onLoadFinished();
|
||||
|
||||
private:
|
||||
EnhancedWebView *webView;
|
||||
QMap<QString, QString> samlResult;
|
||||
|
||||
void closeEvent(QCloseEvent *event);
|
||||
};
|
||||
|
||||
#endif // SAMLLOGINWINDOW_H
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,34 +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();
|
||||
}
|
||||
@@ -1,28 +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();
|
||||
|
||||
private:
|
||||
Ui::SettingsDialog *ui;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
@@ -1,107 +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>177</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 "/etc/gpservice/gp.conf"</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Value of "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="2" 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>
|
||||
</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>
|
||||
@@ -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
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
@@ -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()
|
||||