Prepare release 1.4.3 (#149)

* add inih

* add configuration file for gpservice

* Disable the UI configuration for extra args

* remove VERSION_SUFFIX

* remove ppa-publish.sh

* Use Git repo as the source for PKGBUILD

* remove VERSION_SUFFIX

* Use Git repo as the source for PKGBUILD

* add .install for PKGBUILD

* add configuration file

* Fix cmake

* Fix cmake

* Disable snap job

* update AUR packaging

* Disable the UI configuration for extra args

* improve packaging script

* update README.md

* restart gpservice after package upgrading
This commit is contained in:
Kevin Yue
2022-05-09 21:58:58 +08:00
committed by GitHub
parent 04d180e11a
commit 57df34fd1e
36 changed files with 901 additions and 159 deletions

View File

@@ -22,6 +22,7 @@ qt5_add_dbus_adaptor(
)
add_executable(gpservice
gpservice.h
gpservice.cpp
main.cpp
${gpservice_GENERATED_SOURCES}
@@ -58,6 +59,7 @@ target_link_libraries(gpservice
Qt5::Network
Qt5::DBus
QtSignals
inih
)
target_compile_definitions(gpservice PUBLIC QAPPLICATION_CLASS=QCoreApplication)
@@ -65,6 +67,7 @@ target_compile_definitions(gpservice PUBLIC QAPPLICATION_CLASS=QCoreApplication)
install(TARGETS gpservice DESTINATION bin)
install(FILES "dbus/com.yuezk.qt.GPService.conf" DESTINATION share/dbus-1/system.d )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dbus/com.yuezk.qt.GPService.service" DESTINATION share/dbus-1/system-services)
install(FILES "gp.conf" DESTINATION /etc/gpservice)
if("$ENV{DEBIAN_PACKAGE}")
# Install the systemd unit files to /lib/systemd/system for debian package

17
GPService/gp.conf Normal file
View File

@@ -0,0 +1,17 @@
# Configuration file for GlobalProtect-openconnect
#
# Description:
#
# Each section is a VPN gateway address, and [*] is a special section that defines the default configuration.
# See https://github.com/yuezk/GlobalProtect-openconnect/wiki/Configuration for more details.
#
# Example:
#
# [*]
# openconnect-args=<value>
#
# [vpn1.company.com]
# openconnect-args=--script=/path/to/vpnc-script
[*]
openconnect-args=

View File

@@ -5,6 +5,7 @@
#include <QtCore/QRegularExpressionMatch>
#include <QtDBus/QtDBus>
#include "INIReader.h"
#include "gpservice.h"
#include "gpserviceadaptor.h"
@@ -41,8 +42,22 @@ QString GPService::findBinary()
return nullptr;
}
QString GPService::extraOpenconnectArgs(const QString &gateway)
{
INIReader reader("/etc/gpservice/gp.conf");
if (reader.ParseError() < 0) {
return "";
}
std::string defaultArgs = reader.Get("*", "openconnect-args", "");
std::string extraArgs = reader.Get(gateway.toStdString(), "openconnect-args", defaultArgs);
return QString::fromStdString(extraArgs);
}
/* Port from https://github.com/qt/qtbase/blob/11d1dcc6e263c5059f34b44d531c9ccdf7c0b1d6/src/corelib/io/qprocess.cpp#L2115 */
QStringList GPService::splitCommand(QString command)
QStringList GPService::splitCommand(const QString &command)
{
QStringList args;
QString tmp;
@@ -92,7 +107,7 @@ void GPService::quit()
}
}
void GPService::connect(QString server, QString username, QString passwd, QString extraArgs)
void GPService::connect(QString server, QString username, QString passwd)
{
if (vpnStatus != GPService::VpnNotConnected) {
log("VPN status is: " + QVariant::fromValue(vpnStatus).toString());
@@ -110,6 +125,9 @@ void GPService::connect(QString server, QString username, QString passwd, QStrin
return;
}
const QString extraArgs = extraOpenconnectArgs(server);
log(QString("Got extra OpenConnect args for server: %1, %2").arg(server, extraArgs.isEmpty() ? "<empty>" : extraArgs));
QStringList args;
args << QCoreApplication::arguments().mid(1)
<< "--protocol=gp"

View File

@@ -37,7 +37,7 @@ signals:
void logAvailable(QString log);
public slots:
void connect(QString server, QString username, QString passwd, QString extraArgs);
void connect(QString server, QString username, QString passwd);
void disconnect();
int status();
@@ -56,7 +56,8 @@ private:
void log(QString msg);
bool isValidVersion(QString &bin);
static QString findBinary();
static QStringList splitCommand(QString command);
static QString extraOpenconnectArgs(const QString &gateway);
static QStringList splitCommand(const QString &command);
};
#endif // GLOBALPROTECTSERVICE_H