mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
Support custom parameters (#76)
* Add the setting icon * Add support for custom parameters * Ignore auto generated files * Update README.md
This commit is contained in:
parent
c8942984a8
commit
b4f9cfae67
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,6 +6,8 @@ gpservice
|
|||||||
*_adaptor.cpp
|
*_adaptor.cpp
|
||||||
*_adaptor.h
|
*_adaptor.h
|
||||||
|
|
||||||
|
gpservice_interface.*
|
||||||
|
|
||||||
# C++ objects and libs
|
# C++ objects and libs
|
||||||
*.slo
|
*.slo
|
||||||
*.lo
|
*.lo
|
||||||
|
@ -35,7 +35,8 @@ SOURCES += \
|
|||||||
portalconfigresponse.cpp \
|
portalconfigresponse.cpp \
|
||||||
preloginresponse.cpp \
|
preloginresponse.cpp \
|
||||||
samlloginwindow.cpp \
|
samlloginwindow.cpp \
|
||||||
gpclient.cpp
|
gpclient.cpp \
|
||||||
|
settingsdialog.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
cdpcommand.h \
|
cdpcommand.h \
|
||||||
@ -50,11 +51,13 @@ HEADERS += \
|
|||||||
portalconfigresponse.h \
|
portalconfigresponse.h \
|
||||||
preloginresponse.h \
|
preloginresponse.h \
|
||||||
samlloginwindow.h \
|
samlloginwindow.h \
|
||||||
gpclient.h
|
gpclient.h \
|
||||||
|
settingsdialog.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
gpclient.ui \
|
gpclient.ui \
|
||||||
normalloginwindow.ui
|
normalloginwindow.ui \
|
||||||
|
settingsdialog.ui
|
||||||
|
|
||||||
DBUS_INTERFACES += ../GPService/gpservice.xml
|
DBUS_INTERFACES += ../GPService/gpservice.xml
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "ui_gpclient.h"
|
#include "ui_gpclient.h"
|
||||||
#include "portalauthenticator.h"
|
#include "portalauthenticator.h"
|
||||||
#include "gatewayauthenticator.h"
|
#include "gatewayauthenticator.h"
|
||||||
|
#include "settingsdialog.h"
|
||||||
|
|
||||||
#include <plog/Log.h>
|
#include <plog/Log.h>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
@ -12,12 +13,16 @@ using namespace gpclient::helper;
|
|||||||
GPClient::GPClient(QWidget *parent)
|
GPClient::GPClient(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::GPClient)
|
, ui(new Ui::GPClient)
|
||||||
|
, settingsDialog(new SettingsDialog(this))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setWindowTitle("GlobalProtect");
|
setWindowTitle("GlobalProtect");
|
||||||
setFixedSize(width(), height());
|
setFixedSize(width(), height());
|
||||||
gpclient::helper::moveCenter(this);
|
gpclient::helper::moveCenter(this);
|
||||||
|
|
||||||
|
setupSettings();
|
||||||
|
|
||||||
// Restore portal from the previous settings
|
// Restore portal from the previous settings
|
||||||
ui->portalInput->setText(settings::get("portal", "").toString());
|
ui->portalInput->setText(settings::get("portal", "").toString());
|
||||||
|
|
||||||
@ -36,6 +41,37 @@ GPClient::~GPClient()
|
|||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
delete vpn;
|
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->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPClient::onSettingsAccepted()
|
||||||
|
{
|
||||||
|
settings::save("extraArgs", settingsDialog->extraArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPClient::on_connectButton_clicked()
|
void GPClient::on_connectButton_clicked()
|
||||||
@ -330,7 +366,7 @@ void GPClient::onGatewaySuccess(const QString &authCookie)
|
|||||||
PLOGI << "Gateway login succeeded, got the cookie " << authCookie;
|
PLOGI << "Gateway login succeeded, got the cookie " << authCookie;
|
||||||
|
|
||||||
isQuickConnect = false;
|
isQuickConnect = false;
|
||||||
vpn->connect(currentGateway().address(), portalConfig.username(), authCookie);
|
vpn->connect(currentGateway().address(), portalConfig.username(), authCookie, settings::get("extraArgs", "").toString());
|
||||||
ui->statusLabel->setText("Connecting...");
|
ui->statusLabel->setText("Connecting...");
|
||||||
updateConnectionStatus(VpnStatus::pending);
|
updateConnectionStatus(VpnStatus::pending);
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
#include "gpservice_interface.h"
|
#include "gpservice_interface.h"
|
||||||
#include "portalconfigresponse.h"
|
#include "portalconfigresponse.h"
|
||||||
|
#include "settingsdialog.h"
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class GPClient; }
|
namespace Ui { class GPClient; }
|
||||||
@ -23,6 +25,9 @@ public:
|
|||||||
void activate();
|
void activate();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void onSettingsButtonClicked();
|
||||||
|
void onSettingsAccepted();
|
||||||
|
|
||||||
void on_connectButton_clicked();
|
void on_connectButton_clicked();
|
||||||
void on_portalInput_returnPressed();
|
void on_portalInput_returnPressed();
|
||||||
void on_portalInput_editingFinished();
|
void on_portalInput_editingFinished();
|
||||||
@ -62,10 +67,15 @@ private:
|
|||||||
QAction *clearAction;
|
QAction *clearAction;
|
||||||
QAction *quitAction;
|
QAction *quitAction;
|
||||||
|
|
||||||
|
SettingsDialog *settingsDialog;
|
||||||
|
QPushButton *settingsButton;
|
||||||
|
|
||||||
bool isQuickConnect { false };
|
bool isQuickConnect { false };
|
||||||
bool isSwitchingGateway { false };
|
bool isSwitchingGateway { false };
|
||||||
PortalConfigResponse portalConfig;
|
PortalConfigResponse portalConfig;
|
||||||
|
|
||||||
|
void setupSettings();
|
||||||
|
|
||||||
void initSystemTrayIcon();
|
void initSystemTrayIcon();
|
||||||
void initVpnStatus();
|
void initVpnStatus();
|
||||||
void populateGatewayMenu();
|
void populateGatewayMenu();
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
<file>not_connected.png</file>
|
<file>not_connected.png</file>
|
||||||
<file>radio_unselected.png</file>
|
<file>radio_unselected.png</file>
|
||||||
<file>radio_selected.png</file>
|
<file>radio_selected.png</file>
|
||||||
|
<file>settings_icon.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
15
GPClient/settings_icon.svg
Normal file
15
GPClient/settings_icon.svg
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?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>
|
After Width: | Height: | Size: 1.2 KiB |
26
GPClient/settingsdialog.cpp
Normal file
26
GPClient/settingsdialog.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "settingsdialog.h"
|
||||||
|
#include "ui_settingsdialog.h"
|
||||||
|
|
||||||
|
SettingsDialog::SettingsDialog(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::SettingsDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->extraArgsInput->setPlaceholderText("e.g. --name=value");
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsDialog::~SettingsDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::setExtraArgs(QString args)
|
||||||
|
{
|
||||||
|
ui->extraArgsInput->setPlainText(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SettingsDialog::extraArgs()
|
||||||
|
{
|
||||||
|
return ui->extraArgsInput->toPlainText().trimmed();
|
||||||
|
}
|
25
GPClient/settingsdialog.h
Normal file
25
GPClient/settingsdialog.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#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);
|
||||||
|
QString extraArgs();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::SettingsDialog *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SETTINGSDIALOG_H
|
86
GPClient/settingsdialog.ui
Normal file
86
GPClient/settingsdialog.ui
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<?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>470</width>
|
||||||
|
<height>183</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="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Custom Parameters:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="extraArgsInput"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<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>
|
@ -49,7 +49,7 @@ void GPService::quit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPService::connect(QString server, QString username, QString passwd)
|
void GPService::connect(QString server, QString username, QString passwd, QString extraArgs)
|
||||||
{
|
{
|
||||||
if (vpnStatus != GPService::VpnNotConnected) {
|
if (vpnStatus != GPService::VpnNotConnected) {
|
||||||
log("VPN status is: " + QVariant::fromValue(vpnStatus).toString());
|
log("VPN status is: " + QVariant::fromValue(vpnStatus).toString());
|
||||||
@ -65,10 +65,13 @@ void GPService::connect(QString server, QString username, QString passwd)
|
|||||||
QStringList args;
|
QStringList args;
|
||||||
args << QCoreApplication::arguments().mid(1)
|
args << QCoreApplication::arguments().mid(1)
|
||||||
<< "--protocol=gp"
|
<< "--protocol=gp"
|
||||||
|
<< QProcess::splitCommand(extraArgs)
|
||||||
<< "-u" << username
|
<< "-u" << username
|
||||||
<< "-C" << passwd
|
<< "-C" << passwd
|
||||||
<< server;
|
<< server;
|
||||||
|
|
||||||
|
log("Start process with arugments: " + args.join(" "));
|
||||||
|
|
||||||
openconnect->start(bin, args);
|
openconnect->start(bin, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ signals:
|
|||||||
void logAvailable(QString log);
|
void logAvailable(QString log);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void connect(QString server, QString username, QString passwd);
|
void connect(QString server, QString username, QString passwd, QString extraArgs);
|
||||||
void disconnect();
|
void disconnect();
|
||||||
int status();
|
int status();
|
||||||
void quit();
|
void quit();
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<arg name="server" type="s" direction="in"/>
|
<arg name="server" type="s" direction="in"/>
|
||||||
<arg name="username" type="s" direction="in"/>
|
<arg name="username" type="s" direction="in"/>
|
||||||
<arg name="passwd" type="s" direction="in"/>
|
<arg name="passwd" type="s" direction="in"/>
|
||||||
|
<arg name="extraArgs" type="s" direction="in"/>
|
||||||
</method>
|
</method>
|
||||||
<method name="disconnect">
|
<method name="disconnect">
|
||||||
</method>
|
</method>
|
||||||
|
@ -12,6 +12,13 @@ A GlobalProtect VPN client (GUI) for Linux based on Openconnect and built with Q
|
|||||||
- Supports automatically selecting the preferred gateway from the multiple gateways.
|
- Supports automatically selecting the preferred gateway from the multiple gateways.
|
||||||
- Supports switching gateway from the system tray menu manually.
|
- Supports switching gateway from the system tray menu manually.
|
||||||
|
|
||||||
|
## Passing the Custom Parameters to `OpenConnect` CLI
|
||||||
|
|
||||||
|
Custom parameters can be appended to the `OpenConnect` CLI with the following settings.
|
||||||
|
<p align="center">
|
||||||
|
<img src="https://user-images.githubusercontent.com/3297602/129464304-94eb8a2b-1c4a-47e1-b931-4422fff6eb81.png" />
|
||||||
|
<p>
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- Openconnect v8.x
|
- Openconnect v8.x
|
||||||
|
Loading…
Reference in New Issue
Block a user