Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
4fada9bd14 | ||
|
|
b57fb993ca | ||
|
|
f6d06ed978 | ||
|
|
cc67de3a2b | ||
|
|
e2d28c83b2 | ||
|
|
a489c5881b | ||
|
|
44fd2f1d3f | ||
|
|
9c9b42b87f | ||
|
|
fb2b148b72 | ||
|
|
64bec9660a | ||
|
|
0619e91bf5 | ||
|
|
048aa4799f | ||
|
|
db0e8b801d | ||
|
|
d03bbc339e | ||
|
|
1312d54d08 | ||
|
|
39f99d9143 | ||
|
|
7a4eb0def3 | ||
|
|
d9b2094edd | ||
|
|
e6118af9f3 | ||
|
|
108b4be3ec | ||
|
|
65c59e47ec | ||
|
|
177da7f3a2 | ||
|
|
d5cd90373b | ||
|
|
ffa99d3783 | ||
|
|
4940830885 | ||
|
|
ad178fe56c | ||
|
|
829298bb84 | ||
|
|
8fe717d844 | ||
|
|
dffbc64ef5 | ||
|
|
b99c5a8391 | ||
|
|
c2f7576d10 | ||
|
|
4327235093 | ||
|
|
0699878b92 | ||
|
|
e3aba11506 | ||
|
|
ff58258d5c | ||
|
|
991cf25a7b | ||
|
|
02c70150ba | ||
|
|
28d8321958 | ||
|
|
e1c9180cae | ||
|
|
57df34fd1e | ||
|
|
04d180e11a | ||
|
|
6d3b127569 | ||
|
|
e72b25e415 | ||
|
|
37a511c24d | ||
|
|
ad7db36c92 | ||
|
|
11dc5920ef | ||
|
|
e6383916c7 | ||
|
|
1d9d928b26 | ||
|
|
c02ad5d46d | ||
|
|
2319c7c49c | ||
|
|
e0c2c14dc3 | ||
|
|
8f27c92e7b | ||
|
|
9d6ec84c14 | ||
|
|
dd81ed9519 | ||
|
|
32bd713965 | ||
|
|
ba92517141 | ||
|
|
0e4e082594 | ||
|
|
3e590cab7b | ||
|
|
3e0e4cff12 | ||
|
|
692df2f2c5 | ||
|
|
f2b9ffddde | ||
|
|
ca38925066 | ||
|
|
8591dd7e81 | ||
|
|
b07880930e | ||
|
|
fceb80e10e | ||
|
|
d802c56d8f | ||
|
|
386f08d0e8 | ||
|
|
9e7fb17bd3 | ||
|
|
36d9753008 | ||
|
|
e5b3df9cda | ||
|
|
0dd705d0c0 | ||
|
|
ce2360be61 | ||
|
|
b5b7033eee | ||
|
|
9e7db4eb86 | ||
|
|
bc07e3d496 | ||
|
|
452fe2f189 | ||
|
|
8a65099ca7 | ||
|
|
5c97b2df7a | ||
|
|
0d4485d754 | ||
|
|
98e641e99d | ||
|
|
6fa77cdbd2 | ||
|
|
64e6487e7e | ||
|
|
e8b2c1606f |
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
|
||||
@@ -0,0 +1,16 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[{*.c,*.h}]
|
||||
indent_style = tab
|
||||
indent_size = 8
|
||||
|
||||
[{Makefile,Makefile.in}]
|
||||
indent_style = tab
|
||||
@@ -0,0 +1,2 @@
|
||||
ko_fi: yuezk
|
||||
custom: ["https://buymeacoffee.com/yuezk", "https://paypal.me/zongkun"]
|
||||
@@ -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,98 @@
|
||||
name: Build Linux GUI
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
gp_ref:
|
||||
required: true
|
||||
type: string
|
||||
gpgui_ref:
|
||||
required: true
|
||||
type: string
|
||||
channel:
|
||||
required: true
|
||||
type: string
|
||||
builder:
|
||||
required: true
|
||||
type: string
|
||||
artifact_suffix:
|
||||
default: ""
|
||||
type: string
|
||||
verify_desktop_assets:
|
||||
default: false
|
||||
type: boolean
|
||||
secrets:
|
||||
GH_PAT:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- runner: ubuntu-latest
|
||||
arch: amd64
|
||||
- runner: ubuntu-24.04-arm
|
||||
arch: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.os.runner }}
|
||||
name: build (${{ matrix.os.arch }})
|
||||
steps:
|
||||
- uses: pnpm/action-setup@v5
|
||||
with:
|
||||
version: 9
|
||||
- name: Prepare workspace
|
||||
run: rm -rf gpgui-source && mkdir gpgui-source
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ inputs.gp_ref }}
|
||||
path: gpgui-source/gp
|
||||
submodules: recursive
|
||||
- name: Checkout gpgui
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/gpgui
|
||||
ref: ${{ inputs.gpgui_ref }}
|
||||
path: gpgui-source/gpgui
|
||||
- name: Verify Linux desktop assets
|
||||
if: matrix.os.arch == 'amd64' && inputs.verify_desktop_assets
|
||||
run: gpgui-source/gp/scripts/verify-linux-desktop-assets.sh gpgui-source/gpgui
|
||||
- name: Tarball
|
||||
run: |
|
||||
cd gpgui-source
|
||||
tar -czf gpgui.tar.gz gpgui gp
|
||||
- name: Build gpgui in Docker
|
||||
env:
|
||||
GPGUI_BUILDER: ${{ inputs.builder }}
|
||||
GPGUI_BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
|
||||
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
|
||||
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
|
||||
run: |
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-e GPGUI_BUILD_VERSION \
|
||||
-e GPGUI_UPDATE_CHANNEL \
|
||||
-e GPGUI_LICENSE_SIGNING_KEYS \
|
||||
-v "$(pwd)/gpgui-source:/workspace" "yuezk/gpdev:$GPGUI_BUILDER"
|
||||
- name: Install gpgui in Docker
|
||||
env:
|
||||
GPGUI_BUILDER: ${{ inputs.builder }}
|
||||
run: |
|
||||
cd gpgui-source
|
||||
tar -xJf ./*.bin.tar.xz
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-v "$(pwd):/workspace" "yuezk/gpdev:$GPGUI_BUILDER" \
|
||||
bash -c "cd /workspace/gpgui_*/ && ./gpgui --version"
|
||||
- name: Upload gpgui
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: artifact-gpgui${{ inputs.artifact_suffix }}-${{ matrix.os.arch }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
gpgui-source/*.bin.tar.xz
|
||||
gpgui-source/*.bin.tar.xz.sha256
|
||||
@@ -0,0 +1,971 @@
|
||||
name: Build
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel:
|
||||
description: 'Build channel. Stable builds require matching vX.Y.Z refs in both repositories.'
|
||||
required: true
|
||||
default: snapshot
|
||||
type: choice
|
||||
options: [snapshot, stable]
|
||||
build_only:
|
||||
description: 'Build and test artifacts without publishing releases, images, or update feeds'
|
||||
required: true
|
||||
default: false
|
||||
type: boolean
|
||||
gp_branch:
|
||||
description: 'GlobalProtect-openconnect ref to build (use the matching tag for stable builds)'
|
||||
required: true
|
||||
default: dev
|
||||
gpgui_branch:
|
||||
description: 'gpgui ref to build (use the matching tag for stable builds)'
|
||||
required: true
|
||||
default: dev
|
||||
build_macos:
|
||||
description: 'Build Apple Silicon artifacts for this run'
|
||||
required: true
|
||||
default: false
|
||||
type: boolean
|
||||
build_bsd:
|
||||
description: 'Build FreeBSD/OpenBSD packages for this run'
|
||||
required: true
|
||||
default: false
|
||||
type: boolean
|
||||
build_bsd_arm64:
|
||||
description: 'Build optional FreeBSD/OpenBSD arm64 packages for this run. Slow and disabled by default'
|
||||
required: true
|
||||
default: false
|
||||
type: boolean
|
||||
push:
|
||||
paths-ignore:
|
||||
- LICENSE
|
||||
- "*.md"
|
||||
- .vscode
|
||||
- .devcontainer
|
||||
branches:
|
||||
- main
|
||||
- hotfix/*
|
||||
- feature/*
|
||||
- release/*
|
||||
tags:
|
||||
- v*.*.*
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && (inputs.build_only && github.run_id || 'release') || github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') }}
|
||||
|
||||
jobs:
|
||||
validate-inputs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Validate stable refs
|
||||
env:
|
||||
EVENT: ${{ github.event_name }}
|
||||
CHANNEL: ${{ inputs.channel }}
|
||||
GP_REF: ${{ inputs.gp_branch }}
|
||||
GPGUI_REF: ${{ inputs.gpgui_branch }}
|
||||
run: |
|
||||
if [[ "$EVENT" == workflow_dispatch && "$CHANNEL" == stable ]]; then
|
||||
if [[ ! "$GP_REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ || "$GP_REF" != "$GPGUI_REF" ]]; then
|
||||
echo "Stable builds require matching vX.Y.Z refs" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
test-gp:
|
||||
needs: validate-inputs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
submodules: recursive
|
||||
- name: Run Rust tests as a non-root user with focused privilege checks
|
||||
run: |
|
||||
docker run --rm \
|
||||
--user vscode \
|
||||
-e HOME=/home/vscode \
|
||||
-e CARGO_TARGET_DIR=/tmp/gp-test-target \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-e LIBXML2_STATIC=1 \
|
||||
-v "$(pwd):/workspace:ro" \
|
||||
-w /workspace \
|
||||
yuezk/gpdev:binary-builder-tauri2 \
|
||||
sh -ec '
|
||||
test "$(id -u)" -ne 0
|
||||
# Tauri generates schemas in the source tree. Keep the host checkout read-only.
|
||||
cp -R /workspace /tmp/gp-test-workspace
|
||||
cd /tmp/gp-test-workspace
|
||||
cargo test --workspace --locked
|
||||
|
||||
# Exercise only the paths that require an actual root process.
|
||||
sudo -E env PATH="$PATH" PKEXEC_UID="$(id -u)" cargo test --locked -p gpapi \
|
||||
process::auth_launcher::tests::custom_authenticator_crash_does_not_request_recovery -- --exact
|
||||
sudo -E env PATH="$PATH" PKEXEC_UID="$(id -u)" cargo test --locked -p gpapi \
|
||||
process::collection::tests::root_owned_sticky_directories_protect_collectors_without_trusting_writable_files -- --exact
|
||||
sudo -E env PATH="$PATH" PKEXEC_UID="$(id -u)" cargo test --locked -p gpservice \
|
||||
--bin gpservice device_anchor::tests
|
||||
'
|
||||
|
||||
tarball:
|
||||
needs: validate-inputs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: pnpm/action-setup@v5
|
||||
with:
|
||||
version: 9
|
||||
- name: Prepare workspace
|
||||
run: rm -rf source && mkdir -p source/artifacts
|
||||
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
path: source/gp
|
||||
submodules: recursive
|
||||
|
||||
- name: Create tarball
|
||||
env:
|
||||
IS_SNAPSHOT: ${{ (github.event_name == 'workflow_dispatch' && inputs.channel == 'snapshot') || (github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/')) }}
|
||||
run: |
|
||||
cd source/gp
|
||||
# Stable manual builds use tagged source even when dispatched from main.
|
||||
if [[ "$IS_SNAPSHOT" == true ]]; then
|
||||
touch SNAPSHOT
|
||||
fi
|
||||
make tarball
|
||||
|
||||
mv -v .build/tarball/*.tar.gz ../artifacts/
|
||||
|
||||
- name: Generate RPM spec file
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
|
||||
run: |
|
||||
cd source/gp
|
||||
|
||||
make init-rpm \
|
||||
REVISION='1%{?dist}' \
|
||||
RPM_SOURCE=https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${RELEASE_TAG}/%{name}-%{version}.tar.gz
|
||||
|
||||
mv -v .build/rpm/*.spec ../artifacts/
|
||||
|
||||
- name: Upload tarball
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: artifact-source
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
source/artifacts/*
|
||||
|
||||
tarball-offline:
|
||||
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }}
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- tarball
|
||||
steps:
|
||||
- uses: pnpm/action-setup@v5
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Prepare workspace
|
||||
run: rm -rf source-offline && mkdir source-offline
|
||||
|
||||
- name: Download tarball
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: artifact-source
|
||||
path: source-offline
|
||||
|
||||
- name: Create offline tarball
|
||||
run: |
|
||||
cd source-offline
|
||||
|
||||
offline_tarball=$(basename *.tar.gz .tar.gz).offline.tar.gz
|
||||
|
||||
# Extract the tarball
|
||||
tar -xzf *.tar.gz
|
||||
|
||||
cd */
|
||||
make tarball OFFLINE=1
|
||||
|
||||
# Rename the tarball to .offline.tar.gz
|
||||
mv -v .build/tarball/*.tar.gz ../$offline_tarball
|
||||
|
||||
- name: Upload offline tarball
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
path: source-offline/*.offline.tar.gz
|
||||
name: artifact-source-offline
|
||||
if-no-files-found: error
|
||||
|
||||
build-gp:
|
||||
if: ${{ !(startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.channel == 'stable')) }}
|
||||
needs:
|
||||
- tarball
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- runner: ubuntu-latest
|
||||
arch: amd64
|
||||
- runner: ubuntu-24.04-arm
|
||||
arch: ubuntu-24.04-arm
|
||||
package: [deb, rpm, pkg, apk, binary, ubuntu-rolling]
|
||||
runs-on: ${{ matrix.os.runner }}
|
||||
name: build-gp (${{ matrix.package }}, ${{ matrix.os.arch }})
|
||||
steps:
|
||||
- name: Prepare workspace
|
||||
run: |
|
||||
rm -rf build-gp-${{ matrix.package }}
|
||||
mkdir -p build-gp-${{ matrix.package }}
|
||||
- name: Download tarball
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: artifact-source
|
||||
path: build-gp-${{ matrix.package }}
|
||||
- name: Build ${{ matrix.package }} package in Docker
|
||||
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
||||
run: |
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-e LIBXML2_STATIC=1 \
|
||||
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
|
||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
|
||||
- name: Install ${{ matrix.package }} package in Docker
|
||||
run: |
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-e GPGUI_INSTALLED=0 \
|
||||
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
|
||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
|
||||
bash install.sh
|
||||
# Don't upload package for ubuntu-rolling because it's duplicate of deb package
|
||||
- name: Upload ${{ matrix.package }} package
|
||||
if: ${{ matrix.package != 'ubuntu-rolling' }}
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: artifact-gp-${{ matrix.package }}-${{ matrix.os.arch }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
build-gp-${{ matrix.package }}/artifacts/*
|
||||
|
||||
build-docker-image:
|
||||
if: ${{ !(startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.channel == 'stable')) }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- runner: ubuntu-latest
|
||||
platform: linux/amd64
|
||||
- runner: ubuntu-24.04-arm
|
||||
platform: linux/arm64
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Prepare
|
||||
run: |
|
||||
platform=${{ matrix.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
submodules: recursive
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Login to Docker Hub
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.build_only }}
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
- name: Build and push by digest
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.build_only }}
|
||||
id: build
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
file: packaging/docker/alpine/Dockerfile
|
||||
platforms: ${{ matrix.platform }}
|
||||
outputs: type=image,name=yuezk/globalprotect-openconnect,push-by-digest=true,name-canonical=true,push=true
|
||||
- name: Build local image for verification
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.build_only }}
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
file: packaging/docker/alpine/Dockerfile
|
||||
platforms: ${{ matrix.platform }}
|
||||
tags: yuezk/globalprotect-openconnect:build-test
|
||||
load: true
|
||||
push: false
|
||||
- name: Verify CLI tools
|
||||
env:
|
||||
IMAGE: yuezk/globalprotect-openconnect
|
||||
DIGEST: ${{ steps.build.outputs.digest }}
|
||||
BUILD_ONLY: ${{ github.event_name == 'workflow_dispatch' && inputs.build_only }}
|
||||
run: |
|
||||
image_ref="$IMAGE@$DIGEST"
|
||||
if [[ "$BUILD_ONLY" == "true" ]]; then
|
||||
image_ref="$IMAGE:build-test"
|
||||
fi
|
||||
docker run --rm "$image_ref" --help
|
||||
docker run --rm --entrypoint gpauth "$image_ref" --help
|
||||
docker run --rm --entrypoint sh "$image_ref" -lc 'test "$(id -u gp)" = "1000" && test "$SUDO_UID" = "1000"'
|
||||
- name: Export digest
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.build_only }}
|
||||
run: |
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
- name: Upload digest
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.build_only }}
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: digests-${{ env.PLATFORM_PAIR }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
build-gpgui-glibc:
|
||||
needs: validate-inputs
|
||||
name: build-gpgui (glibc)
|
||||
uses: ./.github/workflows/build-gpgui-linux.yaml
|
||||
with:
|
||||
gp_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
gpgui_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||
builder: gpgui-builder-tauri2
|
||||
verify_desktop_assets: true
|
||||
secrets:
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
|
||||
build-gpgui-musl:
|
||||
needs: validate-inputs
|
||||
name: build-gpgui (musl)
|
||||
uses: ./.github/workflows/build-gpgui-linux.yaml
|
||||
with:
|
||||
gp_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
gpgui_ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||
builder: gpgui-alpine-builder-tauri2
|
||||
artifact_suffix: -musl
|
||||
secrets:
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
|
||||
nix-source:
|
||||
needs: [build-gpgui-glibc]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- runner: ubuntu-latest
|
||||
system: x86_64-linux
|
||||
artifact_arch: amd64
|
||||
- runner: ubuntu-24.04-arm
|
||||
system: aarch64-linux
|
||||
artifact_arch: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.platform.runner }}
|
||||
name: nix-source (${{ matrix.platform.system }})
|
||||
env:
|
||||
NIX_SYSTEM: ${{ matrix.platform.system }}
|
||||
NIXPKGS: locked
|
||||
steps:
|
||||
- name: Checkout source and dependencies
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
submodules: recursive
|
||||
path: gp
|
||||
- name: Download current GUI artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: artifact-gpgui-${{ matrix.platform.artifact_arch }}
|
||||
path: nix-artifacts/gui
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
- name: Configure current source and GUI inputs
|
||||
run: |
|
||||
echo "GP_SOURCE=$PWD/gp" >> "$GITHUB_ENV"
|
||||
gui_archive=$(find "$PWD/nix-artifacts/gui" -name '*.bin.tar.xz' -type f)
|
||||
test -f "$gui_archive"
|
||||
echo "GP_GUI_ARCHIVE=$gui_archive" >> "$GITHUB_ENV"
|
||||
- name: Build source package
|
||||
run: |
|
||||
nix build --impure --file gp/nix/ci.nix source \
|
||||
--extra-experimental-features "nix-command flakes" --print-build-logs
|
||||
bash gp/scripts/tests/nix-desktop-authorization.sh result
|
||||
- name: Test source runtime in NixOS
|
||||
if: matrix.platform.system == 'x86_64-linux'
|
||||
run: |
|
||||
nix build --impure --file gp/nix/ci.nix runtime-source \
|
||||
--extra-experimental-features "nix-command flakes" --print-build-logs
|
||||
|
||||
nix-prebuilt:
|
||||
needs: [build-gp, build-gpgui-glibc]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- runner: ubuntu-latest
|
||||
system: x86_64-linux
|
||||
artifact_arch: amd64
|
||||
- runner: ubuntu-24.04-arm
|
||||
system: aarch64-linux
|
||||
artifact_arch: ubuntu-24.04-arm
|
||||
nixpkgs: [locked, nixos-25.11, nixos-26.05, nixpkgs-unstable]
|
||||
runs-on: ${{ matrix.platform.runner }}
|
||||
name: nix-prebuilt (${{ matrix.platform.system }}, ${{ matrix.nixpkgs }})
|
||||
env:
|
||||
NIX_SYSTEM: ${{ matrix.platform.system }}
|
||||
NIXPKGS: ${{ matrix.nixpkgs }}
|
||||
steps:
|
||||
- name: Checkout packaging and tests
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
submodules: recursive
|
||||
path: gp
|
||||
- name: Download current Linux binary artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: artifact-gp-binary-${{ matrix.platform.artifact_arch }}
|
||||
path: nix-artifacts/binaries
|
||||
- name: Download current GUI artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: artifact-gpgui-${{ matrix.platform.artifact_arch }}
|
||||
path: nix-artifacts/gui
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
- name: Configure current artifact inputs
|
||||
run: |
|
||||
echo "GP_SOURCE=$PWD/gp" >> "$GITHUB_ENV"
|
||||
binary_archive=$(find "$PWD/nix-artifacts/binaries" -name '*.bin.tar.xz' -type f)
|
||||
gui_archive=$(find "$PWD/nix-artifacts/gui" -name '*.bin.tar.xz' -type f)
|
||||
test -f "$binary_archive"
|
||||
test -f "$gui_archive"
|
||||
echo "GP_BINARY_ARCHIVE=$binary_archive" >> "$GITHUB_ENV"
|
||||
echo "GP_GUI_ARCHIVE=$gui_archive" >> "$GITHUB_ENV"
|
||||
- name: Build package through host NixOS module
|
||||
run: |
|
||||
nix build --impure --file gp/nix/ci.nix module \
|
||||
--extra-experimental-features "nix-command flakes" --print-build-logs
|
||||
bash gp/scripts/tests/nix-desktop-authorization.sh result
|
||||
- name: Build standalone prebuilt package
|
||||
if: matrix.nixpkgs == 'locked'
|
||||
run: |
|
||||
nix build --impure --file gp/nix/ci.nix prebuilt \
|
||||
--extra-experimental-features "nix-command flakes" --print-build-logs
|
||||
- name: Test prebuilt runtime in NixOS
|
||||
if: matrix.nixpkgs == 'locked' && matrix.platform.system == 'x86_64-linux'
|
||||
run: |
|
||||
nix build --impure --file gp/nix/ci.nix runtime-prebuilt \
|
||||
--extra-experimental-features "nix-command flakes" --print-build-logs
|
||||
|
||||
trigger-gpgui-macos:
|
||||
needs: test-gp
|
||||
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_macos) || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_MACOS_ON_TAG == 'true') }}
|
||||
permissions:
|
||||
contents: read
|
||||
runs-on: ubuntu-latest
|
||||
name: trigger private macOS build
|
||||
outputs:
|
||||
run_id: ${{ steps.dispatch.outputs.run_id }}
|
||||
run_url: ${{ steps.dispatch.outputs.run_url }}
|
||||
steps:
|
||||
- name: Dispatch private macOS build
|
||||
id: dispatch
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GPGUI_ACTIONS_TOKEN }}
|
||||
PUBLIC_GH_TOKEN: ${{ github.token }}
|
||||
CHANNEL: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
|
||||
GP_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref_name }}
|
||||
GPGUI_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||
BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
|
||||
REQUEST_ID: ${{ github.run_id }}.${{ github.run_attempt }}.macos
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "${GH_TOKEN:-}" ]]; then
|
||||
echo "GPGUI_ACTIONS_TOKEN is not configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gp_ref_path="$(jq -rn --arg ref "$GP_REF" '$ref | @uri')"
|
||||
gpgui_ref_path="$(jq -rn --arg ref "$GPGUI_REF" '$ref | @uri')"
|
||||
gp_sha="$(GH_TOKEN="$PUBLIC_GH_TOKEN" gh api \
|
||||
"repos/yuezk/GlobalProtect-openconnect/commits/$gp_ref_path" --jq .sha)"
|
||||
gpgui_sha="$(gh api "repos/yuezk/gpgui/commits/$gpgui_ref_path" --jq .sha)"
|
||||
if [[ -z "$gp_sha" || -z "$gpgui_sha" ]]; then
|
||||
echo "Could not resolve release source refs" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
expected_title="macOS build $CHANNEL $RELEASE_TAG ($REQUEST_ID)"
|
||||
jq -n \
|
||||
--arg workflow_ref "$GPGUI_REF" \
|
||||
--arg request_id "$REQUEST_ID" \
|
||||
--arg build_version "$BUILD_VERSION" \
|
||||
--arg channel "$CHANNEL" \
|
||||
--arg release_tag "$RELEASE_TAG" \
|
||||
--arg gp_ref "$gp_sha" \
|
||||
--arg gpgui_ref "$gpgui_sha" \
|
||||
'{
|
||||
ref: $workflow_ref,
|
||||
inputs: {
|
||||
request_id: $request_id,
|
||||
build_version: $build_version,
|
||||
channel: $channel,
|
||||
release_tag: $release_tag,
|
||||
gp_ref: $gp_ref,
|
||||
gpgui_ref: $gpgui_ref
|
||||
}
|
||||
}' | gh api --method POST \
|
||||
repos/yuezk/gpgui/actions/workflows/build-macos.yaml/dispatches \
|
||||
--input -
|
||||
|
||||
run_id=""
|
||||
run_url=""
|
||||
for _ in {1..40}; do
|
||||
runs="$(gh api \
|
||||
'repos/yuezk/gpgui/actions/workflows/build-macos.yaml/runs?event=workflow_dispatch&per_page=50')"
|
||||
run_id="$(jq -r --arg title "$expected_title" \
|
||||
'[.workflow_runs[] | select(.display_title == $title)] | first | .id // empty' \
|
||||
<<<"$runs")"
|
||||
run_url="$(jq -r --arg title "$expected_title" \
|
||||
'[.workflow_runs[] | select(.display_title == $title)] | first | .html_url // empty' \
|
||||
<<<"$runs")"
|
||||
if [[ -n "$run_id" ]]; then
|
||||
{
|
||||
echo "run_id=$run_id"
|
||||
echo "run_url=$run_url"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
echo "Triggered private workflow: $run_url"
|
||||
exit 0
|
||||
fi
|
||||
sleep 3
|
||||
done
|
||||
|
||||
echo "Could not locate the dispatched private workflow run" >&2
|
||||
exit 1
|
||||
|
||||
setup-bsd-matrix:
|
||||
needs: validate-inputs
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
enabled: ${{ steps.matrix.outputs.enabled }}
|
||||
matrix: ${{ steps.matrix.outputs.matrix }}
|
||||
steps:
|
||||
- name: Build matrix
|
||||
id: matrix
|
||||
env:
|
||||
BUILD_BSD_ON_TAG: ${{ startsWith(github.ref, 'refs/tags/') && vars.BUILD_BSD_ON_TAG == 'true' }}
|
||||
BUILD_BSD: ${{ github.event_name == 'workflow_dispatch' && inputs.build_bsd }}
|
||||
BUILD_BSD_ARM64: ${{ github.event_name == 'workflow_dispatch' && inputs.build_bsd_arm64 }}
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
import os
|
||||
|
||||
build_bsd = os.environ["BUILD_BSD_ON_TAG"] == "true" or os.environ["BUILD_BSD"] == "true"
|
||||
build_bsd_arm64 = os.environ["BUILD_BSD_ARM64"] == "true"
|
||||
include = []
|
||||
|
||||
def add(os_name, arch):
|
||||
include.append({
|
||||
"os": os_name,
|
||||
"arch": arch,
|
||||
"workspace": f"{os_name}-{arch}-source",
|
||||
"artifact": f"artifact-bsd-{os_name}-{arch}",
|
||||
"package_target": f"package-{os_name}",
|
||||
"artifact_dir": os_name,
|
||||
})
|
||||
|
||||
if build_bsd:
|
||||
add("freebsd", "x86_64")
|
||||
add("openbsd", "x86_64")
|
||||
if build_bsd_arm64:
|
||||
add("freebsd", "arm64")
|
||||
add("openbsd", "arm64")
|
||||
|
||||
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
|
||||
output.write(f"enabled={str(bool(include)).lower()}\n")
|
||||
output.write(f"matrix={json.dumps({'include': include}, separators=(',', ':'))}\n")
|
||||
PY
|
||||
|
||||
build-gpgui-frontend:
|
||||
needs: setup-bsd-matrix
|
||||
if: ${{ needs.setup-bsd-matrix.outputs.enabled == 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: pnpm/action-setup@v5
|
||||
with:
|
||||
version: 9
|
||||
- name: Prepare workspace
|
||||
run: rm -rf gpgui-frontend && mkdir gpgui-frontend
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
path: gpgui-frontend/gp
|
||||
submodules: recursive
|
||||
- name: Checkout gpgui
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/gpgui
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||
path: gpgui-frontend/gpgui
|
||||
- name: Build gpgui frontend
|
||||
run: |
|
||||
cd gpgui-frontend/gpgui/apps/desktop
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm build
|
||||
- name: Upload gpgui frontend
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: bsd-gpgui-frontend
|
||||
if-no-files-found: error
|
||||
path: gpgui-frontend/gpgui/apps/desktop/dist/**
|
||||
|
||||
build-bsd:
|
||||
needs:
|
||||
- setup-bsd-matrix
|
||||
- build-gpgui-frontend
|
||||
if: ${{ needs.setup-bsd-matrix.outputs.enabled == 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
name: build-${{ matrix.os }} (${{ matrix.arch }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.setup-bsd-matrix.outputs.matrix) }}
|
||||
steps:
|
||||
- name: Prepare workspace
|
||||
run: rm -rf "${{ matrix.workspace }}" && mkdir "${{ matrix.workspace }}"
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
path: ${{ matrix.workspace }}/gp
|
||||
submodules: recursive
|
||||
- name: Checkout gpgui
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/gpgui
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
|
||||
path: ${{ matrix.workspace }}/gpgui
|
||||
- name: Download gpgui frontend
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: bsd-gpgui-frontend
|
||||
path: ${{ matrix.workspace }}/gpgui/apps/desktop/dist
|
||||
- name: Build on FreeBSD
|
||||
if: ${{ matrix.os == 'freebsd' }}
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
release: "14.4"
|
||||
arch: ${{ matrix.arch }}
|
||||
usesh: true
|
||||
prepare: |
|
||||
pkg install -y \
|
||||
git \
|
||||
rust \
|
||||
libiconv \
|
||||
gettext-tools \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
patch \
|
||||
gmake \
|
||||
pkgconf \
|
||||
libxml2 \
|
||||
gnutls \
|
||||
p11-kit \
|
||||
nettle \
|
||||
gmp \
|
||||
gnome-keyring \
|
||||
libayatana-appindicator \
|
||||
polkit \
|
||||
webkit2-gtk_41
|
||||
run: |
|
||||
set -eu
|
||||
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
|
||||
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
|
||||
|
||||
cd "${{ matrix.workspace }}/gp"
|
||||
cargo build --release --workspace
|
||||
|
||||
cd ../gpgui/apps/desktop/src-tauri
|
||||
cargo build --release --workspace
|
||||
|
||||
cd ../../../../gp
|
||||
gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui
|
||||
pkg install -y ".build/${{ matrix.artifact_dir }}"/artifacts/*.pkg
|
||||
gpclient --version
|
||||
gpauth --version
|
||||
gpgui --version
|
||||
rm -rf target ../gpgui/target
|
||||
find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} +
|
||||
- name: Build on OpenBSD
|
||||
if: ${{ matrix.os == 'openbsd' }}
|
||||
uses: vmactions/openbsd-vm@v1
|
||||
with:
|
||||
release: "7.9"
|
||||
arch: ${{ matrix.arch }}
|
||||
usesh: true
|
||||
prepare: |
|
||||
set -eu
|
||||
pkg_add -u -I
|
||||
pkg_add -I \
|
||||
git \
|
||||
rust \
|
||||
libiconv \
|
||||
gettext-tools \
|
||||
autoconf%2.72 \
|
||||
automake%1.17 \
|
||||
libtool \
|
||||
gmake \
|
||||
libxml \
|
||||
gnutls \
|
||||
p11-kit \
|
||||
gmp \
|
||||
lz4 \
|
||||
dbus \
|
||||
gnome-keyring \
|
||||
polkit \
|
||||
webkitgtk41 \
|
||||
xdg-utils
|
||||
ln -sf /usr/local/bin/autoreconf-2.72 /usr/local/bin/autoreconf
|
||||
ln -sf /usr/local/bin/autoconf-2.72 /usr/local/bin/autoconf
|
||||
ln -sf /usr/local/bin/autoheader-2.72 /usr/local/bin/autoheader
|
||||
ln -sf /usr/local/bin/autom4te-2.72 /usr/local/bin/autom4te
|
||||
ln -sf /usr/local/bin/aclocal-1.17 /usr/local/bin/aclocal
|
||||
ln -sf /usr/local/bin/automake-1.17 /usr/local/bin/automake
|
||||
run: |
|
||||
set -eu
|
||||
export AUTOCONF_VERSION=2.72
|
||||
export AUTOMAKE_VERSION=1.17
|
||||
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
|
||||
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
|
||||
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
|
||||
|
||||
cd "${{ matrix.workspace }}/gp"
|
||||
cargo build --release --workspace
|
||||
|
||||
cd ../gpgui/apps/desktop/src-tauri
|
||||
cargo build --release --workspace
|
||||
|
||||
cd ../../../../gp
|
||||
gmake "${{ matrix.package_target }}" GPGUI_BINARY=../gpgui/target/release/gpgui
|
||||
pkg_add -D unsigned ".build/${{ matrix.artifact_dir }}"/artifacts/*.tgz
|
||||
gpclient --version
|
||||
gpauth --version
|
||||
gpgui --version
|
||||
rm -rf target ../gpgui/target
|
||||
find ".build/${{ matrix.artifact_dir }}" -mindepth 1 -maxdepth 1 ! -name artifacts -exec rm -rf {} +
|
||||
- name: Upload BSD package
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.artifact }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
${{ matrix.workspace }}/gp/.build/${{ matrix.artifact_dir }}/artifacts/*
|
||||
|
||||
gh-release:
|
||||
if: ${{ always() && ((github.event_name == 'workflow_dispatch' && !inputs.build_only) || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))) }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
id-token: write
|
||||
attestations: write
|
||||
artifact-metadata: write
|
||||
needs:
|
||||
- test-gp
|
||||
- nix-source
|
||||
- nix-prebuilt
|
||||
- tarball
|
||||
- tarball-offline
|
||||
- build-gp
|
||||
- build-docker-image
|
||||
- build-gpgui-glibc
|
||||
- build-gpgui-musl
|
||||
- setup-bsd-matrix
|
||||
- build-gpgui-frontend
|
||||
- build-bsd
|
||||
|
||||
steps:
|
||||
- name: Check required jobs
|
||||
env:
|
||||
NEEDS_JSON: ${{ toJson(needs) }}
|
||||
BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }}
|
||||
IS_STABLE: ${{ (startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.channel == 'stable')) }}
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
needs = json.loads(os.environ["NEEDS_JSON"])
|
||||
bsd_matrix_enabled = os.environ["BSD_MATRIX_ENABLED"] == "true"
|
||||
is_stable = os.environ["IS_STABLE"] == "true"
|
||||
failed = []
|
||||
|
||||
for name, data in needs.items():
|
||||
result = data["result"]
|
||||
if result in {"failure", "cancelled"}:
|
||||
failed.append(f"{name}: {result}")
|
||||
elif name in {"build-gp", "build-docker-image", "nix-prebuilt"} and result == "skipped" and is_stable:
|
||||
continue
|
||||
elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled:
|
||||
continue
|
||||
elif result == "skipped":
|
||||
failed.append(f"{name}: {result}")
|
||||
|
||||
if failed:
|
||||
print("Required jobs did not complete successfully:")
|
||||
for item in failed:
|
||||
print(f" - {item}")
|
||||
sys.exit(1)
|
||||
PY
|
||||
|
||||
- name: Prepare workspace
|
||||
run: rm -rf gh-release && mkdir gh-release
|
||||
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
|
||||
path: gh-release/gp
|
||||
submodules: recursive
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: gh-release/gp/.build/artifacts
|
||||
|
||||
- name: Rename APK artifacts
|
||||
run: |
|
||||
shopt -s nullglob
|
||||
|
||||
for file in gh-release/gp/.build/artifacts/artifact-gp-apk-amd64/*.apk; do
|
||||
mv "$file" "${file%.apk}-x86_64.apk"
|
||||
done
|
||||
for file in gh-release/gp/.build/artifacts/artifact-gp-apk-ubuntu-24.04-arm/*.apk; do
|
||||
mv "$file" "${file%.apk}-aarch64.apk"
|
||||
done
|
||||
|
||||
- name: Generate release asset checksums
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
|
||||
run: |
|
||||
cd gh-release/gp
|
||||
mkdir -p .build
|
||||
scripts/release-assets.sh "$RELEASE_TAG" > .build/release-assets.txt
|
||||
if [ ! -s .build/release-assets.txt ]; then
|
||||
echo "No release assets found"
|
||||
exit 1
|
||||
fi
|
||||
while IFS= read -r file; do
|
||||
digest=$(sha256sum "$file" | cut -d ' ' -f 1)
|
||||
printf '%s %s\n' "$digest" "$(basename "$file")"
|
||||
done < .build/release-assets.txt > .build/release-assets.sha256
|
||||
|
||||
- name: Attest release assets
|
||||
uses: actions/attest-build-provenance@v4
|
||||
with:
|
||||
subject-checksums: gh-release/gp/.build/release-assets.sha256
|
||||
|
||||
- name: Create GH release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
|
||||
run: |
|
||||
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
|
||||
|
||||
wait-gpgui-macos:
|
||||
if: ${{ !cancelled() && needs.trigger-gpgui-macos.result == 'success' }}
|
||||
needs:
|
||||
- trigger-gpgui-macos
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 130
|
||||
steps:
|
||||
- name: Wait for private macOS build
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GPGUI_ACTIONS_TOKEN }}
|
||||
PRIVATE_RUN_ID: ${{ needs.trigger-gpgui-macos.outputs.run_id }}
|
||||
PRIVATE_RUN_URL: ${{ needs.trigger-gpgui-macos.outputs.run_url }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "$PRIVATE_RUN_ID" ]]; then
|
||||
echo "The private macOS workflow was not started" >&2
|
||||
exit 1
|
||||
fi
|
||||
for _ in $(seq 1 480); do
|
||||
run="$(gh api "repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID")"
|
||||
status="$(jq -r '.status' <<<"$run")"
|
||||
conclusion="$(jq -r '.conclusion // ""' <<<"$run")"
|
||||
if [[ "$status" == "completed" ]]; then
|
||||
echo "Private macOS build completed: $PRIVATE_RUN_URL"
|
||||
if [[ "$conclusion" != "success" ]]; then
|
||||
echo "Private macOS build concluded with: $conclusion" >&2
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
sleep 15
|
||||
done
|
||||
|
||||
gh api --method POST \
|
||||
"repos/yuezk/gpgui/actions/runs/$PRIVATE_RUN_ID/cancel" >/dev/null || true
|
||||
echo "Private macOS build timed out: $PRIVATE_RUN_URL" >&2
|
||||
exit 1
|
||||
|
||||
publish-docker-image:
|
||||
needs:
|
||||
- test-gp
|
||||
- build-docker-image
|
||||
if: ${{ (github.event_name == 'workflow_dispatch' && !inputs.build_only) || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digests-*
|
||||
merge-multiple: true
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
- name: Publish Docker manifest
|
||||
working-directory: /tmp/digests
|
||||
env:
|
||||
IMAGE: yuezk/globalprotect-openconnect
|
||||
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
|
||||
run: |
|
||||
docker buildx imagetools create -t "$IMAGE:$RELEASE_TAG" \
|
||||
$(printf "$IMAGE@sha256:%s " *)
|
||||
|
||||
"$GITHUB_WORKSPACE/scripts/verify-docker-publication.sh" "$IMAGE:$RELEASE_TAG" /tmp/digests all
|
||||
@@ -1,30 +0,0 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v2
|
||||
with:
|
||||
version: 5.12.11
|
||||
modules: 'qtwebengine qtwebsockets'
|
||||
|
||||
# Checkout repository and submodules
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
qmake CONFIG+=release
|
||||
make
|
||||
@@ -0,0 +1,118 @@
|
||||
name: Nix
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "flake.nix"
|
||||
- "flake.lock"
|
||||
- "nix/**"
|
||||
- ".github/workflows/nix.yaml"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "flake.nix"
|
||||
- "flake.lock"
|
||||
- "nix/**"
|
||||
- ".github/workflows/nix.yaml"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
standalone-package:
|
||||
name: standalone-package (${{ matrix.platform.system }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- runner: ubuntu-latest
|
||||
system: x86_64-linux
|
||||
- runner: ubuntu-24.04-arm
|
||||
system: aarch64-linux
|
||||
runs-on: ${{ matrix.platform.runner }}
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
|
||||
- name: Build standalone prebuilt package
|
||||
run: |
|
||||
nix build .#prebuilt \
|
||||
--extra-experimental-features "nix-command flakes" \
|
||||
--print-build-logs
|
||||
|
||||
- name: Inspect prebuilt package
|
||||
run: |
|
||||
test -x result/bin/gpclient
|
||||
test -x result/bin/gpauth
|
||||
test -x result/bin/gpservice
|
||||
test -x result/bin/gpgui-helper
|
||||
test -x result/bin/gpgui
|
||||
|
||||
nixos-module:
|
||||
name: nixos-module (${{ matrix.platform.system }}, ${{ matrix.nixpkgs }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform:
|
||||
- runner: ubuntu-latest
|
||||
system: x86_64-linux
|
||||
- runner: ubuntu-24.04-arm
|
||||
system: aarch64-linux
|
||||
nixpkgs:
|
||||
- nixos-25.11
|
||||
- nixos-26.05
|
||||
- nixpkgs-unstable
|
||||
runs-on: ${{ matrix.platform.runner }}
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
|
||||
- name: Build package through host NixOS module
|
||||
env:
|
||||
NIXPKGS_URL: github:NixOS/nixpkgs/${{ matrix.nixpkgs }}
|
||||
NIX_SYSTEM: ${{ matrix.platform.system }}
|
||||
run: |
|
||||
nix build \
|
||||
--impure \
|
||||
--extra-experimental-features "nix-command flakes" \
|
||||
--print-build-logs \
|
||||
--expr '
|
||||
let
|
||||
gp = builtins.getFlake (toString ./.);
|
||||
hostNixpkgs =
|
||||
builtins.getFlake (builtins.getEnv "NIXPKGS_URL");
|
||||
|
||||
hostSystem = hostNixpkgs.lib.nixosSystem {
|
||||
system = builtins.getEnv "NIX_SYSTEM";
|
||||
modules = [
|
||||
gp.nixosModules.default
|
||||
{
|
||||
programs.globalprotect-openconnect.enable = true;
|
||||
system.stateVersion = "25.11";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
package =
|
||||
hostSystem.config.programs.globalprotect-openconnect.package;
|
||||
in
|
||||
assert builtins.elem package
|
||||
hostSystem.config.environment.systemPackages;
|
||||
assert hostSystem.config.services.ayatana-indicators.enable;
|
||||
package
|
||||
'
|
||||
|
||||
- name: Inspect module package
|
||||
run: |
|
||||
test -x result/bin/gpclient
|
||||
test -x result/bin/gpauth
|
||||
test -x result/bin/gpservice
|
||||
test -x result/bin/gpgui-helper
|
||||
test -x result/bin/gpgui
|
||||
@@ -1,63 +0,0 @@
|
||||
name: Pre Release
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Build"]
|
||||
branches: [master]
|
||||
types: [completed]
|
||||
|
||||
jobs:
|
||||
pre-release:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
env:
|
||||
DEBFULLNAME: "Kevin Yue"
|
||||
DEBEMAIL: "[email protected]"
|
||||
|
||||
steps:
|
||||
# Checkout repository and submodules
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Init variables
|
||||
id: vars
|
||||
run: |
|
||||
TAG=$(git tag --sort=-v:refname --list "v[0-9]*" | head -n 1 | cut -c 2-)
|
||||
echo ::set-output name=VERSION::"${TAG}+SNAPSHOT$(date -u +"%Y%m%d%H%M%S")"
|
||||
echo ::set-output name=TAG::${TAG}
|
||||
|
||||
- name: Update debian/changelog
|
||||
run: |
|
||||
sudo apt install devscripts
|
||||
git log --format="%s" v${{ steps.vars.outputs.TAG }}.. | xargs -L1 dch -v ${{ steps.vars.outputs.VERSION }}-1ppa1
|
||||
|
||||
- name: "Archive all"
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install git-archive-all
|
||||
git-archive-all \
|
||||
--force-submodules \
|
||||
--prefix=globalprotect-openconnect-${{ steps.vars.outputs.VERSION }}/ \
|
||||
./globalprotect-openconnect-${{ steps.vars.outputs.VERSION }}.full.tar.gz
|
||||
|
||||
- name: "Debian Packaging"
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install qtbase5-dev libqt5websockets5-dev qtwebengine5-dev qttools5-dev debhelper
|
||||
mkdir build-debian && cd build-debian
|
||||
cp ../*.tar.gz globalprotect-openconnect_${{ steps.vars.outputs.VERSION }}.orig.tar.gz
|
||||
tar xf *.tar.gz
|
||||
cd globalprotect-openconnect-${{ steps.vars.outputs.VERSION }}
|
||||
fakeroot dpkg-buildpackage -uc -us -sa
|
||||
|
||||
- uses: "marvinpinto/action-automatic-releases@latest"
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
automatic_release_tag: "latest"
|
||||
prerelease: true
|
||||
title: "globalprotect-openconnect_${{ steps.vars.outputs.VERSION }}"
|
||||
files: |
|
||||
*.tar.gz
|
||||
build-debian/*.deb
|
||||
@@ -0,0 +1,175 @@
|
||||
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 \
|
||||
cargo \
|
||||
curl \
|
||||
desktop-file-utils \
|
||||
file \
|
||||
git \
|
||||
libappindicator-gtk3 \
|
||||
libsecret \
|
||||
libxml2 \
|
||||
namcap \
|
||||
openconnect \
|
||||
openssl \
|
||||
pkgconf \
|
||||
librsvg \
|
||||
shared-mime-info \
|
||||
vpnc \
|
||||
wget \
|
||||
webkit2gtk-4.1
|
||||
|
||||
- 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,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}"
|
||||
@@ -1,61 +0,0 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v2
|
||||
with:
|
||||
version: 5.12.11
|
||||
modules: 'qtwebengine qtwebsockets'
|
||||
|
||||
# Checkout repository and submodules
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
qmake CONFIG+=release
|
||||
make
|
||||
|
||||
aur-publish:
|
||||
needs:
|
||||
- build
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get latest version
|
||||
id: get-version
|
||||
run: |
|
||||
echo ::set-output name=VERSION::$(git tag --sort=-v:refname --list "v[0-9]*" | head -n 1 | cut -c 2-)
|
||||
|
||||
- name: Get the sha256sum
|
||||
id: get-sha256sum
|
||||
run: |
|
||||
echo ::set-output name=SHA::$(curl -L https://github.com/yuezk/GlobalProtect-openconnect/archive/refs/tags/v${{ steps.get-version.outputs.VERSION }}.tar.gz | sha256sum | cut -f1 -d" ")
|
||||
|
||||
- name: Generate PKGBUILD
|
||||
run: |
|
||||
sed "s/{PKG_VERSION}/${{ steps.get-version.outputs.VERSION }}/g;s/{SOURCE_SHA}/${{ steps.get-sha256sum.outputs.SHA }}/g" PKGBUILD.template > PKGBUILD
|
||||
|
||||
- name: Publish AUR package
|
||||
uses: KSXGitHub/[email protected]
|
||||
with:
|
||||
pkgname: globalprotect-openconnect
|
||||
pkgbuild: ./PKGBUILD
|
||||
commit_username: ${{ secrets.AUR_USERNAME }}
|
||||
commit_email: ${{ secrets.AUR_EMAIL }}
|
||||
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
commit_message: 'Release v${{ steps.get-version.outputs.VERSION }}'
|
||||
force_push: true
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Release infrastructure checks
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- 'scripts/wait-for-publication.py'
|
||||
- 'scripts/select-publication-targets.py'
|
||||
- 'scripts/verify-docker-publication.sh'
|
||||
- 'scripts/tests/test_*publication.py'
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- 'scripts/wait-for-publication.py'
|
||||
- 'scripts/select-publication-targets.py'
|
||||
- 'scripts/verify-docker-publication.sh'
|
||||
- 'scripts/tests/test_*publication.py'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
release-checks:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Validate workflow expressions and schema
|
||||
run: |
|
||||
docker run --rm -v "$PWD:/repo" -w /repo \
|
||||
rhysd/actionlint:1.7.12@sha256:b1934ee5f1c509618f2508e6eb47ee0d3520686341fec936f3b79331f9315667 \
|
||||
-shellcheck='' -pyflakes=''
|
||||
- name: Check Docker publication script
|
||||
run: |
|
||||
bash -n scripts/verify-docker-publication.sh
|
||||
shellcheck scripts/verify-docker-publication.sh
|
||||
- name: Test publication verification
|
||||
run: python3 -m unittest discover -s scripts/tests -p 'test_*publication.py'
|
||||
@@ -0,0 +1,342 @@
|
||||
name: GH Release Packages
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag to release'
|
||||
required: true
|
||||
arch:
|
||||
type: choice
|
||||
description: 'Architecture to build'
|
||||
required: true
|
||||
default: all
|
||||
options:
|
||||
- all
|
||||
- x86_64
|
||||
- arm64
|
||||
release-deb:
|
||||
type: boolean
|
||||
description: 'Build DEB package'
|
||||
required: true
|
||||
default: true
|
||||
release-rpm:
|
||||
type: boolean
|
||||
description: 'Build RPM package'
|
||||
required: true
|
||||
default: true
|
||||
release-pkg:
|
||||
type: boolean
|
||||
description: 'Build PKG package'
|
||||
required: true
|
||||
default: true
|
||||
release-apk:
|
||||
type: boolean
|
||||
description: 'Build APK package'
|
||||
required: true
|
||||
default: true
|
||||
release-binary:
|
||||
type: boolean
|
||||
description: 'Build binary package'
|
||||
required: true
|
||||
default: true
|
||||
release-docker:
|
||||
type: boolean
|
||||
description: 'Publish Docker image'
|
||||
required: true
|
||||
default: true
|
||||
gh-release:
|
||||
type: boolean
|
||||
description: 'Update GitHub release'
|
||||
required: true
|
||||
default: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check tag exists
|
||||
uses: mukunku/[email protected]
|
||||
id: check-tag
|
||||
with:
|
||||
tag: ${{ inputs.tag }}
|
||||
- name: Exit if tag does not exist
|
||||
run: |
|
||||
if [[ "${{ steps.check-tag.outputs.exists }}" == "false" ]]; then
|
||||
echo "Tag ${{ inputs.tag }} does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
setup-matrix:
|
||||
needs:
|
||||
- check
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.result }}
|
||||
steps:
|
||||
- name: Set up matrix
|
||||
id: set-matrix
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
const inputs = ${{ toJson(inputs) }}
|
||||
const { arch } = inputs
|
||||
const osMap = {
|
||||
"all": ["ubuntu-latest", "ubuntu-24.04-arm"],
|
||||
"x86_64": ["ubuntu-latest"],
|
||||
"arm64": ["ubuntu-24.04-arm"]
|
||||
}
|
||||
|
||||
const package = Object.entries(inputs)
|
||||
.filter(([key, value]) => key.startsWith('release-') && key !== 'release-docker' && value)
|
||||
.map(([key, value]) => key.replace('release-', ''))
|
||||
|
||||
return JSON.stringify({
|
||||
os: osMap[arch],
|
||||
package,
|
||||
})
|
||||
|
||||
build:
|
||||
needs:
|
||||
- setup-matrix
|
||||
strategy:
|
||||
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Prepare workspace
|
||||
run: rm -rf build-${{ matrix.package }} && mkdir -p build-${{ matrix.package }}
|
||||
|
||||
- name: Download ${{ inputs.tag }} source code
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
run: |
|
||||
gh -R yuezk/GlobalProtect-openconnect \
|
||||
release download ${{ inputs.tag }} \
|
||||
--pattern '*[^offline].tar.gz' \
|
||||
--dir build-${{ matrix.package }}
|
||||
|
||||
- name: Build ${{ matrix.package }} package in Docker
|
||||
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
||||
run: |
|
||||
docker run --rm \
|
||||
-v $(pwd)/build-${{ matrix.package }}:/workspace \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-e LIBXML2_STATIC=1 \
|
||||
-e INCLUDE_GUI=1 \
|
||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
|
||||
|
||||
- name: Install ${{ matrix.package }} package in Docker
|
||||
run: |
|
||||
docker run --rm \
|
||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||
-v $(pwd)/build-${{ matrix.package }}:/workspace \
|
||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
|
||||
bash install.sh
|
||||
|
||||
- name: Upload ${{ matrix.package }} package
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: artifact-${{ matrix.os }}-${{ matrix.package }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
build-${{ matrix.package }}/artifacts/*
|
||||
|
||||
build-docker-image:
|
||||
needs:
|
||||
- check
|
||||
if: ${{ inputs.release-docker }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- runner: ubuntu-latest
|
||||
platform: linux/amd64
|
||||
- runner: ubuntu-24.04-arm
|
||||
platform: linux/arm64
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Prepare
|
||||
run: |
|
||||
platform=${{ matrix.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
|
||||
- name: Prepare workspace
|
||||
run: rm -rf docker-image && mkdir -p docker-image/source
|
||||
|
||||
- name: Download ${{ inputs.tag }} source code
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
run: |
|
||||
gh -R yuezk/GlobalProtect-openconnect \
|
||||
release download ${{ inputs.tag }} \
|
||||
--pattern '*[^offline].tar.gz' \
|
||||
--dir docker-image
|
||||
tar -xzf docker-image/*.tar.gz -C docker-image/source --strip-components=1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
- name: Build and push by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: docker-image/source
|
||||
file: docker-image/source/packaging/docker/alpine/Dockerfile
|
||||
platforms: ${{ matrix.platform }}
|
||||
outputs: type=image,name=yuezk/globalprotect-openconnect,push-by-digest=true,name-canonical=true,push=true
|
||||
- name: Verify CLI tools
|
||||
env:
|
||||
IMAGE: yuezk/globalprotect-openconnect
|
||||
DIGEST: ${{ steps.build.outputs.digest }}
|
||||
run: |
|
||||
docker run --rm "$IMAGE@$DIGEST" --help
|
||||
docker run --rm --entrypoint gpauth "$IMAGE@$DIGEST" --help
|
||||
docker run --rm --entrypoint sh "$IMAGE@$DIGEST" -lc 'test "$(id -u gp)" = "1000" && test "$SUDO_UID" = "1000"'
|
||||
- name: Export digest
|
||||
run: |
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: digests-${{ env.PLATFORM_PAIR }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
publish-docker-image:
|
||||
needs:
|
||||
- build-docker-image
|
||||
if: ${{ inputs.release-docker }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digests-*
|
||||
merge-multiple: true
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
- name: Publish Docker manifest
|
||||
working-directory: /tmp/digests
|
||||
env:
|
||||
IMAGE: yuezk/globalprotect-openconnect
|
||||
TAG: ${{ inputs.tag }}
|
||||
run: |
|
||||
VERSION="${TAG#v}"
|
||||
tags=(-t "$IMAGE:$TAG")
|
||||
|
||||
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
tags+=(-t "$IMAGE:$VERSION" -t "$IMAGE:latest")
|
||||
fi
|
||||
|
||||
docker buildx imagetools create "${tags[@]}" \
|
||||
$(printf "$IMAGE@sha256:%s " *)
|
||||
|
||||
"$GITHUB_WORKSPACE/scripts/verify-docker-publication.sh" "$IMAGE:$TAG" /tmp/digests "${{ inputs.arch }}"
|
||||
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
for alias in "$VERSION" latest; do
|
||||
"$GITHUB_WORKSPACE/scripts/verify-docker-publication.sh" "$IMAGE:$alias" /tmp/digests "${{ inputs.arch }}"
|
||||
done
|
||||
fi
|
||||
|
||||
gh-release:
|
||||
needs:
|
||||
- build
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ inputs.gh-release }}
|
||||
outputs:
|
||||
stable_version: ${{ steps.stable-release.outputs.version }}
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
id-token: write
|
||||
attestations: write
|
||||
artifact-metadata: write
|
||||
steps:
|
||||
- name: Prepare workspace
|
||||
run: rm -rf gh-release && mkdir gh-release
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
repository: yuezk/GlobalProtect-openconnect
|
||||
ref: ${{ github.ref }}
|
||||
path: gh-release/gp
|
||||
submodules: recursive
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: gh-release
|
||||
- name: Rename APK artifacts
|
||||
run: |
|
||||
shopt -s nullglob
|
||||
|
||||
for file in gh-release/artifact-ubuntu-latest-apk/*.apk; do
|
||||
mv "$file" "${file%.apk}-x86_64.apk"
|
||||
done
|
||||
for file in gh-release/artifact-ubuntu-24.04-arm-apk/*.apk; do
|
||||
mv "$file" "${file%.apk}-aarch64.apk"
|
||||
done
|
||||
- name: Generate release asset checksums
|
||||
run: |
|
||||
cd gh-release/gp
|
||||
mkdir -p .build
|
||||
scripts/release-assets.sh all "$GITHUB_WORKSPACE/gh-release" > .build/release-assets.txt
|
||||
if [ ! -s .build/release-assets.txt ]; then
|
||||
echo "No release assets found"
|
||||
exit 1
|
||||
fi
|
||||
while IFS= read -r file; do
|
||||
digest=$(sha256sum "$file" | cut -d ' ' -f 1)
|
||||
printf '%s %s\n' "$digest" "$(basename "$file")"
|
||||
done < .build/release-assets.txt > .build/release-assets.sha256
|
||||
- name: Attest release assets
|
||||
uses: actions/attest-build-provenance@v4
|
||||
with:
|
||||
subject-checksums: gh-release/gp/.build/release-assets.sha256
|
||||
- name: Upload release assets
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_PAT }}
|
||||
run: |
|
||||
mapfile -t files < gh-release/gp/.build/release-assets.txt
|
||||
if [[ "${{ inputs.tag }}" == "snapshot" ]]; then
|
||||
for file in "${files[@]}"; do
|
||||
gh release upload snapshot "$file" --clobber \
|
||||
--repo yuezk/GlobalProtect-openconnect
|
||||
done
|
||||
else
|
||||
gh-release/gp/scripts/upload-release-assets.sh "${{ inputs.tag }}" "${files[@]}"
|
||||
fi
|
||||
|
||||
- name: Resolve stable release version
|
||||
id: stable-release
|
||||
env:
|
||||
TAG: ${{ inputs.tag }}
|
||||
run: |
|
||||
if [[ "$TAG" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
|
||||
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
update-flake-hashes:
|
||||
needs: gh-release
|
||||
if: ${{ inputs.release-binary && inputs.arch == 'all' && needs.gh-release.outputs.stable_version != '' }}
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
uses: ./.github/workflows/update-flake-hashes.yaml
|
||||
with:
|
||||
version: ${{ needs.gh-release.outputs.stable_version }}
|
||||
release_tag: ${{ inputs.tag }}
|
||||
@@ -0,0 +1,148 @@
|
||||
name: Update flake hashes
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
type: string
|
||||
release_tag:
|
||||
required: true
|
||||
type: string
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Release version. Defaults to Cargo.toml workspace version."
|
||||
required: false
|
||||
release_tag:
|
||||
description: "GitHub release tag to fetch assets from. Defaults to v<version>; use snapshot for snapshot assets."
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
update-flake-hashes:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
|
||||
- name: Update Nixpkgs lock
|
||||
run: |
|
||||
nix flake update nixpkgs \
|
||||
--extra-experimental-features "nix-command flakes"
|
||||
|
||||
- name: Update flake hashes
|
||||
env:
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
run: |
|
||||
if [[ -n "$RELEASE_VERSION" ]]; then
|
||||
scripts/update-flake-hashes.sh "$RELEASE_VERSION" "$RELEASE_TAG"
|
||||
else
|
||||
scripts/update-flake-hashes.sh "" "$RELEASE_TAG"
|
||||
fi
|
||||
|
||||
- name: Upload updated flake
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: updated-flake
|
||||
path: |
|
||||
flake.nix
|
||||
flake.lock
|
||||
if-no-files-found: error
|
||||
|
||||
validate-nix-prebuilt:
|
||||
needs:
|
||||
- update-flake-hashes
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
runner:
|
||||
- ubuntu-latest
|
||||
- ubuntu-24.04-arm
|
||||
nixpkgs:
|
||||
- locked
|
||||
- nixos-25.11
|
||||
- nixos-26.05
|
||||
- nixpkgs-unstable
|
||||
exclude:
|
||||
- runner: ubuntu-24.04-arm
|
||||
nixpkgs: locked
|
||||
name: validate-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }})
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Download updated flake
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: updated-flake
|
||||
path: .
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
|
||||
- name: Build prebuilt Nix package
|
||||
env:
|
||||
NIXPKGS: ${{ matrix.nixpkgs }}
|
||||
run: |
|
||||
if [[ "$NIXPKGS" == "locked" ]]; then
|
||||
nix build .#prebuilt \
|
||||
--extra-experimental-features "nix-command flakes" \
|
||||
--print-build-logs
|
||||
else
|
||||
nix build .#prebuilt \
|
||||
--override-input nixpkgs "github:NixOS/nixpkgs/$NIXPKGS" \
|
||||
--extra-experimental-features "nix-command flakes" \
|
||||
--print-build-logs
|
||||
fi
|
||||
|
||||
- name: Inspect prebuilt Nix package
|
||||
run: |
|
||||
test -x result/bin/gpclient
|
||||
test -x result/bin/gpauth
|
||||
test -x result/bin/gpservice
|
||||
test -x result/bin/gpgui-helper
|
||||
test -x result/bin/gpgui
|
||||
test ! -L result/bin/gpservice
|
||||
test -x result/libexec/gpclient/gp-vpnc-script-installer
|
||||
test -x result/libexec/gpclient/gp-hip-script-installer
|
||||
result/bin/gpclient --version
|
||||
result/bin/gpservice --version
|
||||
result/bin/gpauth --version
|
||||
|
||||
if grep -R '/usr/bin/gp' result/share; then
|
||||
echo "Desktop assets contain paths outside the Nix package" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Verify desktop authorization runs on the host
|
||||
run: bash scripts/tests/nix-desktop-authorization.sh result
|
||||
|
||||
open-pull-request:
|
||||
needs:
|
||||
- validate-nix-prebuilt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout GlobalProtect-openconnect
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Download updated flake
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: updated-flake
|
||||
path: .
|
||||
|
||||
- name: Open pull request
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION" "$RELEASE_TAG"
|
||||
@@ -1,67 +1,18 @@
|
||||
# Binaries
|
||||
gpclient
|
||||
gpservice
|
||||
|
||||
*.rpm
|
||||
*.gz
|
||||
.idea
|
||||
.DS_Store
|
||||
build-debian
|
||||
/target
|
||||
.pnpm-store
|
||||
.env
|
||||
.vendor
|
||||
*.tar.xz
|
||||
|
||||
# Auto generated DBus files
|
||||
*_adaptor.cpp
|
||||
*_adaptor.h
|
||||
.cargo
|
||||
.build
|
||||
SNAPSHOT
|
||||
SOURCE_COMMIT
|
||||
|
||||
gpservice_interface.*
|
||||
# Tauri generated files
|
||||
gen
|
||||
|
||||
# C++ objects and libs
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.a
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.so.*
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
*_plugin_import.cpp
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
*.qbs.user
|
||||
*.qbs.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
*.qmlc
|
||||
*.jsc
|
||||
Makefile*
|
||||
*build-*
|
||||
*.qm
|
||||
*.prl
|
||||
|
||||
# Qt unit tests
|
||||
target_wrapper.*
|
||||
|
||||
# QtCreator
|
||||
*.autosave
|
||||
|
||||
# QtCreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# QtCreator 4.8< compilation database
|
||||
compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
*creator.user*
|
||||
# Nix files
|
||||
result
|
||||
@@ -1,7 +1,7 @@
|
||||
[submodule "singleapplication"]
|
||||
path = singleapplication
|
||||
url = https://github.com/itay-grudev/SingleApplication.git
|
||||
|
||||
[submodule "plog"]
|
||||
path = 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",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"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": {
|
||||
"unistd.h": "c",
|
||||
"utsname.h": "c",
|
||||
"vpn.h": "c",
|
||||
"openconnect.h": "c"
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
|
||||
members = [
|
||||
"crates/*",
|
||||
"apps/gpclient",
|
||||
"apps/gpservice",
|
||||
"apps/gpauth",
|
||||
"apps/gpgui-helper/src-tauri",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
rust-version = "1.91"
|
||||
version = "3.0.4"
|
||||
authors = ["Kevin Yue <[email protected]>"]
|
||||
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
||||
edition = "2024"
|
||||
license = "GPL-3.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
anyhow = "1.0"
|
||||
askama = "0.16"
|
||||
base64 = "0.22"
|
||||
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"
|
||||
regex = "1"
|
||||
reqwest = { version = "0.13", default-features = false, features = ["native-tls", "charset", "http2", "system-proxy", "json", "form", "query"] }
|
||||
openssl = "0.10"
|
||||
pem = "3"
|
||||
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 = "0.38.4"
|
||||
tempfile = "3.8"
|
||||
tokio = { version = "1" }
|
||||
tokio-util = "0.7"
|
||||
url = "2.4"
|
||||
urlencoding = "2.1.3"
|
||||
axum = "0.8"
|
||||
futures = "0.3"
|
||||
futures-util = "0.3"
|
||||
uzers = "0.12"
|
||||
whoami = "2"
|
||||
thiserror = "2"
|
||||
redact-engine = "0.1"
|
||||
compile-time = "0.2"
|
||||
serde_urlencoded = "0.7"
|
||||
md5 = "0.8"
|
||||
sha256 = "1"
|
||||
which = "8"
|
||||
uuid = "1"
|
||||
netdev = "0.46.3"
|
||||
humantime = "2"
|
||||
snow = { version = "0.10", default-features = false, features = ["std", "use-getrandom", "use-curve25519", "use-chacha20poly1305", "use-sha2"] }
|
||||
zeroize = "1"
|
||||
|
||||
# Tauri dependencies
|
||||
tauri = { version = "2" }
|
||||
specta = "=2.0.0-rc.20"
|
||||
proptest = "1"
|
||||
|
||||
[patch.crates-io]
|
||||
# Restore BSD GTK resize hit testing until https://github.com/tauri-apps/tao/pull/1356 is released.
|
||||
tao = { git = "https://github.com/yuezk/tao", rev = "1452ae7a42c9f134296ba199f91f514fc9077f61" }
|
||||
# Use one macro source for Tao and Wry so Cargo can vendor the workspace.
|
||||
tao-macros = { git = "https://github.com/yuezk/tao", rev = "1452ae7a42c9f134296ba199f91f514fc9077f61" }
|
||||
|
||||
[profile.release]
|
||||
opt-level = 'z' # Optimize for size
|
||||
lto = true # Enable link-time optimization
|
||||
codegen-units = 1 # Reduce number of codegen units to increase optimizations
|
||||
panic = 'abort' # Abort on panic
|
||||
strip = true # Strip symbols from binary*
|
||||
@@ -1,83 +0,0 @@
|
||||
TARGET = gpclient
|
||||
|
||||
QT += core gui network websockets dbus webenginewidgets
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
include(../singleapplication/singleapplication.pri)
|
||||
DEFINES += QAPPLICATION_CLASS=QApplication
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
INCLUDEPATH += ../plog/include
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
SOURCES += \
|
||||
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
|
||||
|
||||
HEADERS += \
|
||||
cdpcommand.h \
|
||||
cdpcommandmanager.h \
|
||||
enhancedwebview.h \
|
||||
gatewayauthenticator.h \
|
||||
gatewayauthenticatorparams.h \
|
||||
gpgateway.h \
|
||||
gphelper.h \
|
||||
loginparams.h \
|
||||
normalloginwindow.h \
|
||||
portalauthenticator.h \
|
||||
portalconfigresponse.h \
|
||||
preloginresponse.h \
|
||||
samlloginwindow.h \
|
||||
gpclient.h \
|
||||
settingsdialog.h
|
||||
|
||||
FORMS += \
|
||||
gpclient.ui \
|
||||
normalloginwindow.ui \
|
||||
settingsdialog.ui
|
||||
|
||||
DBUS_INTERFACES += ../GPService/gpservice.xml
|
||||
|
||||
# Default rules for deployment.
|
||||
target.path = /usr/bin
|
||||
INSTALLS += target
|
||||
|
||||
DISTFILES += \
|
||||
com.yuezk.qt.GPClient.svg \
|
||||
com.yuezk.qt.gpclient.desktop
|
||||
|
||||
desktop_entry.path = /usr/share/applications/
|
||||
desktop_entry.files = com.yuezk.qt.gpclient.desktop
|
||||
|
||||
desktop_icon.path = /usr/share/pixmaps/
|
||||
desktop_icon.files = com.yuezk.qt.GPClient.svg
|
||||
|
||||
INSTALLS += desktop_entry desktop_icon
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "cdpcommand.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
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 <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,86 +0,0 @@
|
||||
#include "cdpcommandmanager.h"
|
||||
#include <QVariantMap>
|
||||
#include <plog/Log.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,39 +0,0 @@
|
||||
#ifndef CDPCOMMANDMANAGER_H
|
||||
#define CDPCOMMANDMANAGER_H
|
||||
|
||||
#include "cdpcommand.h"
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QtWebSockets>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
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,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 |
@@ -1,11 +0,0 @@
|
||||
[Desktop Entry]
|
||||
|
||||
Type=Application
|
||||
Version=1.0.0
|
||||
Name=GlobalProtect VPN
|
||||
Comment=GlobalProtect VPN client, supports SAML auth mode
|
||||
Exec=/usr/bin/gpclient
|
||||
Icon=com.yuezk.qt.GPClient
|
||||
Categories=Network;VPN;Utility;Qt;
|
||||
Keywords=GlobalProtect;Openconnect;SAML;connection;VPN;
|
||||
StartupWMClass=gpclient
|
||||
|
Before Width: | Height: | Size: 18 KiB |
@@ -1,36 +0,0 @@
|
||||
#include "enhancedwebview.h"
|
||||
#include "cdpcommandmanager.h"
|
||||
|
||||
#include <QtWebEngineWidgets/QWebEngineView>
|
||||
#include <QProcessEnvironment>
|
||||
|
||||
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,29 +0,0 @@
|
||||
#ifndef ENHANCEDWEBVIEW_H
|
||||
#define ENHANCEDWEBVIEW_H
|
||||
|
||||
#include "cdpcommandmanager.h"
|
||||
#include <QtWebEngineWidgets/QWebEngineView>
|
||||
|
||||
#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,184 +0,0 @@
|
||||
#include "gatewayauthenticator.h"
|
||||
#include "gphelper.h"
|
||||
#include "loginparams.h"
|
||||
#include "preloginresponse.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <plog/Log.h>
|
||||
|
||||
using namespace gpclient::helper;
|
||||
|
||||
GatewayAuthenticator::GatewayAuthenticator(const QString& gateway, const 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;
|
||||
loginParams.setUser(params.username());
|
||||
loginParams.setPassword(params.password());
|
||||
loginParams.setUserAuthCookie(params.userAuthCookie());
|
||||
|
||||
if (!params.clientos().isEmpty()) {
|
||||
loginParams.setClientos(params.clientos());
|
||||
}
|
||||
|
||||
login(loginParams);
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::login(const LoginParams ¶ms)
|
||||
{
|
||||
PLOGI << "Trying to login the gateway at " << loginUrl << " with " << params.toUtf8();
|
||||
|
||||
QNetworkReply *reply = createRequest(loginUrl, params.toUtf8());
|
||||
connect(reply, &QNetworkReply::finished, this, &GatewayAuthenticator::onLoginFinished);
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::onLoginFinished()
|
||||
{
|
||||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||
QByteArray response;
|
||||
|
||||
if (reply->error() || (response = reply->readAll()).contains("Authentication failure")) {
|
||||
PLOGE << QString("Failed to login the gateway at %1, %2").arg(loginUrl).arg(reply->errorString());
|
||||
|
||||
if (normalLoginWindow) {
|
||||
normalLoginWindow->setProcessing(false);
|
||||
openMessageBox("Gateway login failed.", "Please check your credentials and try again.");
|
||||
} else {
|
||||
doAuth();
|
||||
}
|
||||
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).arg(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).arg(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).arg(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);
|
||||
LoginParams params;
|
||||
params.setUser(username);
|
||||
params.setPassword(password);
|
||||
login(params);
|
||||
}
|
||||
|
||||
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, &GatewayAuthenticator::onSAMLLoginSuccess);
|
||||
connect(loginWindow, &SAMLLoginWindow::fail, this, &GatewayAuthenticator::onSAMLLoginFail);
|
||||
connect(loginWindow, &SAMLLoginWindow::rejected, this, &GatewayAuthenticator::onLoginWindowRejected);
|
||||
|
||||
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 params;
|
||||
params.setUser(samlResult.value("username"));
|
||||
params.setPreloginCookie(samlResult.value("preloginCookie"));
|
||||
params.setUserAuthCookie(samlResult.value("userAuthCookie"));
|
||||
|
||||
login(params);
|
||||
}
|
||||
|
||||
void GatewayAuthenticator::onSAMLLoginFail(const QString msg)
|
||||
{
|
||||
emit fail(msg);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
#ifndef GATEWAYAUTHENTICATOR_H
|
||||
#define GATEWAYAUTHENTICATOR_H
|
||||
|
||||
#include "normalloginwindow.h"
|
||||
#include "loginparams.h"
|
||||
#include "gatewayauthenticatorparams.h"
|
||||
#include <QObject>
|
||||
|
||||
class GatewayAuthenticator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GatewayAuthenticator(const QString& gateway, const 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;
|
||||
const GatewayAuthenticatorParams& params;
|
||||
QString preloginUrl;
|
||||
QString loginUrl;
|
||||
|
||||
NormalLoginWindow *normalLoginWindow{ nullptr };
|
||||
|
||||
void login(const LoginParams& params);
|
||||
void doAuth();
|
||||
void normalAuth(QString labelUsername, QString labelPassword, QString authMessage);
|
||||
void samlAuth(QString samlMethod, QString samlRequest, QString preloginUrl = "");
|
||||
};
|
||||
|
||||
#endif // GATEWAYAUTHENTICATOR_H
|
||||
@@ -1,57 +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;
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef GATEWAYAUTHENTICATORPARAMS_H
|
||||
#define GATEWAYAUTHENTICATORPARAMS_H
|
||||
|
||||
#include <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);
|
||||
|
||||
private:
|
||||
QString m_username;
|
||||
QString m_password;
|
||||
QString m_userAuthCookie;
|
||||
QString m_clientos;
|
||||
};
|
||||
|
||||
#endif // GATEWAYAUTHENTICATORPARAMS_H
|
||||
@@ -1,490 +0,0 @@
|
||||
#include "gpclient.h"
|
||||
#include "gphelper.h"
|
||||
#include "ui_gpclient.h"
|
||||
#include "portalauthenticator.h"
|
||||
#include "gatewayauthenticator.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "gatewayauthenticatorparams.h"
|
||||
|
||||
#include <plog/Log.h>
|
||||
#include <QIcon>
|
||||
|
||||
using namespace gpclient::helper;
|
||||
|
||||
GPClient::GPClient(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::GPClient)
|
||||
, settingsDialog(new SettingsDialog(this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowTitle("GlobalProtect");
|
||||
setFixedSize(width(), height());
|
||||
gpclient::helper::moveCenter(this);
|
||||
|
||||
setupSettings();
|
||||
|
||||
// Restore portal from the previous settings
|
||||
ui->portalInput->setText(settings::get("portal", "").toString());
|
||||
|
||||
// DBus service setup
|
||||
vpn = new com::yuezk::qt::GPService("com.yuezk.qt.GPService", "/", QDBusConnection::systemBus(), this);
|
||||
connect(vpn, &com::yuezk::qt::GPService::connected, this, &GPClient::onVPNConnected);
|
||||
connect(vpn, &com::yuezk::qt::GPService::disconnected, this, &GPClient::onVPNDisconnected);
|
||||
connect(vpn, &com::yuezk::qt::GPService::error, this, &GPClient::onVPNError);
|
||||
connect(vpn, &com::yuezk::qt::GPService::logAvailable, this, &GPClient::onVPNLogAvailable);
|
||||
|
||||
// Initiallize 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.svg"));
|
||||
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->setExtraArgs(settings::get("extraArgs", "").toString());
|
||||
settingsDialog->setClientos(settings::get("clientos", "").toString());
|
||||
settingsDialog->show();
|
||||
}
|
||||
|
||||
void GPClient::onSettingsAccepted()
|
||||
{
|
||||
settings::save("extraArgs", settingsDialog->extraArgs());
|
||||
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), g.name())->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", "").toString());
|
||||
|
||||
connect(portalAuth, &PortalAuthenticator::success, this, &GPClient::onPortalSuccess);
|
||||
// Prelogin failed on the portal interface, try to treat the portal as a gateway interface
|
||||
connect(portalAuth, &PortalAuthenticator::preloginFailed, this, &GPClient::onPortalPreloginFail);
|
||||
connect(portalAuth, &PortalAuthenticator::portalConfigFailed, this, &GPClient::onPortalConfigFail);
|
||||
// Portal login failed
|
||||
connect(portalAuth, &PortalAuthenticator::fail, this, &GPClient::onPortalFail);
|
||||
|
||||
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", "").toString());
|
||||
|
||||
GatewayAuthenticator *gatewayAuth = new GatewayAuthenticator(currentGateway().address(), params);
|
||||
|
||||
connect(gatewayAuth, &GatewayAuthenticator::success, this, &GPClient::onGatewaySuccess);
|
||||
connect(gatewayAuth, &GatewayAuthenticator::fail, this, &GPClient::onGatewayFail);
|
||||
|
||||
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;
|
||||
vpn->connect(currentGateway().address(), portalConfig.username(), authCookie, settings::get("extraArgs", "").toString());
|
||||
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;
|
||||
}
|
||||
|
||||
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,102 +0,0 @@
|
||||
#ifndef GPCLIENT_H
|
||||
#define GPCLIENT_H
|
||||
|
||||
#include "gpservice_interface.h"
|
||||
#include "portalconfigresponse.h"
|
||||
#include "settingsdialog.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class GPClient; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class GPClient : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GPClient(QWidget *parent = nullptr);
|
||||
~GPClient();
|
||||
|
||||
void activate();
|
||||
|
||||
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;
|
||||
com::yuezk::qt::GPService *vpn;
|
||||
|
||||
QSystemTrayIcon *systemTrayIcon;
|
||||
QMenu *contextMenu;
|
||||
QAction *openAction;
|
||||
QAction *connectAction;
|
||||
|
||||
QMenu *gatewaySwitchMenu;
|
||||
QAction *clearAction;
|
||||
QAction *quitAction;
|
||||
|
||||
SettingsDialog *settingsDialog;
|
||||
QPushButton *settingsButton;
|
||||
|
||||
bool isQuickConnect { false };
|
||||
bool isSwitchingGateway { false };
|
||||
PortalConfigResponse portalConfig;
|
||||
|
||||
void setupSettings();
|
||||
|
||||
void initSystemTrayIcon();
|
||||
void initVpnStatus();
|
||||
void populateGatewayMenu();
|
||||
void updateConnectionStatus(const VpnStatus &status);
|
||||
|
||||
void doConnect();
|
||||
void portalLogin();
|
||||
void tryGatewayLogin();
|
||||
void gatewayLogin();
|
||||
|
||||
QString portal() const;
|
||||
bool connected() const;
|
||||
|
||||
QList<GPGateway> allGateways() const;
|
||||
void setAllGateways(QList<GPGateway> gateways);
|
||||
|
||||
GPGateway currentGateway() const;
|
||||
void setCurrentGateway(const GPGateway gateway);
|
||||
|
||||
void clearSettings();
|
||||
void quit();
|
||||
};
|
||||
#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 "gpgateway.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
||||
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 <QString>
|
||||
#include <QMap>
|
||||
#include <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,128 +0,0 @@
|
||||
#include "gphelper.h"
|
||||
#include <QNetworkRequest>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QSslConfiguration>
|
||||
#include <QSslSocket>
|
||||
#include <plog/Log.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);
|
||||
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 "samlloginwindow.h"
|
||||
#include "gpgateway.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QUrlQuery>
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
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,74 +0,0 @@
|
||||
#include "loginparams.h"
|
||||
|
||||
#include <QUrlQuery>
|
||||
|
||||
LoginParams::LoginParams()
|
||||
{
|
||||
params.addQueryItem("prot", QUrl::toPercentEncoding("https:"));
|
||||
params.addQueryItem("server", "");
|
||||
params.addQueryItem("inputSrc", "");
|
||||
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()));
|
||||
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::setClientos(const QString clientos)
|
||||
{
|
||||
updateQueryItem("clientos", clientos);
|
||||
}
|
||||
|
||||
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 <QUrlQuery>
|
||||
|
||||
class LoginParams
|
||||
{
|
||||
public:
|
||||
LoginParams();
|
||||
~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 setClientos(const QString clientos);
|
||||
|
||||
QByteArray toUtf8() const;
|
||||
|
||||
private:
|
||||
QUrlQuery params;
|
||||
|
||||
void updateQueryItem(const QString key, const QString value);
|
||||
};
|
||||
|
||||
#endif // LOGINPARAMS_H
|
||||
@@ -1,39 +0,0 @@
|
||||
#include "singleapplication.h"
|
||||
#include "gpclient.h"
|
||||
#include "enhancedwebview.h"
|
||||
|
||||
#include <QStandardPaths>
|
||||
#include <plog/Log.h>
|
||||
#include <plog/Appenders/ColorConsoleAppender.h>
|
||||
|
||||
static const QString version = "v1.3.1";
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const QDir path = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/GlobalProtect-openconnect";
|
||||
const QString logFile = path.path() + "/gpclient.log";
|
||||
if (!path.exists()) {
|
||||
path.mkpath(".");
|
||||
}
|
||||
|
||||
static plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender;
|
||||
plog::init(plog::debug, logFile.toUtf8()).addAppender(&consoleAppender);
|
||||
|
||||
PLOGI << "GlobalProtect started, version: " << version;
|
||||
|
||||
QString port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT));
|
||||
|
||||
if (port == "") {
|
||||
qputenv(ENV_CDP_PORT, "12315");
|
||||
}
|
||||
|
||||
SingleApplication app(argc, argv);
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
GPClient w;
|
||||
w.show();
|
||||
|
||||
QObject::connect(&app, &SingleApplication::instanceStarted, &w, &GPClient::activate);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#include "normalloginwindow.h"
|
||||
#include "ui_normalloginwindow.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
|
||||
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 <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,209 +0,0 @@
|
||||
#include "portalauthenticator.h"
|
||||
#include "gphelper.h"
|
||||
#include "normalloginwindow.h"
|
||||
#include "samlloginwindow.h"
|
||||
#include "loginparams.h"
|
||||
#include "preloginresponse.h"
|
||||
#include "portalconfigresponse.h"
|
||||
#include "gpgateway.h"
|
||||
|
||||
#include <plog/Log.h>
|
||||
#include <QNetworkReply>
|
||||
|
||||
using namespace gpclient::helper;
|
||||
|
||||
PortalAuthenticator::PortalAuthenticator(const QString& portal, const QString& clientos) : QObject()
|
||||
, portal(portal)
|
||||
, 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).arg(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 params;
|
||||
params.setServer(portal);
|
||||
params.setUser(username);
|
||||
params.setPassword(password);
|
||||
params.setPreloginCookie(preloginCookie);
|
||||
params.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, params.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...";
|
||||
|
||||
// Save the credentials for reuse
|
||||
settings::save("username", username);
|
||||
settings::save("password", password);
|
||||
normalLoginWindow->close();
|
||||
}
|
||||
|
||||
emit success(response, preloginResponse.region());
|
||||
}
|
||||
|
||||
void PortalAuthenticator::emitFail(const QString& msg)
|
||||
{
|
||||
emit fail(msg);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#ifndef PORTALAUTHENTICATOR_H
|
||||
#define PORTALAUTHENTICATOR_H
|
||||
|
||||
#include "portalconfigresponse.h"
|
||||
#include "normalloginwindow.h"
|
||||
#include "samlloginwindow.h"
|
||||
#include "preloginresponse.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
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 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,178 +0,0 @@
|
||||
#include "portalconfigresponse.h"
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <plog/Log.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;
|
||||
QString address = xmlReader.attributes().value("name").toString();
|
||||
g.setAddress(address);
|
||||
g.setPriorityRules(parsePriorityRules(xmlReader));
|
||||
g.setName(parseGatewayName(xmlReader));
|
||||
gateways.append(g);
|
||||
}
|
||||
}
|
||||
|
||||
PLOGI << "Finished parsing the gateways.";
|
||||
|
||||
return gateways;
|
||||
}
|
||||
|
||||
QMap<QString, int> PortalConfigResponse::parsePriorityRules(QXmlStreamReader &xmlReader)
|
||||
{
|
||||
PLOGI << "Start parsing the priority rules...";
|
||||
|
||||
QMap<QString, int> priorityRules;
|
||||
|
||||
while ((xmlReader.name() != "priority-rule" || !xmlReader.isEndElement()) && !xmlReader.hasError()) {
|
||||
xmlReader.readNext();
|
||||
|
||||
if (xmlReader.name() == "entry" && xmlReader.isStartElement()) {
|
||||
QString ruleName = xmlReader.attributes().value("name").toString();
|
||||
// Read the priority tag
|
||||
while (xmlReader.name() != "priority"){
|
||||
xmlReader.readNext();
|
||||
}
|
||||
int ruleValue = xmlReader.readElementText().toUInt();
|
||||
priorityRules.insert(ruleName, ruleValue);
|
||||
}
|
||||
}
|
||||
|
||||
PLOGI << "Finished parsing the priority rules.";
|
||||
|
||||
return priorityRules;
|
||||
}
|
||||
|
||||
QString PortalConfigResponse::parseGatewayName(QXmlStreamReader &xmlReader)
|
||||
{
|
||||
PLOGI << "Start parsing the gateway name...";
|
||||
|
||||
while (xmlReader.name() != "description" || !xmlReader.isEndElement()) {
|
||||
xmlReader.readNext();
|
||||
if (xmlReader.name() == "description" && xmlReader.tokenType() == xmlReader.StartElement) {
|
||||
PLOGI << "Finished parsing the gateway name";
|
||||
return xmlReader.readElementText();
|
||||
}
|
||||
}
|
||||
|
||||
PLOGE << "Error: <description> tag not found";
|
||||
return "";
|
||||
}
|
||||
|
||||
QString PortalConfigResponse::userAuthCookie() const
|
||||
{
|
||||
return m_userAuthCookie;
|
||||
}
|
||||
|
||||
QString PortalConfigResponse::prelogonUserAuthCookie() const
|
||||
{
|
||||
return m_prelogonAuthCookie;
|
||||
}
|
||||
|
||||
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 "gpgateway.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
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;
|
||||
QString prelogonUserAuthCookie() 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 QMap<QString, int> parsePriorityRules(QXmlStreamReader &xmlReader);
|
||||
static QString parseGatewayName(QXmlStreamReader &xmlReader);
|
||||
};
|
||||
|
||||
#endif // PORTALCONFIGRESPONSE_H
|
||||
@@ -1,100 +0,0 @@
|
||||
#include "preloginresponse.h"
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QMap>
|
||||
#include <plog/Log.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 <QString>
|
||||
#include <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.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,99 +0,0 @@
|
||||
#include "samlloginwindow.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <plog/Log.h>
|
||||
#include <QWebEngineProfile>
|
||||
#include <QWebEngineView>
|
||||
|
||||
SAMLLoginWindow::SAMLLoginWindow(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, webView(new EnhancedWebView(this))
|
||||
{
|
||||
setWindowTitle("GlobalProtect SAML Login");
|
||||
setModal(true);
|
||||
resize(700, 550);
|
||||
|
||||
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
||||
webView->setUrl(QUrl("about:blank"));
|
||||
// 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 "enhancedwebview.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
#include <QCloseEvent>
|
||||
|
||||
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
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">
|
||||
<g>
|
||||
<path d="M16.5,19.9C16.5,19.9,16.5,19.9,16.5,19.9l3.1-3.1c0,0,0,0,0,0l2.3-2.3c2.2,0.6,4.5,0,6.2-1.6c1.8-1.8,2.3-4.4,1.4-6.8
|
||||
c-0.1-0.3-0.4-0.5-0.7-0.6c-0.3-0.1-0.7,0-0.9,0.3L25.6,8l-1.3-0.3L24,6.4l2.2-2.2c0.2-0.2,0.3-0.6,0.3-0.9
|
||||
c-0.1-0.3-0.3-0.6-0.6-0.7c-2.3-0.9-5-0.4-6.8,1.4c-1.6,1.6-2.2,4-1.6,6.2l-1.6,1.6l-2.6-2.6L11,5.3c-0.1-0.1-0.2-0.3-0.3-0.3
|
||||
L6.8,2.7C6.4,2.4,5.9,2.5,5.5,2.8L2.5,5.9C2.1,6.2,2.1,6.7,2.3,7.1L4.6,11c0.1,0.1,0.2,0.3,0.3,0.3l3.7,2.2l2.6,2.6l-1.2,1.2
|
||||
c-2.2-0.6-4.5,0-6.2,1.6c-1.8,1.8-2.3,4.4-1.4,6.8c0.1,0.3,0.4,0.5,0.7,0.6c0.3,0.1,0.7,0,0.9-0.3L6.4,24l1.3,0.3L8,25.6l-2.2,2.2
|
||||
c-0.2,0.2-0.3,0.6-0.3,0.9c0.1,0.3,0.3,0.6,0.6,0.7c0.8,0.3,1.5,0.4,2.3,0.4c1.6,0,3.3-0.6,4.5-1.9c1.6-1.6,2.2-4,1.6-6.2
|
||||
L16.5,19.9z"/>
|
||||
<path d="M22.5,16.8l-6,6l6.1,6.1c0.8,0.8,1.9,1.3,3,1.3s2.2-0.4,3-1.3c0.8-0.8,1.3-1.9,1.3-3c0-1.1-0.4-2.2-1.3-3L22.5,16.8z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.2 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 <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,104 +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="placeholderText">
|
||||
<string extracomment="Tokens with spaces can be surrounded by double quotes">e.g. --name=value --script="vpn-slice xxx"</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,52 +0,0 @@
|
||||
TARGET = gpservice
|
||||
|
||||
QT += dbus
|
||||
QT -= gui
|
||||
|
||||
CONFIG += c++11 console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
include(../singleapplication/singleapplication.pri)
|
||||
DEFINES += QAPPLICATION_CLASS=QCoreApplication
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
HEADERS += \
|
||||
gpservice.h \
|
||||
sigwatch.h
|
||||
|
||||
SOURCES += \
|
||||
gpservice.cpp \
|
||||
main.cpp \
|
||||
sigwatch.cpp
|
||||
|
||||
DBUS_ADAPTORS += gpservice.xml
|
||||
|
||||
# Default rules for deployment.
|
||||
target.path = /usr/bin
|
||||
INSTALLS += target
|
||||
|
||||
DISTFILES += \
|
||||
dbus/com.yuezk.qt.GPService.conf \
|
||||
dbus/com.yuezk.qt.GPService.service \
|
||||
systemd/gpservice.service
|
||||
|
||||
dbus_config.path = /usr/share/dbus-1/system.d/
|
||||
dbus_config.files = dbus/com.yuezk.qt.GPService.conf
|
||||
|
||||
dbus_service.path = /usr/share/dbus-1/system-services/
|
||||
dbus_service.files = dbus/com.yuezk.qt.GPService.service
|
||||
|
||||
systemd_service.path = /etc/systemd/system/
|
||||
systemd_service.files = systemd/gpservice.service
|
||||
|
||||
INSTALLS += dbus_config dbus_service systemd_service
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<policy user="root">
|
||||
<allow own="com.yuezk.qt.GPService"/>
|
||||
</policy>
|
||||
|
||||
<policy context="default">
|
||||
<allow send_destination="com.yuezk.qt.GPService"
|
||||
send_interface="com.yuezk.qt.GPService"
|
||||
/>
|
||||
<allow send_destination="com.yuezk.qt.GPService"
|
||||
send_interface="org.freedesktop.DBus.Introspectable"
|
||||
/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
@@ -1,5 +0,0 @@
|
||||
[D-BUS Service]
|
||||
Name=com.yuezk.qt.GPService
|
||||
Exec=/usr/bin/gpservice
|
||||
User=root
|
||||
SystemdService=gpservice.service
|
||||
@@ -1,176 +0,0 @@
|
||||
#include "gpservice.h"
|
||||
#include "gpservice_adaptor.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QtDBus>
|
||||
#include <QDateTime>
|
||||
#include <QVariant>
|
||||
|
||||
GPService::GPService(QObject *parent)
|
||||
: QObject(parent)
|
||||
, openconnect(new QProcess)
|
||||
{
|
||||
// Register the DBus service
|
||||
new GPServiceAdaptor(this);
|
||||
QDBusConnection dbus = QDBusConnection::systemBus();
|
||||
dbus.registerObject("/", this);
|
||||
dbus.registerService("com.yuezk.qt.GPService");
|
||||
|
||||
// Setup the openconnect process
|
||||
QObject::connect(openconnect, &QProcess::started, this, &GPService::onProcessStarted);
|
||||
QObject::connect(openconnect, &QProcess::errorOccurred, this, &GPService::onProcessError);
|
||||
QObject::connect(openconnect, &QProcess::readyReadStandardOutput, this, &GPService::onProcessStdout);
|
||||
QObject::connect(openconnect, &QProcess::readyReadStandardError, this, &GPService::onProcessStderr);
|
||||
QObject::connect(openconnect, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &GPService::onProcessFinished);
|
||||
}
|
||||
|
||||
GPService::~GPService()
|
||||
{
|
||||
delete openconnect;
|
||||
}
|
||||
|
||||
QString GPService::findBinary()
|
||||
{
|
||||
for (int i = 0; i < binaryPaths->length(); i++) {
|
||||
if (QFileInfo::exists(binaryPaths[i])) {
|
||||
return binaryPaths[i];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Port from https://github.com/qt/qtbase/blob/11d1dcc6e263c5059f34b44d531c9ccdf7c0b1d6/src/corelib/io/qprocess.cpp#L2115 */
|
||||
QStringList GPService::splitCommand(QStringView command)
|
||||
{
|
||||
QStringList args;
|
||||
QString tmp;
|
||||
int quoteCount = 0;
|
||||
bool inQuote = false;
|
||||
|
||||
// handle quoting. tokens can be surrounded by double quotes
|
||||
// "hello world". three consecutive double quotes represent
|
||||
// the quote character itself.
|
||||
for (int i = 0; i < command.size(); ++i) {
|
||||
if (command.at(i) == QLatin1Char('"')) {
|
||||
++quoteCount;
|
||||
if (quoteCount == 3) {
|
||||
// third consecutive quote
|
||||
quoteCount = 0;
|
||||
tmp += command.at(i);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (quoteCount) {
|
||||
if (quoteCount == 1)
|
||||
inQuote = !inQuote;
|
||||
quoteCount = 0;
|
||||
}
|
||||
if (!inQuote && command.at(i).isSpace()) {
|
||||
if (!tmp.isEmpty()) {
|
||||
args += tmp;
|
||||
tmp.clear();
|
||||
}
|
||||
} else {
|
||||
tmp += command.at(i);
|
||||
}
|
||||
}
|
||||
if (!tmp.isEmpty())
|
||||
args += tmp;
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
void GPService::quit()
|
||||
{
|
||||
if (openconnect->state() == QProcess::NotRunning) {
|
||||
exit(0);
|
||||
} else {
|
||||
aboutToQuit = true;
|
||||
openconnect->terminate();
|
||||
}
|
||||
}
|
||||
|
||||
void GPService::connect(QString server, QString username, QString passwd, QString extraArgs)
|
||||
{
|
||||
if (vpnStatus != GPService::VpnNotConnected) {
|
||||
log("VPN status is: " + QVariant::fromValue(vpnStatus).toString());
|
||||
return;
|
||||
}
|
||||
|
||||
QString bin = findBinary();
|
||||
if (bin == nullptr) {
|
||||
log("Could not find openconnect binary, make sure openconnect is installed, exiting.");
|
||||
emit error("The OpenConect CLI was not found, make sure it has been installed!");
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList args;
|
||||
args << QCoreApplication::arguments().mid(1)
|
||||
<< "--protocol=gp"
|
||||
<< splitCommand(extraArgs)
|
||||
<< "-u" << username
|
||||
<< "-C" << passwd
|
||||
<< server;
|
||||
|
||||
log("Start process with arugments: " + args.join(" "));
|
||||
|
||||
openconnect->start(bin, args);
|
||||
}
|
||||
|
||||
void GPService::disconnect()
|
||||
{
|
||||
if (openconnect->state() != QProcess::NotRunning) {
|
||||
vpnStatus = GPService::VpnDisconnecting;
|
||||
openconnect->terminate();
|
||||
}
|
||||
}
|
||||
|
||||
int GPService::status()
|
||||
{
|
||||
return vpnStatus;
|
||||
}
|
||||
|
||||
void GPService::onProcessStarted()
|
||||
{
|
||||
log("Openconnect started successfully, PID=" + QString::number(openconnect->processId()));
|
||||
vpnStatus = GPService::VpnConnecting;
|
||||
}
|
||||
|
||||
void GPService::onProcessError(QProcess::ProcessError error)
|
||||
{
|
||||
log("Error occurred: " + QVariant::fromValue(error).toString());
|
||||
vpnStatus = GPService::VpnNotConnected;
|
||||
emit disconnected();
|
||||
}
|
||||
|
||||
void GPService::onProcessStdout()
|
||||
{
|
||||
QString output = openconnect->readAllStandardOutput();
|
||||
|
||||
log(output);
|
||||
if (output.indexOf("Connected as") >= 0) {
|
||||
vpnStatus = GPService::VpnConnected;
|
||||
emit connected();
|
||||
}
|
||||
}
|
||||
|
||||
void GPService::onProcessStderr()
|
||||
{
|
||||
log(openconnect->readAllStandardError());
|
||||
}
|
||||
|
||||
void GPService::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
log("Openconnect process exited with code " + QString::number(exitCode) + " and exit status " + QVariant::fromValue(exitStatus).toString());
|
||||
vpnStatus = GPService::VpnNotConnected;
|
||||
emit disconnected();
|
||||
|
||||
if (aboutToQuit) {
|
||||
exit(0);
|
||||
};
|
||||
}
|
||||
|
||||
void GPService::log(QString msg)
|
||||
{
|
||||
emit logAvailable(msg);
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
#ifndef GLOBALPROTECTSERVICE_H
|
||||
#define GLOBALPROTECTSERVICE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
|
||||
static const QString binaryPaths[] {
|
||||
"/usr/local/bin/openconnect",
|
||||
"/usr/local/sbin/openconnect",
|
||||
"/usr/bin/openconnect",
|
||||
"/usr/sbin/openconnect",
|
||||
"/opt/bin/openconnect",
|
||||
"/opt/sbin/openconnect"
|
||||
};
|
||||
|
||||
class GPService : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "com.yuezk.qt.GPService")
|
||||
public:
|
||||
explicit GPService(QObject *parent = nullptr);
|
||||
~GPService();
|
||||
|
||||
enum VpnStatus {
|
||||
VpnNotConnected,
|
||||
VpnConnecting,
|
||||
VpnConnected,
|
||||
VpnDisconnecting,
|
||||
};
|
||||
|
||||
signals:
|
||||
void connected();
|
||||
void disconnected();
|
||||
void error(QString errorMessage);
|
||||
void logAvailable(QString log);
|
||||
|
||||
public slots:
|
||||
void connect(QString server, QString username, QString passwd, QString extraArgs);
|
||||
void disconnect();
|
||||
int status();
|
||||
void quit();
|
||||
|
||||
private slots:
|
||||
void onProcessStarted();
|
||||
void onProcessError(QProcess::ProcessError error);
|
||||
void onProcessStdout();
|
||||
void onProcessStderr();
|
||||
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
|
||||
private:
|
||||
QProcess *openconnect;
|
||||
bool aboutToQuit = false;
|
||||
int vpnStatus = GPService::VpnNotConnected;
|
||||
|
||||
void log(QString msg);
|
||||
static QString findBinary();
|
||||
static QStringList splitCommand(QStringView command);
|
||||
};
|
||||
|
||||
#endif // GLOBALPROTECTSERVICE_H
|
||||
@@ -1,26 +0,0 @@
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="com.yuezk.qt.GPService">
|
||||
<signal name="connected">
|
||||
</signal>
|
||||
<signal name="disconnected">
|
||||
</signal>
|
||||
<signal name="logAvailable">
|
||||
<arg name="log" type="s" />
|
||||
</signal>
|
||||
<signal name="error">
|
||||
<arg name="errorMessage" type="s" />
|
||||
</signal>
|
||||
<method name="connect">
|
||||
<arg name="server" type="s" direction="in"/>
|
||||
<arg name="username" type="s" direction="in"/>
|
||||
<arg name="passwd" type="s" direction="in"/>
|
||||
<arg name="extraArgs" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="disconnect">
|
||||
</method>
|
||||
<method name="status">
|
||||
<arg type="i" direction="out"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
@@ -1,26 +0,0 @@
|
||||
#include <QtDBus>
|
||||
#include "gpservice.h"
|
||||
#include "singleapplication.h"
|
||||
#include "sigwatch.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SingleApplication app(argc, argv);
|
||||
|
||||
if (!QDBusConnection::systemBus().isConnected()) {
|
||||
qWarning("Cannot connect to the D-Bus session bus.\n"
|
||||
"Please check your system settings and try again.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
GPService service;
|
||||
|
||||
UnixSignalWatcher sigwatch;
|
||||
sigwatch.watchForSignal(SIGINT);
|
||||
sigwatch.watchForSignal(SIGTERM);
|
||||
sigwatch.watchForSignal(SIGQUIT);
|
||||
sigwatch.watchForSignal(SIGHUP);
|
||||
QObject::connect(&sigwatch, &UnixSignalWatcher::unixSignal, &service, &GPService::quit);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -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,11 +0,0 @@
|
||||
[Unit]
|
||||
Description=GlobalProtect openconnect DBus service
|
||||
|
||||
[Service]
|
||||
Environment="LANG=en_US.utf8"
|
||||
Type=dbus
|
||||
BusName=com.yuezk.qt.GPService
|
||||
ExecStart=/usr/bin/gpservice
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,5 +0,0 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
GPClient \
|
||||
GPService
|
||||
@@ -0,0 +1,507 @@
|
||||
SHELL := /bin/sh
|
||||
.SHELLFLAGS := -ec
|
||||
|
||||
INCLUDE_GUI ?= 0
|
||||
CARGO ?= cargo
|
||||
CARGO_TARGET_DIR ?= target
|
||||
CARGO_RELEASE_DIR ?= $(CARGO_TARGET_DIR)/$(if $(CARGO_BUILD_TARGET),$(CARGO_BUILD_TARGET)/)release
|
||||
DISABLE_RUST_TOOLCHAIN ?= 0
|
||||
RUST_VERSION ?= 1.91
|
||||
IGNORE_RUST_VERSION ?= 0
|
||||
|
||||
VERSION = $(shell grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')
|
||||
SOURCE_COMMIT_VALUE := $(shell \
|
||||
if [ -n "$$SOURCE_GIT_COMMIT" ]; then \
|
||||
printf '%s' "$$SOURCE_GIT_COMMIT" | cut -c1-9; \
|
||||
elif [ -n "$$GITHUB_SHA" ]; then \
|
||||
printf '%s' "$$GITHUB_SHA" | cut -c1-9; \
|
||||
elif [ -f SOURCE_COMMIT ]; then \
|
||||
head -n1 SOURCE_COMMIT | tr -d '[:space:]' | cut -c1-9; \
|
||||
else \
|
||||
git rev-parse --short=9 HEAD 2>/dev/null || printf unknown; \
|
||||
fi)
|
||||
GUI_LIBC_SUFFIX ?= $(shell ldd --version 2>&1 | grep -qi musl && echo -musl || true)
|
||||
REVISION ?= 1
|
||||
RPM_SOURCE ?= %{name}.tar.gz
|
||||
|
||||
PPA_REVISION ?= 1
|
||||
PKG_NAME = globalprotect-openconnect
|
||||
PKG = $(PKG_NAME)-$(VERSION)
|
||||
SERIES ?= $(shell lsb_release -cs)
|
||||
PUBLISH ?= 0
|
||||
|
||||
# Indicates whether to build the GUI components
|
||||
BUILD_GUI_HELPER ?= 1
|
||||
|
||||
# Indicates whether to build embedded webview auth support into gpauth
|
||||
BUILD_WEBVIEW_AUTH ?= 1
|
||||
ifeq ($(shell uname -s),Linux)
|
||||
PREFIX ?= /usr
|
||||
GPGUI_BINARY ?= $(wildcard .build/gpgui/gpgui_*/gpgui)
|
||||
else ifeq ($(shell uname -s)-$(shell uname -m),Darwin-arm64)
|
||||
PREFIX ?= /opt/homebrew
|
||||
else
|
||||
PREFIX ?= /usr/local
|
||||
endif
|
||||
BSD_FLAVOR ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||
GPGUI_BINARY ?= ../gpgui/target/release/gpgui
|
||||
|
||||
export DEBEMAIL = [email protected]
|
||||
export DEBFULLNAME = Kevin Yue
|
||||
export SNAPSHOT = $(shell test -f SNAPSHOT && echo "true" || echo "false")
|
||||
export OFFLINE_BUILD = $(shell test -f OFFLINE_BUILD && echo "1" || echo "0")
|
||||
# If OFFLINE is not set, use OFFLINE_BUILD
|
||||
ifndef OFFLINE
|
||||
OFFLINE = $(OFFLINE_BUILD)
|
||||
endif
|
||||
|
||||
ifeq ($(SNAPSHOT), true)
|
||||
RELEASE_TAG = snapshot
|
||||
else
|
||||
RELEASE_TAG = v$(VERSION)
|
||||
endif
|
||||
|
||||
CARGO_BUILD_ARGS = --release
|
||||
|
||||
ifeq ($(OFFLINE), 1)
|
||||
CARGO_BUILD_ARGS += --frozen
|
||||
endif
|
||||
|
||||
ifeq ($(IGNORE_RUST_VERSION), 1)
|
||||
CARGO_BUILD_ARGS += --ignore-rust-version
|
||||
endif
|
||||
|
||||
default: build
|
||||
|
||||
dev-service:
|
||||
./scripts/dev-service.sh
|
||||
|
||||
version:
|
||||
@echo $(VERSION)
|
||||
|
||||
clean-tarball:
|
||||
rm -rf .build/tarball
|
||||
rm -rf .vendor
|
||||
rm -rf vendor.tar.xz
|
||||
rm -rf .cargo
|
||||
rm -f SOURCE_COMMIT
|
||||
|
||||
# Create a tarball, include the cargo dependencies if OFFLINE is set to 1
|
||||
tarball: clean-tarball
|
||||
mkdir -p .cargo
|
||||
mkdir -p .build/tarball
|
||||
printf '%s\n' "$(SOURCE_COMMIT_VALUE)" > SOURCE_COMMIT
|
||||
|
||||
# If OFFLINE is set to 1, vendor all cargo dependencies
|
||||
# Generate a OFFLINE_BUILD file to indicate offline build
|
||||
if [ $(OFFLINE) -eq 1 ]; then \
|
||||
$(CARGO) vendor .vendor > .cargo/config.toml; \
|
||||
tar -cJf vendor.tar.xz .vendor; \
|
||||
touch OFFLINE_BUILD; \
|
||||
fi
|
||||
|
||||
@echo "Creating tarball..."
|
||||
tar --exclude .vendor --exclude target --transform 's,^,${PKG}/,' -czf .build/tarball/${PKG}.tar.gz * .cargo
|
||||
|
||||
download-gui:
|
||||
rm -rf .build/gpgui
|
||||
|
||||
if [ $(INCLUDE_GUI) -eq 1 ]; then \
|
||||
echo "Downloading GlobalProtect GUI..."; \
|
||||
mkdir -p .build/gpgui; \
|
||||
curl -sSL https://github.com/yuezk/GlobalProtect-openconnect/releases/download/$(RELEASE_TAG)/gpgui_$(shell uname -m)$(GUI_LIBC_SUFFIX).bin.tar.xz \
|
||||
-o .build/gpgui/gpgui_$(shell uname -m)$(GUI_LIBC_SUFFIX).bin.tar.xz; \
|
||||
tar -xJf .build/gpgui/*.tar.xz -C .build/gpgui; \
|
||||
else \
|
||||
echo "Skipping GlobalProtect GUI download (INCLUDE_GUI=0)"; \
|
||||
fi
|
||||
|
||||
build: download-gui build-rs
|
||||
|
||||
build-rs:
|
||||
if [ $(OFFLINE) -eq 1 ]; then \
|
||||
tar -xJf vendor.tar.xz; \
|
||||
fi
|
||||
|
||||
# Remove the rust-toolchain.toml if DISABLE_RUST_TOOLCHAIN is set to 1
|
||||
if [ $(DISABLE_RUST_TOOLCHAIN) -eq 1 ]; then \
|
||||
rm -vf rust-toolchain.toml; \
|
||||
fi
|
||||
|
||||
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice
|
||||
|
||||
# Build gpauth with or without embedded webview auth support
|
||||
if [ $(BUILD_WEBVIEW_AUTH) -eq 1 ]; then \
|
||||
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth; \
|
||||
else \
|
||||
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth --no-default-features; \
|
||||
fi
|
||||
|
||||
# Only build the GUI components if BUILD_GUI_HELPER is set to 1
|
||||
if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \
|
||||
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpgui-helper; \
|
||||
fi
|
||||
|
||||
clean:
|
||||
$(CARGO) clean
|
||||
rm -rf .build
|
||||
rm -rf .vendor
|
||||
rm -rf apps/gpgui-helper/node_modules
|
||||
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
install: install-macos
|
||||
install-gpclient: install-gpclient-macos
|
||||
else ifneq ($(filter FreeBSD OpenBSD,$(shell uname -s)),)
|
||||
install: install-bsd
|
||||
install-gpclient: install-gpclient-unix
|
||||
else
|
||||
install: install-linux
|
||||
install-gpclient: install-gpclient-unix
|
||||
endif
|
||||
|
||||
install-gpclient-unix:
|
||||
install -d "$(DESTDIR)$(PREFIX)/bin" "$(DESTDIR)$(PREFIX)/libexec/gpclient"
|
||||
install -m 755 "$(CARGO_RELEASE_DIR)/gpclient" "$(DESTDIR)$(PREFIX)/bin/"
|
||||
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script "$(DESTDIR)$(PREFIX)/libexec/gpclient/"
|
||||
|
||||
install-gpclient-macos:
|
||||
install -d "$(DESTDIR)$(PREFIX)/bin" "$(DESTDIR)$(PREFIX)/lib/gpclient" "$(DESTDIR)$(PREFIX)/libexec/gpclient"
|
||||
install -m 755 "$(CARGO_RELEASE_DIR)/gpclient" "$(DESTDIR)$(PREFIX)/bin/"
|
||||
set -e; library=$$(sh scripts/macos-openconnect-library.sh "$(CARGO_RELEASE_DIR)/gpclient"); \
|
||||
install -m 755 "$$library" "$(DESTDIR)$(PREFIX)/lib/gpclient/"; \
|
||||
install_name_tool -delete_rpath "$$(dirname "$$library")" "$(DESTDIR)$(PREFIX)/bin/gpclient"; \
|
||||
codesign --force --sign - "$(DESTDIR)$(PREFIX)/bin/gpclient"
|
||||
install -m 755 packaging/files/usr/libexec/gpclient/vpnc-script "$(DESTDIR)$(PREFIX)/libexec/gpclient/"
|
||||
|
||||
install-macos: install-gpclient-macos
|
||||
install -m 755 "$(CARGO_RELEASE_DIR)/gpauth" "$(DESTDIR)$(PREFIX)/bin/"
|
||||
|
||||
# Common executable and icon installation uses portable install options on Linux/BSD.
|
||||
install-unix: install-gpclient-unix
|
||||
set -e; for binary in gpauth gpservice; do \
|
||||
install -m 755 "$(CARGO_RELEASE_DIR)/$$binary" "$(DESTDIR)$(PREFIX)/bin/"; \
|
||||
done
|
||||
set -e; for binary in gp-hip-script-installer gp-vpnc-script-installer; do \
|
||||
install -m 755 "$(CARGO_RELEASE_DIR)/$$binary" "$(DESTDIR)$(PREFIX)/libexec/gpclient/"; \
|
||||
done
|
||||
set -e; if [ "$(BUILD_GUI_HELPER)" = "1" ]; then \
|
||||
install -m 755 "$(CARGO_RELEASE_DIR)/gpgui-helper" "$(DESTDIR)$(PREFIX)/bin/"; \
|
||||
fi
|
||||
set -e; if [ -f "$(GPGUI_BINARY)" ]; then \
|
||||
install -m 755 "$(GPGUI_BINARY)" "$(DESTDIR)$(PREFIX)/bin/gpgui"; \
|
||||
fi
|
||||
set -e; for file in packaging/files/usr/share/icons/hicolor/*/apps/gpgui.* \
|
||||
packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-*.svg; do \
|
||||
destination="$(DESTDIR)$(PREFIX)/$${file#packaging/files/usr/}"; \
|
||||
install -d "$$(dirname "$$destination")"; \
|
||||
install -m 644 "$$file" "$$destination"; \
|
||||
done
|
||||
|
||||
install-linux: install-unix
|
||||
@echo "Installing Linux integration under $(PREFIX)..."
|
||||
set -e; for file in share/applications/gpgui.desktop \
|
||||
share/polkit-1/actions/com.yuezk.gpgui.policy \
|
||||
lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down \
|
||||
lib/NetworkManager/dispatcher.d/gpclient-nm-hook; do \
|
||||
mode=644; case "$$file" in lib/*) mode=755 ;; esac; \
|
||||
destination="$(DESTDIR)$(PREFIX)/$$file"; \
|
||||
install -d "$$(dirname "$$destination")"; \
|
||||
install -m "$$mode" "packaging/files/usr/$$file" "$$destination"; \
|
||||
done
|
||||
sh scripts/relocate-install-paths.sh "$(PREFIX)" /usr "$(DESTDIR)$(PREFIX)"
|
||||
|
||||
install-bsd: install-unix
|
||||
@echo "Installing BSD integration under $(PREFIX)..."
|
||||
install -d "$(DESTDIR)$(PREFIX)/share/applications" "$(DESTDIR)$(PREFIX)/share/polkit-1/actions"
|
||||
install -m 644 packaging/bsd/gpgui.desktop "$(DESTDIR)$(PREFIX)/share/applications/"
|
||||
install -m 644 packaging/bsd/com.yuezk.gpgui.policy "$(DESTDIR)$(PREFIX)/share/polkit-1/actions/"
|
||||
sh scripts/relocate-install-paths.sh "$(PREFIX)" /usr/local "$(DESTDIR)$(PREFIX)"
|
||||
|
||||
clean-bsd-package:
|
||||
rm -rf .build/$(BSD_FLAVOR)
|
||||
|
||||
bsd-gpgui-tarball:
|
||||
test -x "$(GPGUI_BINARY)"
|
||||
rm -rf .build/$(BSD_FLAVOR)/gpgui
|
||||
mkdir -p .build/$(BSD_FLAVOR)/artifacts .build/$(BSD_FLAVOR)/gpgui/gpgui_$(VERSION)
|
||||
cp "$(GPGUI_BINARY)" .build/$(BSD_FLAVOR)/gpgui/gpgui_$(VERSION)/
|
||||
tar -cf - -C .build/$(BSD_FLAVOR)/gpgui gpgui_$(VERSION) | xz -c > .build/$(BSD_FLAVOR)/artifacts/gpgui_$(BSD_FLAVOR)_$(shell uname -m).bin.tar.xz
|
||||
file=.build/$(BSD_FLAVOR)/artifacts/gpgui_$(BSD_FLAVOR)_$(shell uname -m).bin.tar.xz; \
|
||||
if command -v sha256sum >/dev/null 2>&1; then sha256sum "$$file" | cut -d ' ' -f 1; \
|
||||
elif command -v sha256 >/dev/null 2>&1; then sha256 -q "$$file"; \
|
||||
else cksum -a sha256 "$$file" | awk '{print $$1}'; fi > "$$file.sha256"
|
||||
|
||||
package-freebsd: BSD_FLAVOR=freebsd
|
||||
package-freebsd: clean-bsd-package
|
||||
test -x "$(GPGUI_BINARY)"
|
||||
mkdir -p .build/freebsd/pkgroot .build/freebsd/artifacts .build/freebsd/metadata
|
||||
$(MAKE) install-bsd DESTDIR=$(CURDIR)/.build/freebsd/pkgroot PREFIX=$(PREFIX) GPGUI_BINARY="$(GPGUI_BINARY)"
|
||||
find .build/freebsd/pkgroot$(PREFIX) -type f -print | sed 's|^.build/freebsd/pkgroot$(PREFIX)/||' | sort > .build/freebsd/PLIST
|
||||
freebsd_major=$$(freebsd-version -u | sed 's/\..*//'); \
|
||||
freebsd_arch=$$(uname -m | sed -e 's/x86_64/amd64/' -e 's/arm64/aarch64/'); \
|
||||
sed \
|
||||
-e 's/@PKG_NAME@/$(PKG_NAME)/g' \
|
||||
-e 's/@VERSION@/$(VERSION)/g' \
|
||||
-e "s/@ABI@/FreeBSD:$$freebsd_major:$$freebsd_arch/g" \
|
||||
-e "s/@ARCH@/freebsd:$$freebsd_major:$$freebsd_arch/g" \
|
||||
-e 's|@PREFIX@|$(PREFIX)|g' \
|
||||
packaging/bsd/freebsd/MANIFEST.in > .build/freebsd/metadata/+MANIFEST
|
||||
cp packaging/bsd/freebsd/POST_DEINSTALL .build/freebsd/metadata/+POST_DEINSTALL
|
||||
pkg create -r .build/freebsd/pkgroot -M .build/freebsd/metadata -p .build/freebsd/PLIST -o .build/freebsd/artifacts
|
||||
freebsd_arch=$$(uname -m | sed -e 's/x86_64/amd64/' -e 's/arm64/aarch64/'); \
|
||||
mv .build/freebsd/artifacts/$(PKG_NAME)-$(VERSION).pkg .build/freebsd/artifacts/$(PKG_NAME)-$(VERSION)-freebsd-$$freebsd_arch.pkg
|
||||
$(MAKE) bsd-gpgui-tarball BSD_FLAVOR=freebsd GPGUI_BINARY="$(GPGUI_BINARY)"
|
||||
|
||||
package-openbsd: BSD_FLAVOR=openbsd
|
||||
package-openbsd: clean-bsd-package
|
||||
test -x "$(GPGUI_BINARY)"
|
||||
mkdir -p .build/openbsd/pkgroot .build/openbsd/artifacts
|
||||
$(MAKE) install-bsd DESTDIR=$(CURDIR)/.build/openbsd/pkgroot PREFIX=$(PREFIX) GPGUI_BINARY="$(GPGUI_BINARY)"
|
||||
cp packaging/bsd/openbsd/COMMENT .build/openbsd/+COMMENT
|
||||
cp packaging/bsd/openbsd/DESC .build/openbsd/+DESC
|
||||
{ \
|
||||
echo '@unexec-delete /bin/rm -f /usr/local/libexec/gpclient/gpgui /var/db/gpclient/scripts/vpnc-script /var/db/gpclient/scripts/vpnc-script.metadata || echo "Warning: failed to remove gpclient runtime files" >&2'; \
|
||||
echo '@unexec-delete /bin/rmdir /usr/local/libexec/gpclient 2>/dev/null || true'; \
|
||||
echo '@unexec-delete /bin/rmdir /var/db/gpclient/scripts 2>/dev/null || true'; \
|
||||
echo '@unexec-delete /bin/rmdir /var/db/gpclient 2>/dev/null || true'; \
|
||||
find .build/openbsd/pkgroot$(PREFIX) -type f -print | sed 's|^.build/openbsd/pkgroot$(PREFIX)/||' | sort; \
|
||||
} > .build/openbsd/PLIST
|
||||
comment=$$(cat .build/openbsd/+COMMENT); \
|
||||
openbsd_arch=$$(uname -m | sed 's/x86_64/amd64/'); \
|
||||
gnome_keyring_pkg=$$(pkg_info -e 'gnome-keyring-*' | sed 's/^inst://' | head -n 1); \
|
||||
dbus_pkg=$$(pkg_info -e 'dbus-*' | sed 's/^inst://' | head -n 1); \
|
||||
polkit_pkg=$$(pkg_info -e 'polkit-*' | sed 's/^inst://' | head -n 1); \
|
||||
webkitgtk_pkg=$$(pkg_info -e 'webkitgtk41-*' | sed 's/^inst://' | head -n 1); \
|
||||
xdg_utils_pkg=$$(pkg_info -e 'xdg-utils-*' | sed 's/^inst://' | head -n 1); \
|
||||
pkg_create \
|
||||
-B .build/openbsd/pkgroot \
|
||||
-D COMMENT="$$comment" \
|
||||
-d .build/openbsd/+DESC \
|
||||
-f .build/openbsd/PLIST \
|
||||
-p $(PREFIX) \
|
||||
-P x11/gnome/keyring:gnome-keyring-*:$$gnome_keyring_pkg \
|
||||
-P x11/dbus:dbus-*:$$dbus_pkg \
|
||||
-P sysutils/polkit:polkit-*:$$polkit_pkg \
|
||||
-P www/webkitgtk4,webkitgtk41:webkitgtk41-*:$$webkitgtk_pkg \
|
||||
-P devel/xdg-utils:xdg-utils-*:$$xdg_utils_pkg \
|
||||
.build/openbsd/artifacts/$(PKG_NAME)-$(VERSION)-openbsd-$$openbsd_arch.tgz
|
||||
$(MAKE) bsd-gpgui-tarball BSD_FLAVOR=openbsd GPGUI_BINARY="$(GPGUI_BINARY)"
|
||||
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
uninstall: uninstall-macos
|
||||
else ifneq ($(filter FreeBSD OpenBSD,$(shell uname -s)),)
|
||||
uninstall: uninstall-bsd
|
||||
else
|
||||
uninstall: uninstall-linux
|
||||
endif
|
||||
|
||||
.PHONY: install install-gpclient install-macos install-unix install-linux install-bsd \
|
||||
install-gpclient-macos install-gpclient-unix \
|
||||
uninstall uninstall-macos uninstall-unix uninstall-linux uninstall-bsd
|
||||
|
||||
uninstall-macos:
|
||||
@echo "Uninstalling $(PKG_NAME) for macOS under $(PREFIX)..."
|
||||
rm -f "$(DESTDIR)$(PREFIX)/bin/gpclient" "$(DESTDIR)$(PREFIX)/bin/gpauth" \
|
||||
"$(DESTDIR)$(PREFIX)/libexec/gpclient/vpnc-script" \
|
||||
"$(DESTDIR)$(PREFIX)/lib/gpclient/"libopenconnect.*.dylib
|
||||
rmdir "$(DESTDIR)$(PREFIX)/lib/gpclient" "$(DESTDIR)$(PREFIX)/libexec/gpclient" 2>/dev/null || true
|
||||
|
||||
uninstall-unix:
|
||||
@echo "Uninstalling $(PKG_NAME) under $(PREFIX)..."
|
||||
set -e; for binary in gpclient gpauth gpservice gpgui-helper gpgui; do \
|
||||
rm -f "$(DESTDIR)$(PREFIX)/bin/$$binary"; \
|
||||
done
|
||||
set -e; for file in gp-hip-script-installer gp-vpnc-script-installer vpnc-script; do \
|
||||
rm -f "$(DESTDIR)$(PREFIX)/libexec/gpclient/$$file"; \
|
||||
done
|
||||
set -e; for file in packaging/files/usr/share/icons/hicolor/*/apps/gpgui.* \
|
||||
packaging/files/usr/share/icons/hicolor/scalable/status/gpgui-*.svg; do \
|
||||
rm -f "$(DESTDIR)$(PREFIX)/$${file#packaging/files/usr/}"; \
|
||||
done
|
||||
rm -f "$(DESTDIR)$(PREFIX)/share/applications/gpgui.desktop" \
|
||||
"$(DESTDIR)$(PREFIX)/share/polkit-1/actions/com.yuezk.gpgui.policy"
|
||||
rmdir "$(DESTDIR)$(PREFIX)/libexec/gpclient" 2>/dev/null || true
|
||||
|
||||
uninstall-linux: uninstall-unix
|
||||
rm -f "$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down" \
|
||||
"$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/gpclient-nm-hook"
|
||||
rm -f "$(DESTDIR)/var/lib/gpclient/gpgui" \
|
||||
"$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script" \
|
||||
"$(DESTDIR)/var/lib/gpclient/scripts/vpnc-script.metadata"
|
||||
rmdir "$(DESTDIR)/var/lib/gpclient/scripts" "$(DESTDIR)/var/lib/gpclient" 2>/dev/null || true
|
||||
|
||||
uninstall-bsd: uninstall-unix
|
||||
rm -f "$(DESTDIR)/usr/local/libexec/gpclient/gpgui" \
|
||||
"$(DESTDIR)/var/db/gpclient/scripts/vpnc-script" \
|
||||
"$(DESTDIR)/var/db/gpclient/scripts/vpnc-script.metadata"
|
||||
rmdir "$(DESTDIR)/var/db/gpclient/scripts" "$(DESTDIR)/var/db/gpclient" 2>/dev/null || true
|
||||
|
||||
clean-debian:
|
||||
rm -rf .build/deb
|
||||
|
||||
# Generate the debian package structure, without the changelog
|
||||
init-debian: clean-debian tarball
|
||||
mkdir -p .build/deb
|
||||
cp .build/tarball/${PKG}.tar.gz .build/deb
|
||||
|
||||
tar -xzf .build/deb/${PKG}.tar.gz -C .build/deb
|
||||
cd .build/deb/${PKG} && debmake
|
||||
|
||||
cp -f packaging/deb/control.in .build/deb/$(PKG)/debian/control
|
||||
cp -f packaging/deb/rules.in .build/deb/$(PKG)/debian/rules
|
||||
cp -f packaging/deb/postrm .build/deb/$(PKG)/debian/postrm
|
||||
cp -f packaging/deb/compat .build/deb/$(PKG)/debian/compat
|
||||
|
||||
sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/control
|
||||
|
||||
# Remove the GUI dependencies if neither GUI component is included
|
||||
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ]; then \
|
||||
sed -i "/libsecret-1-0/d" .build/deb/$(PKG)/debian/control; \
|
||||
sed -i "/libayatana-appindicator3-1/d" .build/deb/$(PKG)/debian/control; \
|
||||
sed -i "/gnome-keyring/d" .build/deb/$(PKG)/debian/control; \
|
||||
fi
|
||||
|
||||
# Remove WebKitGTK only if no included component needs it
|
||||
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \
|
||||
sed -i "/libwebkit2gtk-4.1-dev/d" .build/deb/$(PKG)/debian/control; \
|
||||
fi
|
||||
|
||||
sed -i "s/@INCLUDE_GUI@/$(INCLUDE_GUI)/g" .build/deb/$(PKG)/debian/rules
|
||||
sed -i "s/@BUILD_GUI_HELPER@/$(BUILD_GUI_HELPER)/g" .build/deb/$(PKG)/debian/rules
|
||||
sed -i "s/@BUILD_WEBVIEW_AUTH@/$(BUILD_WEBVIEW_AUTH)/g" .build/deb/$(PKG)/debian/rules
|
||||
sed -i "s/@RUST_VERSION@/$(RUST_VERSION)/g" .build/deb/$(PKG)/debian/rules
|
||||
|
||||
rm -f .build/deb/$(PKG)/debian/changelog
|
||||
|
||||
deb: init-debian
|
||||
cd .build/deb/$(PKG) && dch --create --distribution unstable --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION) "Bugfix and improvements."
|
||||
|
||||
# Install build dependencies
|
||||
cd .build/deb/$(PKG) && sudo mk-build-deps --install --remove debian/control || echo "mk-build-deps failed, continuing"
|
||||
|
||||
cd .build/deb/$(PKG) && debuild --preserve-env -e PATH -us -uc -b -d
|
||||
|
||||
check-ppa:
|
||||
if [ $(OFFLINE) -eq 0 ]; then \
|
||||
echo "Error: ppa build requires offline mode (OFFLINE=1)"; \
|
||||
fi
|
||||
|
||||
# Usage: make ppa SERIES=focal OFFLINE=1 PUBLISH=1
|
||||
ppa: check-ppa init-debian
|
||||
$(eval SERIES_VER = $(shell distro-info --series $(SERIES) -r | cut -d' ' -f1))
|
||||
@echo "Building for $(SERIES) $(SERIES_VER)"
|
||||
|
||||
rm -rf .build/deb/$(PKG)/debian/changelog
|
||||
cd .build/deb/$(PKG) && dch --create --distribution $(SERIES) --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION)ppa$(PPA_REVISION)~ubuntu$(SERIES_VER) "Bugfix and improvements."
|
||||
|
||||
cd .build/deb/$(PKG) && echo "y" | debuild -e PATH -S -sa -k"$(GPG_KEY_ID)" -p"gpg --batch --passphrase $(GPG_KEY_PASS) --pinentry-mode loopback"
|
||||
|
||||
if [ $(PUBLISH) -eq 1 ]; then \
|
||||
cd .build/deb/$(PKG) && dput ppa:yuezk/globalprotect-openconnect ../*.changes; \
|
||||
else \
|
||||
echo "Skipping ppa publish (PUBLISH=0)"; \
|
||||
fi
|
||||
|
||||
clean-rpm:
|
||||
rm -rf .build/rpm
|
||||
|
||||
# Generate RPM sepc file
|
||||
init-rpm: clean-rpm
|
||||
mkdir -p .build/rpm
|
||||
|
||||
cp packaging/rpm/globalprotect-openconnect.spec.in .build/rpm/globalprotect-openconnect.spec
|
||||
cp packaging/rpm/globalprotect-openconnect.changes.in .build/rpm/globalprotect-openconnect.changes
|
||||
|
||||
sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.spec
|
||||
sed -i "s/@REVISION@/$(REVISION)/g" .build/rpm/globalprotect-openconnect.spec
|
||||
sed -i "s|@SOURCE@|$(RPM_SOURCE)|g" .build/rpm/globalprotect-openconnect.spec
|
||||
sed -i "s/@DATE@/$(shell LC_ALL=en.US date "+%a %b %d %Y")/g" .build/rpm/globalprotect-openconnect.spec
|
||||
|
||||
sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.changes
|
||||
sed -i "s/@DATE@/$(shell LC_ALL=en.US date -u "+%a %b %e %T %Z %Y")/g" .build/rpm/globalprotect-openconnect.changes
|
||||
|
||||
rpm: init-rpm tarball
|
||||
rm -rf $(HOME)/rpmbuild
|
||||
rpmdev-setuptree
|
||||
|
||||
cp .build/tarball/${PKG}.tar.gz $(HOME)/rpmbuild/SOURCES/${PKG_NAME}.tar.gz
|
||||
rpmbuild -ba .build/rpm/globalprotect-openconnect.spec
|
||||
|
||||
# Copy RPM package from build directory
|
||||
cp $(HOME)/rpmbuild/RPMS/$(shell uname -m)/$(PKG_NAME)*.rpm .build/rpm
|
||||
|
||||
# Copy the SRPM only for x86_64.
|
||||
if [ "$(shell uname -m)" = "x86_64" ]; then \
|
||||
cp $(HOME)/rpmbuild/SRPMS/$(PKG_NAME)*.rpm .build/rpm; \
|
||||
fi
|
||||
|
||||
clean-pkgbuild:
|
||||
rm -rf .build/pkgbuild
|
||||
|
||||
init-pkgbuild: clean-pkgbuild tarball
|
||||
mkdir -p .build/pkgbuild
|
||||
|
||||
cp .build/tarball/${PKG}.tar.gz .build/pkgbuild
|
||||
cp packaging/pkgbuild/PKGBUILD.in .build/pkgbuild/PKGBUILD
|
||||
cp packaging/pkgbuild/gp.install .build/pkgbuild/gp.install
|
||||
|
||||
sed -i "s/@PKG_NAME@/$(PKG_NAME)/g" .build/pkgbuild/PKGBUILD
|
||||
sed -i "s/@VERSION@/$(VERSION)/g" .build/pkgbuild/PKGBUILD
|
||||
sed -i "s/@REVISION@/$(REVISION)/g" .build/pkgbuild/PKGBUILD
|
||||
|
||||
pkgbuild: init-pkgbuild
|
||||
cd .build/pkgbuild && makepkg -s --noconfirm
|
||||
|
||||
clean-apk:
|
||||
rm -rf .build/apk
|
||||
|
||||
init-apk: clean-apk tarball
|
||||
mkdir -p .build/apk
|
||||
|
||||
cp .build/tarball/${PKG}.tar.gz .build/apk
|
||||
cp packaging/apk/APKBUILD.in .build/apk/APKBUILD
|
||||
cp packaging/apk/post-deinstall .build/apk/$(PKG_NAME).post-deinstall
|
||||
|
||||
sed -i "s/@PKG_NAME@/$(PKG_NAME)/g" .build/apk/APKBUILD
|
||||
sed -i "s/@VERSION@/$(VERSION)/g" .build/apk/APKBUILD
|
||||
sed -i "s/@REVISION@/$(REVISION)/g" .build/apk/APKBUILD
|
||||
checksum=$$(sha512sum .build/apk/${PKG}.tar.gz | cut -d' ' -f1); \
|
||||
sed -i "s/@SHA512@/$$checksum/g" .build/apk/APKBUILD
|
||||
|
||||
# Remove the GUI dependencies if neither GUI component is included
|
||||
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ]; then \
|
||||
sed -i "/^\tlibayatana-appindicator$$/d" .build/apk/APKBUILD; \
|
||||
sed -i "/^\tlibsecret$$/d" .build/apk/APKBUILD; \
|
||||
fi
|
||||
|
||||
# Remove WebKitGTK only if no included component needs it
|
||||
if [ $(INCLUDE_GUI) -eq 0 ] && [ $(BUILD_GUI_HELPER) -eq 0 ] && [ $(BUILD_WEBVIEW_AUTH) -eq 0 ]; then \
|
||||
sed -i "/^\twebkit2gtk-4.1$$/d" .build/apk/APKBUILD; \
|
||||
fi
|
||||
|
||||
apk: init-apk
|
||||
cd .build/apk && abuild -r -P "$(CURDIR)/.build/apk/packages"
|
||||
|
||||
find .build/apk/packages -type f -name "$(PKG_NAME)-*.apk" -exec cp {} .build/apk \;
|
||||
|
||||
clean-binary:
|
||||
rm -rf .build/binary
|
||||
|
||||
binary: clean-binary tarball
|
||||
mkdir -p .build/binary
|
||||
|
||||
cp .build/tarball/${PKG}.tar.gz .build/binary
|
||||
tar -xzf .build/binary/${PKG}.tar.gz -C .build/binary
|
||||
|
||||
mkdir -p .build/binary/$(PKG_NAME)_$(VERSION)/artifacts
|
||||
|
||||
make -C .build/binary/${PKG} build INCLUDE_GUI=$(INCLUDE_GUI)
|
||||
make -C .build/binary/${PKG} install DESTDIR=$(PWD)/.build/binary/$(PKG_NAME)_$(VERSION)/artifacts
|
||||
|
||||
cp packaging/binary/Makefile.in .build/binary/$(PKG_NAME)_$(VERSION)/Makefile
|
||||
|
||||
# Create a tarball for the binary package
|
||||
tar -cJf .build/binary/$(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.xz -C .build/binary $(PKG_NAME)_$(VERSION)
|
||||
|
||||
# Generate sha256sum
|
||||
cd .build/binary && sha256sum $(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.xz | cut -d' ' -f1 > $(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.xz.sha256
|
||||
@@ -1,39 +0,0 @@
|
||||
# Maintainer: Keinv Yue <[email protected]>
|
||||
|
||||
pkgname=globalprotect-openconnect
|
||||
_gitname=GlobalProtect-openconnect
|
||||
pkgver={PKG_VERSION}
|
||||
pkgrel=1
|
||||
pkgdesc="A GlobalProtect VPN client (GUI) for Linux based on Openconnect and built with Qt5, supports SAML auth mode."
|
||||
arch=(x86_64 aarch64)
|
||||
url="https://github.com/yuezk/${_gitname}"
|
||||
license=('GPL3')
|
||||
depends=('openconnect>=8.0.0' qt5-base qt5-webengine qt5-websockets)
|
||||
makedepends=()
|
||||
source=(
|
||||
"${_gitname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz"
|
||||
"https://github.com/itay-grudev/SingleApplication/archive/v3.0.19.tar.gz"
|
||||
"https://github.com/SergiusTheBest/plog/archive/1.1.5.tar.gz"
|
||||
)
|
||||
|
||||
sha256sums=(
|
||||
'{SOURCE_SHA}'
|
||||
'9405fd259288b2a862e91e5135bccee936f0438e1b32c13603277132309d15e0'
|
||||
'6c80b4701183d2415bec927e1f5ca9b1761b3b5c65d3e09fb29c743e016d5609'
|
||||
);
|
||||
|
||||
prepare() {
|
||||
mv "$srcdir/SingleApplication-3.0.19" -T "$srcdir/${_gitname}-${pkgver}/singleapplication"
|
||||
mv "$srcdir/plog-1.1.5" -T "$srcdir/${_gitname}-${pkgver}/plog"
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "$srcdir/${_gitname}-${pkgver}"
|
||||
qmake CONFIG+=release "${srcdir}/${_gitname}-${pkgver}/GlobalProtect-openconnect.pro"
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$srcdir/${_gitname}-${pkgver}"
|
||||
make INSTALL_ROOT="$pkgdir/" install
|
||||
}
|
||||
@@ -1,152 +1,571 @@
|
||||
# GlobalProtect-openconnect
|
||||
A GlobalProtect VPN client (GUI) for Linux based on Openconnect and built with Qt5, supports SAML auth mode, inspired by [gp-saml-gui](https://github.com/dlenski/gp-saml-gui).
|
||||
|
||||
A GlobalProtect VPN client built on OpenConnect with support for SSO authentication. It provides command-line tools and the GP Connect desktop application for macOS, Linux, FreeBSD, and OpenBSD.
|
||||
|
||||
<p align="center">
|
||||
<img src="screenshot.png">
|
||||
<img width="300" src="https://github.com/user-attachments/assets/2fb6116c-dc57-43f2-af75-9c3d97ab7122">
|
||||
</p>
|
||||
|
||||
> **Inspired by** [gp-saml-gui](https://github.com/dlenski/gp-saml-gui)
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Features](#features)
|
||||
- [Usage](#usage)
|
||||
- [Command-Line Interface](#command-line-interface)
|
||||
- [Graphical User Interface](#graphical-user-interface)
|
||||
- [Installation](#installation)
|
||||
- [macOS](#macos)
|
||||
- [Debian / Ubuntu](#debian--ubuntu)
|
||||
- [Arch Linux / Manjaro](#arch-linux--manjaro)
|
||||
- [Fedora 38+ / Rawhide](#fedora-38--rawhide)
|
||||
- [openSUSE Leap 15.6+ / Tumbleweed](#opensuse-leap-156--tumbleweed)
|
||||
- [Other RPM-based Distributions](#other-rpm-based-distributions)
|
||||
- [Alpine Linux](#alpine-linux)
|
||||
- [FreeBSD](#freebsd)
|
||||
- [OpenBSD](#openbsd)
|
||||
- [Gentoo](#gentoo)
|
||||
- [NixOS](#nixos)
|
||||
- [Official Docker Image](#official-docker-image)
|
||||
- [Other Distributions](#other-distributions)
|
||||
- [Building from Source](#building-from-source)
|
||||
- [Frequently Asked Questions](#frequently-asked-questions)
|
||||
- [NetworkManager Integration](#networkmanager-integration)
|
||||
- [Licensing](#licensing)
|
||||
|
||||
## Features
|
||||
|
||||
- Similar user experience as the official client in macOS.
|
||||
- Supports both SAML and non-SAML authentication modes.
|
||||
- Supports automatically selecting the preferred gateway from the multiple gateways.
|
||||
- Supports switching gateway from the system tray menu manually.
|
||||
- **Desktop Platform Support** – macOS, Linux, FreeBSD, and OpenBSD
|
||||
- **Dual Interface** – Available as both CLI and GUI applications
|
||||
- **Flexible Authentication** – Supports SSO, non-SSO, FIDO2 (e.g., YubiKey), and client certificate authentication
|
||||
- **Browser Integration** – Authenticate using your default browser or any specified browser
|
||||
- **Multi-Portal Support** – Connect to multiple portals and gateways
|
||||
- **Direct Gateway Connection** – Bypass portal selection when needed
|
||||
- **Auto-Connect** – Automatically connect on system startup
|
||||
- **System Tray Integration** – Convenient system tray icon (requires [gnome-shell-extension-appindicator](https://extensions.gnome.org/extension/615/appindicator-support/) on GNOME)
|
||||
|
||||
## Future plan
|
||||
## Usage
|
||||
|
||||
- [ ] Improve the release process
|
||||
- [ ] Process bugs and feature requests
|
||||
- [ ] Support for bypassing the `gpclient` parameters
|
||||
- [ ] Support the CLI mode
|
||||
### Command-Line Interface
|
||||
|
||||
## Passing the Custom Parameters to `OpenConnect` CLI
|
||||
The CLI is free and open source. Use it to authenticate, connect to portals or gateways, and generate HIP reports from the terminal.
|
||||
|
||||
Custom parameters can be appended to the `OpenConnect` CLI with the following settings.
|
||||
#### Basic Commands
|
||||
|
||||
> Tokens with spaces can be surrounded by double quotes; three consecutive double quotes represent the quote character itself.
|
||||
```bash
|
||||
Usage: gpclient [OPTIONS] <COMMAND>
|
||||
|
||||
Commands:
|
||||
connect Connect to a portal server
|
||||
disconnect Disconnect from the server
|
||||
launch-gui Launch the GUI
|
||||
hip Generate HIP report
|
||||
help Print this message or the help of the given subcommand(s)
|
||||
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/3297602/130319209-744be02b-d657-4f49-a76d-d2c81b5c46d5.png" />
|
||||
<p>
|
||||
|
||||
## Display the system tray icon on Gnome 40
|
||||
|
||||
Install the [AppIndicator and KStatusNotifierItem Support](https://extensions.gnome.org/extension/615/appindicator-support/) extension and you will see the system try icon (Restart the system after the installation).
|
||||
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/3297602/130831022-b93492fd-46dd-4a8e-94a4-13b5747120b7.png" />
|
||||
<p>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Openconnect v8.x
|
||||
- Qt5, qt5-webengine, qt5-websockets
|
||||
|
||||
### Ubuntu
|
||||
1. Install openconnect v8.x
|
||||
|
||||
```sh
|
||||
sudo apt install openconnect
|
||||
openconnect --version
|
||||
```
|
||||
|
||||
For Ubuntu 18.04 you might need to [build the latest openconnect from source code](https://gist.github.com/yuezk/ab9a4b87a9fa0182bdb2df41fab5f613).
|
||||
|
||||
2. Install the Qt dependencies
|
||||
|
||||
For Ubuntu 20, this should work.
|
||||
|
||||
```sh
|
||||
sudo apt install qtbase5-dev libqt5websockets5-dev qtwebengine5-dev qttools5-dev debhelper
|
||||
```
|
||||
|
||||
For Ubuntu 21, you need to install the base pieces separately as QT5 is the default.
|
||||
|
||||
```sh
|
||||
sudo apt install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5websockets5-dev qtwebengine5-dev qttools5-dev debhelper
|
||||
```
|
||||
|
||||
### OpenSUSE
|
||||
Install the Qt dependencies
|
||||
|
||||
```sh
|
||||
sudo zypper install libqt5-qtbase-devel libqt5-qtwebsockets-devel libqt5-qtwebengine-devel
|
||||
Options:
|
||||
--fix-openssl Uses extended compatibility mode for OpenSSL operations to support a broader range of systems and formats.
|
||||
--ignore-tls-errors Ignore the TLS errors
|
||||
--lock-file <LOCK_FILE> Path to the gpclient PID lock file
|
||||
--log-format <LOG_FORMAT> Log output format. JSON is intended for non-interactive consumers; interactive prompts remain text. [default: text] [possible values: text, json]
|
||||
-v, --verbose... Enable verbose output, -v for debug, -vv for trace
|
||||
-q, --quiet... Decrease logging verbosity, -q for warnings, -qq for errors
|
||||
-h, --help Print help (see more with '--help')
|
||||
-V, --version Print version
|
||||
```
|
||||
|
||||
### Fedora
|
||||
Install the Qt dependencies:
|
||||
> **Tip:** Use `gpclient help <command>` for detailed information on a specific command.
|
||||
|
||||
```sh
|
||||
sudo dnf install qt5-qtbase-devel qt5-qtwebengine-devel qt5-qtwebsockets-devel
|
||||
#### HIP reports
|
||||
|
||||
HIP is disabled in the CLI unless enabled explicitly. Use `--hip` to generate reports inside `gpclient`, including later reports requested by the gateway:
|
||||
|
||||
```bash
|
||||
sudo gpclient connect <portal> --hip
|
||||
```
|
||||
|
||||
## Install
|
||||
Use `--hip=/absolute/path/to/script` for a custom executable. It runs as the `gpclient` process user unless `--hip-user` specifies another user. No installed HIP script is discovered automatically. `--hip-user` applies only to custom executables.
|
||||
|
||||
### Install from AUR (Arch/Manjaro)
|
||||
`gpclient hip` generates a report on demand for inspection; see `gpclient hip --help` for report inputs. The GUI's HIP tab supports generated reports, edited XML, and HIP Off on all desktop platforms. Linux, FreeBSD, and OpenBSD also support desktop-user scripts and explicitly approved root scripts.
|
||||
|
||||
Install [globalprotect-openconnect](https://aur.archlinux.org/packages/globalprotect-openconnect/).
|
||||
#### External Browser Authentication
|
||||
|
||||
### Build from source code
|
||||
Use `gpclient` directly for browser-based authentication. It opens the browser as your normal desktop user while keeping VPN tunnel setup privileged:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/yuezk/GlobalProtect-openconnect.git
|
||||
cd GlobalProtect-openconnect
|
||||
git submodule update --init
|
||||
|
||||
# qmake or qmake-qt5
|
||||
qmake CONFIG+=release
|
||||
make
|
||||
sudo make install
|
||||
```bash
|
||||
sudo gpclient connect <portal> --browser
|
||||
```
|
||||
Open `GlobalProtect VPN` in the application dashboard.
|
||||
|
||||
### Debian package
|
||||
To reuse a saved portal cookie for later connections, add `--cookie-cache`:
|
||||
|
||||
Relatively manual process for now:
|
||||
```bash
|
||||
sudo gpclient connect <portal> --browser --cookie-cache
|
||||
```
|
||||
|
||||
* Clone the source tree
|
||||
Add `--gateway <gateway>` to select a particular gateway. Cookie caching is handled by `gpclient`. Its default cache file is `$HOME/.config/gpclient/cookie.json`, which normally belongs to root when running with `sudo`. To choose a predictable location, specify the path explicitly:
|
||||
|
||||
```
|
||||
git clone https://github.com/yuezk/GlobalProtect-openconnect.git
|
||||
cd GlobalProtect-openconnect
|
||||
```
|
||||
```bash
|
||||
sudo gpclient connect <portal> --browser --cookie-cache=/absolute/path/to/cookie.json
|
||||
```
|
||||
|
||||
* Install git-archive-all using the pip. Remember to adjust the version numbers etc.
|
||||
**Browser Options:**
|
||||
|
||||
```
|
||||
pip install git-archive-all
|
||||
```
|
||||
- Use `--browser` to try your recognized default browser first, then another detected browser, and finally the system URL handler
|
||||
- Use `--browser default` to use the system default browser
|
||||
- Use `--browser <browser>` to specify a browser (e.g., `firefox`, `chrome`)
|
||||
- Use `--browser remote` for headless servers – this provides a URL you can access from another machine to complete authentication
|
||||
|
||||
* Next create an upstream source tree using git archive.
|
||||
### Graphical User Interface
|
||||
|
||||
```
|
||||
git-archive-all --force-submodules --prefix=globalprotect-openconnect-1.3.0/ ../globalprotect-openconnect_1.3.0.orig.tar.gz
|
||||
```
|
||||
GP Connect provides a desktop interface for managing VPN connections. On macOS, open GP Connect from Applications. On Linux, FreeBSD, and OpenBSD, launch it from your application menu or via the terminal:
|
||||
|
||||
* Finally extract the source tree, build the debian package, and install it.
|
||||
```bash
|
||||
gpclient launch-gui
|
||||
```
|
||||
|
||||
```
|
||||
cd ..
|
||||
tar -xzvf globalprotect-openconnect_1.3.0.orig.tar.gz
|
||||
cd globalprotect-openconnect-1.3.0
|
||||
fakeroot dpkg-buildpackage -uc -us -sa 2>&1 | tee ../build.log
|
||||
sudo dpkg -i globalprotect-openconnect_1.3.0-1ppa1_amd64.deb
|
||||
```
|
||||
> [!Note]
|
||||
>
|
||||
> The GUI version is partially open source. The background service ([gpservice](./apps/gpservice/)) is open source, while the GUI wrapper is proprietary.
|
||||
|
||||
## Installation
|
||||
|
||||
> [!Note]
|
||||
>
|
||||
> For older Linux distributions, use [v2.3.13](https://github.com/yuezk/GlobalProtect-openconnect/releases/tag/v2.3.13) instead of the latest release. It provides release assets for common distro families, including Debian/Ubuntu (`.deb`), Arch Linux / Manjaro (`.pkg.tar.zst`), RPM-based distros such as Fedora / RHEL / Rocky / AlmaLinux / CentOS (`.rpm`), and generic Linux tarballs (`.bin.tar.xz`).
|
||||
|
||||
### macOS
|
||||
|
||||
GP Connect requires Apple silicon and macOS 13 or later. The macOS app includes both the desktop application and the free `gpclient` CLI. The CLI does not require a GUI license.
|
||||
|
||||
#### Option 1: Install with Homebrew
|
||||
|
||||
```bash
|
||||
brew install --cask yuezk/gp-connect/gp-connect
|
||||
```
|
||||
|
||||
Open GP Connect from Applications, or connect from the terminal:
|
||||
|
||||
```bash
|
||||
sudo gpclient connect <portal> --browser
|
||||
```
|
||||
|
||||
#### Option 2: Install from DMG
|
||||
|
||||
Download the GP Connect `.dmg` from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, open it, and drag GP Connect into Applications.
|
||||
|
||||
### Debian / Ubuntu
|
||||
|
||||
#### Option 1: Install from PPA (Recommended)
|
||||
|
||||
```bash
|
||||
sudo add-apt-repository ppa:yuezk/globalprotect-openconnect
|
||||
sudo apt-get update
|
||||
sudo apt-get install globalprotect-openconnect
|
||||
```
|
||||
|
||||
> [!Note]
|
||||
>
|
||||
> **For Linux Mint users:** If you encounter a GPG key error, import the key manually:
|
||||
> ```bash
|
||||
> sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7937C393082992E5D6E4A60453FC26B43838D761
|
||||
> ```
|
||||
|
||||
#### Option 2: Install from DEB Package
|
||||
|
||||
Download the latest `.deb` package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||
|
||||
```bash
|
||||
sudo apt install --fix-broken ./globalprotect-openconnect_*.deb
|
||||
```
|
||||
|
||||
### Arch Linux / Manjaro
|
||||
|
||||
#### Option 1: Install from AUR
|
||||
|
||||
Package: [globalprotect-openconnect-git](https://aur.archlinux.org/packages/globalprotect-openconnect-git/)
|
||||
|
||||
You can install it using an AUR helper like [`yay`](https://github.com/Jguer/yay):
|
||||
|
||||
```bash
|
||||
yay -S globalprotect-openconnect-git
|
||||
```
|
||||
|
||||
#### Option 2: Install from the Official Extra Repository
|
||||
|
||||
The package is also available in the official Arch Linux Extra repository.
|
||||
|
||||
Package: [globalprotect-openconnect](https://archlinux.org/packages/extra/x86_64/globalprotect-openconnect/)
|
||||
|
||||
> [!Note]
|
||||
>
|
||||
> Since the official package does not include the system tray support dependency, you need to install `libappindicator` manually:
|
||||
|
||||
```bash
|
||||
sudo pacman -S libappindicator globalprotect-openconnect
|
||||
```
|
||||
|
||||
#### Option 3: Install from Package
|
||||
|
||||
Download the latest package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||
|
||||
```bash
|
||||
sudo pacman -U globalprotect-openconnect-*.pkg.tar.zst
|
||||
```
|
||||
|
||||
### Fedora 38+ / Rawhide
|
||||
|
||||
#### Install from COPR
|
||||
|
||||
The package is available on [COPR](https://copr.fedorainfracloud.org/coprs/yuezk/globalprotect-openconnect/) for RPM-based distributions:
|
||||
|
||||
```bash
|
||||
sudo dnf copr enable yuezk/globalprotect-openconnect
|
||||
sudo dnf install globalprotect-openconnect
|
||||
```
|
||||
|
||||
### openSUSE Leap 15.6+ / Tumbleweed
|
||||
|
||||
#### Install from OBS (openSUSE Build Service)
|
||||
|
||||
Packages are available on the [openSUSE Build Service](https://build.opensuse.org/package/show/home:yuezk/globalprotect-openconnect). Follow the [installation instructions](https://software.opensuse.org//download.html?project=home%3Ayuezk&package=globalprotect-openconnect) for your distribution.
|
||||
|
||||
### Other RPM-based Distributions
|
||||
|
||||
#### Install from RPM Package
|
||||
|
||||
Download the latest RPM package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page:
|
||||
|
||||
```bash
|
||||
sudo rpm -i globalprotect-openconnect-*.rpm
|
||||
```
|
||||
|
||||
### Alpine Linux
|
||||
|
||||
Download the latest `.apk` package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||
|
||||
```bash
|
||||
sudo apk add --allow-untrusted globalprotect-openconnect-*.apk
|
||||
```
|
||||
|
||||
The package uses Alpine's native musl build. Make sure the `community` repository is enabled so GUI dependencies such as `webkit2gtk-4.1`, `libsecret`, and `libayatana-appindicator` can be resolved. GUI-launched connections use polkit, and VPN tunnel creation requires `/dev/net/tun`.
|
||||
|
||||
### FreeBSD
|
||||
|
||||
Download the latest FreeBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||
|
||||
```bash
|
||||
sudo pkg install ./globalprotect-openconnect-*-freebsd-*.pkg
|
||||
```
|
||||
|
||||
To build from source, see [Building from Source on FreeBSD and OpenBSD](./docs/bsd-source-build.md).
|
||||
|
||||
### OpenBSD
|
||||
|
||||
Download the latest OpenBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
|
||||
|
||||
```bash
|
||||
doas pkg_add -D unsigned ./globalprotect-openconnect-*-openbsd-*.tgz
|
||||
```
|
||||
|
||||
To build from source, see [Building from Source on FreeBSD and OpenBSD](./docs/bsd-source-build.md).
|
||||
|
||||
### Gentoo
|
||||
|
||||
Available via the `guru` and `lamdness` overlays:
|
||||
|
||||
```bash
|
||||
sudo eselect repository enable guru
|
||||
sudo emerge --sync guru
|
||||
sudo emerge --ask --verbose net-vpn/GlobalProtect-openconnect
|
||||
```
|
||||
|
||||
### NixOS
|
||||
In `configuration.nix`:
|
||||
|
||||
```
|
||||
services.globalprotect = {
|
||||
enable = true;
|
||||
# if you need a Host Integrity Protection report
|
||||
csdWrapper = "${pkgs.openconnect}/libexec/openconnect/hipreport.sh";
|
||||
This repository includes a flake for NixOS integration.
|
||||
|
||||
#### Installation Steps
|
||||
|
||||
Add the flake input and NixOS module to your `flake.nix`:
|
||||
|
||||
The module builds the package with your NixOS configuration's `pkgs`, so the
|
||||
GlobalProtect GUI and the system use the same Nixpkgs dependency versions.
|
||||
It also enables Polkit and its setuid `pkexec` wrapper for privileged operations.
|
||||
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
# ... other inputs
|
||||
globalprotect-openconnect.url = "github:yuezk/GlobalProtect-openconnect";
|
||||
};
|
||||
|
||||
environment.systemPackages = [ globalprotect-openconnect ];
|
||||
```
|
||||
|
||||
|
||||
## [License](./LICENSE)
|
||||
GPLv3
|
||||
outputs = { self, nixpkgs, globalprotect-openconnect, ... }:
|
||||
let
|
||||
system = "x86_64-linux"; # or "aarch64-linux" for ARM64
|
||||
hostname = "<your-host>";
|
||||
in {
|
||||
nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
|
||||
modules = [
|
||||
./configuration.nix
|
||||
globalprotect-openconnect.nixosModules.default
|
||||
{
|
||||
programs.globalprotect-openconnect.enable = true;
|
||||
|
||||
environment.systemPackages = [
|
||||
nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Apply:
|
||||
|
||||
```bash
|
||||
sudo nixos-rebuild switch
|
||||
loginctl terminate-user "$USER"
|
||||
```
|
||||
|
||||
After logging back in to GNOME, enable AppIndicator support if needed:
|
||||
|
||||
```bash
|
||||
gnome-extensions enable [email protected]
|
||||
```
|
||||
|
||||
NixOS does not run an imperative package-uninstall hook when a package is
|
||||
removed from the system configuration. Remove an installed replacement VPN
|
||||
script from the app settings before removing the package.
|
||||
|
||||
The `prebuilt` package and NixOS module use the published release pinned in `flake.nix`. Both `prebuilt` and `fromSource` run natively on the host with packaged dependencies and installer paths. The `fromSource` package builds the current flake checkout, including its Git submodules:
|
||||
|
||||
```bash
|
||||
git submodule update --init --recursive
|
||||
nix build "git+file://$PWD?submodules=1#fromSource"
|
||||
```
|
||||
|
||||
Local source builds require initialized Git submodules and a flake URL with `submodules=1`, as shown above. For a remote source flake, use a Git URL with submodules enabled, such as `git+https://github.com/yuezk/GlobalProtect-openconnect?submodules=1#fromSource`. The `prebuilt` package and NixOS module do not require Git submodules. Build output (`target`, `.build`, and `node_modules`) is excluded from the source input. Updating release asset hashes changes the prebuilt package, independently of source builds.
|
||||
|
||||
### Official Docker Image
|
||||
|
||||
The [official Docker image](https://hub.docker.com/r/yuezk/globalprotect-openconnect) provides the CLI tools on Alpine Linux:
|
||||
|
||||
```bash
|
||||
docker pull yuezk/globalprotect-openconnect:<version>
|
||||
```
|
||||
|
||||
Release images are tagged as `vX.Y.Z`, `X.Y.Z`, and `latest`.
|
||||
|
||||
Run it with access to the TUN device:
|
||||
|
||||
```bash
|
||||
docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||
yuezk/globalprotect-openconnect:<version> \
|
||||
connect <portal>
|
||||
```
|
||||
|
||||
For browser authentication in a headless environment, use remote browser authentication:
|
||||
|
||||
```bash
|
||||
docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||
yuezk/globalprotect-openconnect:<version> \
|
||||
connect <portal> --browser remote
|
||||
```
|
||||
|
||||
On a host with multiple network interfaces, use `--browser-listen` to select the IP address reachable from the browser machine:
|
||||
|
||||
```bash
|
||||
gpclient connect <portal> --browser remote --browser-listen 192.168.107.15
|
||||
```
|
||||
|
||||
On a Linux host, add host networking if the VPN routes should affect the host network namespace:
|
||||
|
||||
```bash
|
||||
docker run --rm -it --network host --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||
yuezk/globalprotect-openconnect:<version> \
|
||||
connect <portal> --browser remote
|
||||
```
|
||||
|
||||
Without `--network host`, the VPN connection stays inside the container's network namespace. Docker Desktop on macOS and Windows does not make the host use the VPN through `--network host`; run `gpclient` on the host or use a container gateway setup for host traffic.
|
||||
|
||||
The image includes `gpclient` and `gpauth` only. It does not include embedded webview authentication, `gpgui-helper`, or `gpgui`.
|
||||
|
||||
### Other Distributions
|
||||
|
||||
#### Manual Installation
|
||||
|
||||
1. **Install dependencies:**
|
||||
- WebKitGTK 4.1 (for example, `libwebkit2gtk-4.1-0` on Debian/Ubuntu)
|
||||
- `libsecret`
|
||||
- `libayatana-appindicator` or `libappindicator-gtk3`
|
||||
- polkit (`pkexec`) for GUI-launched VPN connections
|
||||
|
||||
2. **Download and extract:**
|
||||
Download `globalprotect-openconnect_${version}_${arch}.bin.tar.xz` from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page:
|
||||
```bash
|
||||
tar -xJf globalprotect-openconnect_${version}_${arch}.bin.tar.xz
|
||||
cd globalprotect-openconnect_${version}
|
||||
```
|
||||
|
||||
3. **Install:**
|
||||
```bash
|
||||
sudo make install
|
||||
```
|
||||
|
||||
## Building from Source
|
||||
|
||||
The instructions below build the open-source components on Linux. For FreeBSD and OpenBSD, see [Building from Source on FreeBSD and OpenBSD](./docs/bsd-source-build.md).
|
||||
|
||||
### Method 1: Using DevContainer
|
||||
|
||||
This project includes a DevContainer configuration for Linux development. The repository's `rust-toolchain.toml` selects the Rust toolchain; rustup may need to download it on the first build.
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
- [Docker](https://docs.docker.com/get-docker/)
|
||||
- [Visual Studio Code](https://code.visualstudio.com/) (optional, for IDE support)
|
||||
- [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) (if using VS Code)
|
||||
|
||||
#### Build Steps
|
||||
|
||||
1. **Clone the repository:**
|
||||
```bash
|
||||
git clone https://github.com/yuezk/GlobalProtect-openconnect.git
|
||||
cd GlobalProtect-openconnect
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
2. **Build the DevContainer image:**
|
||||
```bash
|
||||
docker build -t gpoc-devcontainer .devcontainer/
|
||||
```
|
||||
|
||||
3. **Build the project:**
|
||||
|
||||
To build the open-source components, including the GUI helper, run:
|
||||
```bash
|
||||
docker run --privileged --cap-add=NET_ADMIN --device=/dev/net/tun \
|
||||
--tty -v "$(pwd)":/workspace -w /workspace gpoc-devcontainer \
|
||||
bash -c "export PATH=/usr/local/cargo/bin:\$PATH && make build"
|
||||
```
|
||||
To build without the GUI helper run the same command as above, but with `BUILD_GUI_HELPER=0` passed as an argument to `make`.
|
||||
|
||||
4. **Locate build artifacts:**
|
||||
|
||||
The compiled binaries will be available in `target/release/`:
|
||||
- `gpclient` – CLI client
|
||||
- `gpservice` – Background service
|
||||
- `gpauth` – Authentication helper
|
||||
- `gpgui-helper` – GUI helper
|
||||
- `gp-hip-script-installer` – Privileged HIP script installer
|
||||
- `gp-vpnc-script-installer` – Privileged VPN script installer
|
||||
|
||||
The proprietary GP Connect desktop application is distributed separately. Use `INCLUDE_GUI=1` with `make build` to download its matching published Linux build for installation.
|
||||
|
||||
#### Alternative: Using VS Code
|
||||
|
||||
1. Open the project in VS Code
|
||||
2. When prompted, click "Reopen in Container" (or run **Dev Containers: Reopen in Container**)
|
||||
3. Once the container is ready, open a terminal and run:
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
|
||||
### Method 2: Local Development Build
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
- [Rust 1.91 or later](https://www.rust-lang.org/tools/install)
|
||||
- [Tauri dependencies](https://tauri.app/start/prerequisites/)
|
||||
- OpenConnect source-build dependencies: `autoconf`, `automake`, `autopoint`/`gettext`, `libtool`, `patch`, `pkg-config`, `libxml2`, `zlib`, `lz4`, `gnutls`, `p11-kit`, `nettle`, and `gmp` development packages
|
||||
- `pkexec` and `gnome-keyring` (or `pam_kwallet` on KDE)
|
||||
- Node.js and pnpm if rebuilding the GUI helper frontend
|
||||
|
||||
#### Build Steps
|
||||
|
||||
1. **Download source code:**
|
||||
|
||||
Download `globalprotect-openconnect-${version}.tar.gz` from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page.
|
||||
|
||||
2. **Extract and build:**
|
||||
```bash
|
||||
tar -xzf globalprotect-openconnect-${version}.tar.gz
|
||||
cd globalprotect-openconnect-${version}
|
||||
make build
|
||||
```
|
||||
|
||||
3. **Install:**
|
||||
```bash
|
||||
sudo make install
|
||||
```
|
||||
|
||||
To stage the files for packaging instead of installing them into the system, use `make install DESTDIR=/absolute/path/to/staging`.
|
||||
|
||||
### Testing Your Build
|
||||
|
||||
Verify the CLI client is working correctly:
|
||||
|
||||
```bash
|
||||
./target/release/gpclient --help
|
||||
```
|
||||
|
||||
### Build Options
|
||||
|
||||
- `BUILD_GUI_HELPER=0` – Skip building and installing the GUI helper
|
||||
- `BUILD_WEBVIEW_AUTH=0` – Build `gpauth` without embedded browser authentication; use an external or remote browser
|
||||
- `INCLUDE_GUI=1` – Download the matching published Linux desktop application for installation
|
||||
- `OFFLINE=1` – Build in offline mode using vendored dependencies
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
When reporting a problem, follow the [diagnostics collection instructions](docs/diagnostics.md). A standalone script is available for versions without the diagnostics command; you do not need to upgrade first.
|
||||
|
||||
### Q: How do I resolve the "Secure Storage not ready" error?
|
||||
|
||||
Unlock your desktop keyring and ensure the application can access it. On Linux and BSD, check that a keyring service such as GNOME Keyring is installed and running in your desktop session. On macOS, check Keychain access.
|
||||
|
||||
Linux and BSD can use file storage when secure storage is unavailable during initial setup. An existing configuration that uses the keyring still needs access to that keyring.
|
||||
|
||||
See related issues: [#321](https://github.com/yuezk/GlobalProtect-openconnect/issues/321), [#316](https://github.com/yuezk/GlobalProtect-openconnect/issues/316)
|
||||
|
||||
### Q: How do I fix the "cannot open display" error when using CLI?
|
||||
|
||||
Run the client from a terminal in your normal desktop session and use an external browser:
|
||||
|
||||
```bash
|
||||
sudo gpclient connect <portal> --browser
|
||||
```
|
||||
|
||||
See related issue: [#316](https://github.com/yuezk/GlobalProtect-openconnect/issues/316)
|
||||
|
||||
On a headless server, use `--browser remote` and complete authentication from another machine.
|
||||
|
||||
## NetworkManager Integration
|
||||
|
||||
- [WMP/GlobalProtect-SAML-NetworkManager](https://github.com/WMP/GlobalProtect-SAML-NetworkManager) – NetworkManager VPN plugin with SAML/SSO support for GNOME and KDE Plasma
|
||||
- [jdpipe/networkmanager-gpclient](https://github.com/jdpipe/networkmanager-gpclient) – NetworkManager VPN plugin that uses `gpclient`
|
||||
|
||||
## Licensing
|
||||
|
||||
### Trial and Pricing
|
||||
|
||||
The **CLI version** is completely free and open source.
|
||||
The **GUI version** is a paid application with a **7-day trial**. Start the trial in the app by verifying your email address with a one-time code. Installing the app alone does not start the trial.
|
||||
|
||||
### Open Source Licenses
|
||||
|
||||
This project consists of multiple components, each with its own license:
|
||||
|
||||
| Component | Type | License |
|
||||
|-----------|------|---------|
|
||||
| [gpapi](./crates/gpapi) | Crate | [MIT](./crates/gpapi/LICENSE) |
|
||||
| [openconnect](./crates/openconnect) | Rust wrapper crate | [MIT](./crates/openconnect/LICENSE) |
|
||||
| [upstream OpenConnect](./crates/openconnect/deps/openconnect) | C library | [LGPL-2.1](./crates/openconnect/deps/openconnect/COPYING.LGPL) |
|
||||
| [common](./crates/common) | Crate | [MIT](./crates/common/LICENSE) |
|
||||
| [browser-launcher](./crates/browser-launcher) | Crate | [MIT](./crates/browser-launcher/LICENSE) |
|
||||
| [auth](./crates/auth) | Crate | [GPL-3.0](./crates/auth/LICENSE) |
|
||||
| [gpservice](./apps/gpservice) | Application | [GPL-3.0](./apps/gpservice/LICENSE) |
|
||||
| [gpclient](./apps/gpclient) | Application | [GPL-3.0](./apps/gpclient/LICENSE) |
|
||||
| [gpauth](./apps/gpauth) | Application | [GPL-3.0](./apps/gpauth/LICENSE) |
|
||||
| [gpgui-helper](./apps/gpgui-helper) | Application | [GPL-3.0](./apps/gpgui-helper/LICENSE) |
|
||||
@@ -0,0 +1,35 @@
|
||||
[package]
|
||||
name = "gpauth"
|
||||
rust-version.workspace = true
|
||||
authors.workspace = true
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [], optional = true }
|
||||
|
||||
[dependencies]
|
||||
common = { path = "../../crates/common" }
|
||||
gpapi = { path = "../../crates/gpapi", features = ["clap", "logger"] }
|
||||
|
||||
auth = { path = "../../crates/auth", features = ["browser-auth"] }
|
||||
|
||||
# Shared dependencies
|
||||
anyhow.workspace = true
|
||||
clap.workspace = true
|
||||
log.workspace = true
|
||||
serde_json.workspace = true
|
||||
tokio = { workspace = true, features = ["rt-multi-thread"] }
|
||||
tempfile.workspace = true
|
||||
compile-time.workspace = true
|
||||
|
||||
home = "0.5.12"
|
||||
|
||||
# webview auth dependencies
|
||||
tauri = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
default = ["webview-auth"]
|
||||
webview-auth = ["auth/webview-auth", "dep:tauri", "dep:tauri-build"]
|
||||
release-devtools = ["auth/release-devtools"]
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>LSUIElement</key>
|
||||
<true/>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>GlobalProtect authentication callback</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>globalprotectcallback</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,63 @@
|
||||
use std::{env, fs, path::PathBuf, process::Command};
|
||||
|
||||
const UNKNOWN_COMMIT: &str = "unknown";
|
||||
const DISPLAY_COMMIT_LEN: usize = 9;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-env-changed=GPAUTH_GIT_COMMIT");
|
||||
println!("cargo:rerun-if-env-changed=SOURCE_GIT_COMMIT");
|
||||
println!("cargo:rerun-if-env-changed=GITHUB_SHA");
|
||||
|
||||
let repo_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set")).join("../..");
|
||||
let source_commit = repo_root.join("SOURCE_COMMIT");
|
||||
println!("cargo:rerun-if-changed={}", source_commit.display());
|
||||
println!(
|
||||
"cargo:rustc-env=GPAUTH_GIT_COMMIT={}",
|
||||
resolve_commit(&repo_root, &source_commit)
|
||||
);
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
tauri_build::build()
|
||||
}
|
||||
|
||||
fn resolve_commit(repo_root: &PathBuf, source_commit: &PathBuf) -> String {
|
||||
env_commit("GPAUTH_GIT_COMMIT")
|
||||
.or_else(|| env_commit("SOURCE_GIT_COMMIT"))
|
||||
.or_else(|| env_commit("GITHUB_SHA"))
|
||||
.or_else(|| file_commit(source_commit))
|
||||
.or_else(|| git_commit(repo_root))
|
||||
.unwrap_or_else(|| UNKNOWN_COMMIT.to_string())
|
||||
}
|
||||
|
||||
fn env_commit(key: &str) -> Option<String> {
|
||||
env::var(key).ok().and_then(|value| normalize_commit(&value))
|
||||
}
|
||||
|
||||
fn file_commit(path: &PathBuf) -> Option<String> {
|
||||
fs::read_to_string(path).ok().and_then(|value| normalize_commit(&value))
|
||||
}
|
||||
|
||||
fn git_commit(repo_root: &PathBuf) -> Option<String> {
|
||||
let output = Command::new("git")
|
||||
.args(["rev-parse", "--short=9", "HEAD"])
|
||||
.current_dir(repo_root)
|
||||
.output()
|
||||
.ok()?;
|
||||
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
|
||||
String::from_utf8(output.stdout)
|
||||
.ok()
|
||||
.and_then(|value| normalize_commit(&value))
|
||||
}
|
||||
|
||||
fn normalize_commit(value: &str) -> Option<String> {
|
||||
let value = value.trim();
|
||||
if value.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(value.chars().take(DISPLAY_COMMIT_LEN).collect())
|
||||
}
|
||||
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 62 KiB |
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>GlobalProtect Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to GlobalProtect Login...</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,58 @@
|
||||
use std::{
|
||||
sync::{
|
||||
Arc,
|
||||
atomic::{AtomicBool, Ordering},
|
||||
},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use tauri::RunEvent;
|
||||
|
||||
pub fn run() -> anyhow::Result<()> {
|
||||
let handled = Arc::new(AtomicBool::new(false));
|
||||
let timeout_handled = Arc::clone(&handled);
|
||||
let app = tauri::Builder::default()
|
||||
.setup(move |app| {
|
||||
#[cfg(target_os = "macos")]
|
||||
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
|
||||
|
||||
let app_handle = app.handle().clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
tokio::time::sleep(Duration::from_secs(10)).await;
|
||||
if !timeout_handled.swap(true, Ordering::AcqRel) {
|
||||
app_handle.exit(1);
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
})
|
||||
.build(crate::tauri_context::get())?;
|
||||
|
||||
app.run(move |app_handle, event| {
|
||||
let RunEvent::Opened { urls } = event else {
|
||||
return;
|
||||
};
|
||||
let Some(callback) = urls
|
||||
.into_iter()
|
||||
.find(|url| url.scheme().eq_ignore_ascii_case("globalprotectcallback"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
if handled.swap(true, Ordering::AcqRel) {
|
||||
return;
|
||||
}
|
||||
|
||||
let app_handle = app_handle.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let exit_code = match auth::forward_auth_callback(callback.as_str()).await {
|
||||
Ok(()) => 0,
|
||||
Err(err) => {
|
||||
eprintln!("Failed to forward authentication callback: {err}");
|
||||
1
|
||||
}
|
||||
};
|
||||
app_handle.exit(exit_code);
|
||||
});
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||
use auth::forward_auth_callback;
|
||||
use auth::{BrowserAuthenticator, auth_prelogin};
|
||||
use clap::Parser;
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||
use clap::Subcommand;
|
||||
#[cfg(feature = "webview-auth")]
|
||||
use gpapi::auth::AuthWindowTheme;
|
||||
use gpapi::{
|
||||
auth::{AuthenticationCancelled, SamlAuthData, SamlAuthResult},
|
||||
clap::{Args, InfoLevelVerbosity, args::Os, handle_error},
|
||||
gp_params::GpParams,
|
||||
log_format::LogFormat,
|
||||
os_profile::{ClientOs, OsProfile},
|
||||
utils::{normalize_server, openssl},
|
||||
};
|
||||
use log::info;
|
||||
use serde_json::json;
|
||||
use std::net::IpAddr;
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
const VERSION: &str = concat!(
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
" (",
|
||||
env!("GPAUTH_GIT_COMMIT"),
|
||||
" ",
|
||||
compile_time::date_str!(),
|
||||
")"
|
||||
);
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(
|
||||
version = VERSION,
|
||||
author,
|
||||
about = "The authentication component for the GlobalProtect VPN client, supports the SSO authentication method.",
|
||||
args_conflicts_with_subcommands = true,
|
||||
subcommand_negates_reqs = true,
|
||||
help_template = "\
|
||||
{before-help}{name} {version}
|
||||
{author}
|
||||
|
||||
{about}
|
||||
|
||||
{usage-heading} {usage}
|
||||
|
||||
{all-args}{after-help}
|
||||
|
||||
See 'gpauth -h' for more information.
|
||||
"
|
||||
)]
|
||||
struct Cli {
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||
#[command(subcommand)]
|
||||
command: Option<CliCommand>,
|
||||
|
||||
#[arg(required = true, help = "The portal server to authenticate")]
|
||||
server: Option<String>,
|
||||
|
||||
#[arg(long, help = "Treating the server as a gateway")]
|
||||
gateway: bool,
|
||||
|
||||
#[arg(long, help = "The SAML authentication request")]
|
||||
saml_request: Option<String>,
|
||||
|
||||
#[arg(long, value_enum, default_value_t = Os::default())]
|
||||
os: Os,
|
||||
|
||||
#[arg(long, help = "Use this runtime host ID when building the OS profile")]
|
||||
host_id: Option<String>,
|
||||
|
||||
#[arg(long, help = "Override the GlobalProtect client version reported to the server")]
|
||||
client_version: Option<String>,
|
||||
|
||||
#[arg(
|
||||
short,
|
||||
long,
|
||||
help = "Use SSL client certificate file in pkcs#8 (.pem) or pkcs#12 (.p12, .pfx) format"
|
||||
)]
|
||||
certificate: Option<String>,
|
||||
|
||||
#[arg(short = 'k', long, help = "Use SSL private key file in pkcs#8 (.pem) format")]
|
||||
sslkey: Option<String>,
|
||||
|
||||
#[arg(short = 'p', long, help = "The key passphrase of the private key")]
|
||||
key_password: Option<String>,
|
||||
|
||||
#[arg(long, help = "Get around the OpenSSL `unsafe legacy renegotiation` error")]
|
||||
fix_openssl: bool,
|
||||
|
||||
#[arg(long, help = "Ignore TLS errors")]
|
||||
ignore_tls_errors: bool,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
value_enum,
|
||||
default_value_t = LogFormat::Text,
|
||||
help = "Log output format. JSON is intended for non-interactive consumers; interactive prompts remain text."
|
||||
)]
|
||||
log_format: LogFormat,
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
#[arg(long, help = "Use the default browser for authentication")]
|
||||
default_browser: bool,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
help = "Use external browser authentication. With no value, auto-select Chrome, Firefox, then system default. Use `default` for the system default browser or `remote` for headless servers.",
|
||||
default_missing_value = "auto",
|
||||
num_args=0..=1
|
||||
)]
|
||||
browser: Option<String>,
|
||||
|
||||
#[arg(long, help = "Listen on this IP address when using '--browser remote'")]
|
||||
browser_listen: Option<IpAddr>,
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
#[arg(long, help = "The HiDPI mode, useful for high-resolution screens")]
|
||||
hidpi: bool,
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
#[arg(long, help = "Clean the cache of the embedded browser")]
|
||||
pub clean: bool,
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
#[arg(long, help = "Set the embedded authentication window title")]
|
||||
window_title: Option<String>,
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
#[arg(long, value_enum, default_value_t = AuthWindowTheme::default(), help = "Set the embedded authentication window appearance")]
|
||||
window_theme: AuthWindowTheme,
|
||||
|
||||
#[command(flatten)]
|
||||
verbose: InfoLevelVerbosity,
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||
#[derive(Subcommand)]
|
||||
enum CliCommand {
|
||||
#[command(hide = true)]
|
||||
AuthCallback {
|
||||
#[arg(help = "The globalprotectcallback URL to forward")]
|
||||
callback: String,
|
||||
},
|
||||
}
|
||||
|
||||
impl Args for Cli {
|
||||
fn fix_openssl(&self) -> bool {
|
||||
self.fix_openssl
|
||||
}
|
||||
|
||||
fn ignore_tls_errors(&self) -> bool {
|
||||
self.ignore_tls_errors
|
||||
}
|
||||
|
||||
fn log_format(&self) -> LogFormat {
|
||||
self.log_format
|
||||
}
|
||||
}
|
||||
|
||||
impl Cli {
|
||||
fn prepare_env(&self) -> anyhow::Result<Option<NamedTempFile>> {
|
||||
#[cfg(feature = "webview-auth")]
|
||||
gpapi::utils::env_utils::patch_gui_runtime_env(self.hidpi);
|
||||
|
||||
if self.fix_openssl {
|
||||
info!("Fixing OpenSSL environment");
|
||||
let file = openssl::fix_openssl_env()?;
|
||||
|
||||
return Ok(Some(file));
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
async fn run(&self) -> anyhow::Result<()> {
|
||||
if self.browser_listen.is_some()
|
||||
&& !matches!(self.browser.as_deref(), Some(browser) if browser.eq_ignore_ascii_case("remote"))
|
||||
{
|
||||
anyhow::bail!("The '--browser-listen' option requires '--browser remote'");
|
||||
}
|
||||
|
||||
if self.ignore_tls_errors {
|
||||
info!("TLS errors will be ignored");
|
||||
}
|
||||
|
||||
let openssl_conf = self.prepare_env()?;
|
||||
|
||||
let server = normalize_server(self.server.as_deref().expect("server is required for authentication"))?;
|
||||
let gp_params = self.build_gp_params();
|
||||
info!(
|
||||
"gpauth auth host-id: {}",
|
||||
gp_params.os_profile().host_identity().host_id()
|
||||
);
|
||||
|
||||
let auth_request = match self.saml_request.as_deref() {
|
||||
Some(auth_request) => auth_request.to_string(),
|
||||
None => auth_prelogin(&server, &gp_params, self.external_browser_requested(), self.gateway).await?,
|
||||
};
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
let browser = self
|
||||
.browser
|
||||
.as_deref()
|
||||
.or_else(|| self.default_browser.then(|| "default"));
|
||||
|
||||
#[cfg(not(feature = "webview-auth"))]
|
||||
let browser = self.browser.as_deref().or(Some("default"));
|
||||
|
||||
if let Some(browser) = browser {
|
||||
let auth_host_id = gp_params.os_profile().host_identity().host_id().to_string();
|
||||
let authenticator = BrowserAuthenticator::new(&auth_request, browser, self.browser_listen);
|
||||
let auth_result = authenticator.authenticate().await;
|
||||
|
||||
print_auth_result(auth_result, Some(&auth_host_id));
|
||||
|
||||
// explicitly drop openssl_conf to avoid the unused variable warning
|
||||
drop(openssl_conf);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
crate::webview_auth::authenticate(
|
||||
server,
|
||||
gp_params,
|
||||
auth_request,
|
||||
self.clean,
|
||||
self.window_title.clone(),
|
||||
self.window_theme,
|
||||
openssl_conf,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn build_gp_params(&self) -> GpParams {
|
||||
GpParams::builder(self.build_os_profile())
|
||||
.ignore_tls_errors(self.ignore_tls_errors)
|
||||
.certificate(self.certificate.clone())
|
||||
.sslkey(self.sslkey.clone())
|
||||
.key_password(self.key_password.clone())
|
||||
.is_gateway(self.gateway)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn build_os_profile(&self) -> OsProfile {
|
||||
let mut builder = OsProfile::builder(ClientOs::from(self.os));
|
||||
if let Some(host_id) = self.host_id.as_deref() {
|
||||
builder = builder.host_id_override(host_id);
|
||||
}
|
||||
if let Some(client_version) = self.client_version.as_deref() {
|
||||
builder = builder.client_version(client_version);
|
||||
}
|
||||
builder.build()
|
||||
}
|
||||
|
||||
fn external_browser_requested(&self) -> bool {
|
||||
#[cfg(feature = "webview-auth")]
|
||||
{
|
||||
self.default_browser || self.browser.is_some()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "webview-auth"))]
|
||||
{
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn init_logger(cli: &Cli) {
|
||||
let Some(level) = cli.verbose.log_level_filter().to_level() else {
|
||||
log::set_max_level(log::LevelFilter::Off);
|
||||
return;
|
||||
};
|
||||
|
||||
gpapi::logger::init(level, "com.yuezk.gpgui", "gpauth", cli.log_format);
|
||||
}
|
||||
|
||||
pub async fn run() {
|
||||
let cli = Cli::parse();
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||
if let Some(CliCommand::AuthCallback { callback }) = &cli.command {
|
||||
if let Err(err) = forward_auth_callback(callback).await {
|
||||
eprintln!("Failed to forward authentication callback: {err}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
init_logger(&cli);
|
||||
info!("gpauth started: {}", VERSION);
|
||||
|
||||
if let Err(err) = cli.run().await {
|
||||
handle_error(err, &cli);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_auth_result(auth_result: anyhow::Result<SamlAuthData>, host_id: Option<&str>) {
|
||||
let auth_result = match auth_result {
|
||||
Ok(auth_data) => {
|
||||
let auth_data = match host_id {
|
||||
Some(host_id) => auth_data.with_host_id(host_id),
|
||||
None => auth_data,
|
||||
};
|
||||
SamlAuthResult::Success(auth_data)
|
||||
}
|
||||
Err(err) if err.downcast_ref::<AuthenticationCancelled>().is_some() => SamlAuthResult::Cancelled,
|
||||
Err(err) => SamlAuthResult::Failure(format!("{}", err)),
|
||||
};
|
||||
|
||||
println!("{}", json!(auth_result));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// gpauth's own result already goes to stdout as JSON; this makes its *logs*
|
||||
/// readable the same way, so a caller driving it does not have to parse prose
|
||||
/// on stderr to find out why an attempt failed.
|
||||
#[test]
|
||||
fn log_format_defaults_to_text() {
|
||||
let cli = Cli::try_parse_from(["gpauth", "portal.example.com"]).expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.log_format, LogFormat::Text);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn log_format_accepts_json() {
|
||||
let cli =
|
||||
Cli::try_parse_from(["gpauth", "portal.example.com", "--log-format", "json"]).expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.log_format, LogFormat::Json);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn os_defaults_to_runtime_os() {
|
||||
let cli = Cli::try_parse_from(["gpauth", "portal.example.com"]).expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.os, Os::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||
fn callback_arguments_parse_separately() {
|
||||
let cli = Cli::try_parse_from([
|
||||
"gpauth",
|
||||
"auth-callback",
|
||||
"globalprotectcallback:cas-as=1&[email protected]&token=token",
|
||||
])
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
cli.command,
|
||||
Some(CliCommand::AuthCallback { callback }) if callback.starts_with("globalprotectcallback:")
|
||||
));
|
||||
assert!(cli.server.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_id_arg_sets_profile_host_id_seed() {
|
||||
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--host-id", "host-seed"])
|
||||
.expect("gpauth args should parse");
|
||||
let profile = cli.build_os_profile();
|
||||
|
||||
assert_eq!(profile.host_identity().host_id(), "host-seed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_arg_requests_external_browser() {
|
||||
let cli =
|
||||
Cli::try_parse_from(["gpauth", "portal.example.com", "--browser", "firefox"]).expect("gpauth args should parse");
|
||||
|
||||
assert!(cli.external_browser_requested());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_without_value_uses_auto_mode() {
|
||||
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--browser"]).expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.browser.as_deref(), Some("auto"));
|
||||
assert!(cli.external_browser_requested());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_default_keeps_system_default_mode() {
|
||||
let cli =
|
||||
Cli::try_parse_from(["gpauth", "portal.example.com", "--browser", "default"]).expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.browser.as_deref(), Some("default"));
|
||||
assert!(cli.external_browser_requested());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_listen_accepts_ip_address() {
|
||||
let cli = Cli::try_parse_from([
|
||||
"gpauth",
|
||||
"portal.example.com",
|
||||
"--browser",
|
||||
"remote",
|
||||
"--browser-listen",
|
||||
"192.168.107.15",
|
||||
])
|
||||
.expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.browser_listen, Some("192.168.107.15".parse().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn client_version_arg_sets_profile_client_version() {
|
||||
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--client-version", "legacy-client"])
|
||||
.expect("gpauth args should parse");
|
||||
let profile = cli.build_os_profile();
|
||||
|
||||
assert_eq!(profile.client_version(), "legacy-client");
|
||||
assert!(profile.user_agent().contains("legacy-client"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn client_certificate_args_parse() {
|
||||
let cli = Cli::try_parse_from([
|
||||
"gpauth",
|
||||
"portal.example.com",
|
||||
"--certificate",
|
||||
"/tmp/client.pem",
|
||||
"--sslkey",
|
||||
"/tmp/client.key",
|
||||
"--key-password",
|
||||
"secret",
|
||||
])
|
||||
.expect("gpauth args should parse");
|
||||
|
||||
assert_eq!(cli.certificate.as_deref(), Some("/tmp/client.pem"));
|
||||
assert_eq!(cli.sslkey.as_deref(), Some("/tmp/client.key"));
|
||||
assert_eq!(cli.key_password.as_deref(), Some("secret"));
|
||||
}
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
#[test]
|
||||
fn auth_window_options_parse() {
|
||||
let cli = Cli::try_parse_from([
|
||||
"gpauth",
|
||||
"portal.example.com",
|
||||
"--window-title",
|
||||
"GP Connect Login",
|
||||
"--window-theme",
|
||||
"dark",
|
||||
])
|
||||
.expect("gpauth window options should parse");
|
||||
|
||||
assert_eq!(cli.window_title.as_deref(), Some("GP Connect Login"));
|
||||
assert_eq!(cli.window_theme, AuthWindowTheme::Dark);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
mod cli;
|
||||
|
||||
#[cfg(all(target_os = "macos", feature = "webview-auth"))]
|
||||
mod callback_app;
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
mod tauri_context;
|
||||
|
||||
#[cfg(feature = "webview-auth")]
|
||||
mod webview_auth;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
#[cfg(all(target_os = "macos", feature = "webview-auth"))]
|
||||
if is_callback_app_launch() {
|
||||
if let Err(err) = callback_app::run() {
|
||||
eprintln!("Failed to handle authentication callback: {err}");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cli::run().await;
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "macos", feature = "webview-auth"))]
|
||||
fn is_callback_app_launch() -> bool {
|
||||
std::env::args_os().len() == 1
|
||||
&& std::env::current_exe().is_ok_and(|executable| {
|
||||
executable
|
||||
.ancestors()
|
||||
.any(|path| path.extension().is_some_and(|extension| extension == "app"))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub fn get() -> tauri::Context<tauri::Wry> {
|
||||
tauri::generate_context!()
|
||||
}
|
||||