mirror of
https://github.com/chenx-dust/EZ4Connect.git
synced 2026-09-20 10:23:33 +08:00
feat: support atrust version
This commit is contained in:
1
.clang-format
Normal file
1
.clang-format
Normal file
@@ -0,0 +1 @@
|
||||
BasedOnStyle: Microsoft
|
||||
@@ -26,6 +26,7 @@ find_package(Qt6 COMPONENTS
|
||||
Network
|
||||
Svg
|
||||
Core5Compat
|
||||
WebEngineWidgets
|
||||
REQUIRED
|
||||
)
|
||||
|
||||
@@ -37,6 +38,7 @@ set(SOURCE_FILES
|
||||
extrasettingwindow/extrasettingwindow.cpp
|
||||
settingwindow/settingwindow.cpp
|
||||
loginwindow/loginwindow.cpp
|
||||
ssologinwebview/ssologinwebview.cpp
|
||||
utils/utils.cpp
|
||||
utils/proxysettings.cpp
|
||||
utils/coreversion.cpp
|
||||
@@ -88,6 +90,7 @@ target_link_libraries(${PROJECT_NAME}
|
||||
Qt::Network
|
||||
Qt::Svg
|
||||
Qt::Core5Compat
|
||||
Qt::WebEngineWidgets
|
||||
SingleApplication::SingleApplication
|
||||
${PLATFORM_LIBS}
|
||||
)
|
||||
|
||||
@@ -9,12 +9,9 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "ui_mainwindow.h"
|
||||
#include "zjuconnectcontroller/zjuconnectcontroller.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include "zjuconnectcontroller/zjuconnectcontroller.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
@@ -22,15 +19,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
{
|
||||
zjuConnectController = nullptr;
|
||||
|
||||
process = new QProcess(this);
|
||||
processForL2tp = new QProcess(this);
|
||||
processForL2tpCheck = new QProcess(this);
|
||||
processForWebLogin = new QProcess(this);
|
||||
settings = new QSettings(
|
||||
QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/config.ini",
|
||||
QSettings::IniFormat
|
||||
);
|
||||
l2tpCheckTimer = nullptr;
|
||||
diagnosisContext = nullptr;
|
||||
|
||||
upgradeSettings();
|
||||
@@ -325,6 +317,10 @@ void MainWindow::upgradeSettings()
|
||||
{
|
||||
Utils::resetDefaultSettings(*settings);
|
||||
}
|
||||
else if (configVersion == 4)
|
||||
{
|
||||
settings->setValue("ZJUConnect/Protocol", "easyconnect");
|
||||
}
|
||||
else if (configVersion < Utils::CONFIG_VERSION)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
|
||||
10
mainwindow.h
10
mainwindow.h
@@ -9,7 +9,7 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "loginwindow/loginwindow.h"
|
||||
#include "extrasettingwindow/extrasettingwindow.h"
|
||||
#include "ssologinwebview/ssologinwebview.h"
|
||||
#include "zjuconnectcontroller/zjuconnectcontroller.h"
|
||||
#include "settingwindow/settingwindow.h"
|
||||
|
||||
@@ -71,16 +71,12 @@ private:
|
||||
QNetworkAccessManager *checkUpdateNAM;
|
||||
QNetworkAccessManager *checkCoreUpdateNAM;
|
||||
QSettings *settings;
|
||||
QProcess *process;
|
||||
QProcess *processForL2tp;
|
||||
QProcess *processForL2tpCheck;
|
||||
QProcess *processForWebLogin;
|
||||
QTimer *l2tpCheckTimer;
|
||||
|
||||
QObject *diagnosisContext;
|
||||
|
||||
SettingWindow *settingWindow;
|
||||
LoginWindow *login_window;
|
||||
LoginWindow *loginWindow;
|
||||
SsoLoginWebView *ssoLoginWebView;
|
||||
|
||||
bool isFirstTimeSetMode;
|
||||
|
||||
|
||||
@@ -78,6 +78,12 @@ Line 2
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
@@ -140,7 +146,7 @@ Line 2
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>33</height>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
@@ -189,6 +195,14 @@ Line 2
|
||||
<string>设置</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="webLoginAction">
|
||||
<property name="text">
|
||||
<string>SSO 登录</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>打开校园网 SSO 登录窗口</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="disableProxyAction">
|
||||
<property name="text">
|
||||
<string>清除系统代理</string>
|
||||
|
||||
@@ -41,15 +41,17 @@ SettingWindow::SettingWindow(QWidget *parent, QSettings *inputSettings) :
|
||||
extraSettingWindow->show();
|
||||
});
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, [&](){
|
||||
if (!Utils::credentialCheck(ui->usernameLineEdit->text(), ui->passwordLineEdit->text()))
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, [&]() {
|
||||
if (!(ui->atrustRadioButton->isChecked() && ui->casRadioButton->isChecked()) &&
|
||||
!Utils::credentialCheck(ui->usernameLineEdit->text(), ui->passwordLineEdit->text()))
|
||||
return;
|
||||
applySettings();
|
||||
accept();
|
||||
});
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, [&](){
|
||||
if (!Utils::credentialCheck(ui->usernameLineEdit->text(), ui->passwordLineEdit->text()))
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, [&]() {
|
||||
if (!(ui->atrustRadioButton->isChecked() && ui->casRadioButton->isChecked()) &&
|
||||
!Utils::credentialCheck(ui->usernameLineEdit->text(), ui->passwordLineEdit->text()))
|
||||
return;
|
||||
applySettings();
|
||||
loadSettings();
|
||||
@@ -103,19 +105,6 @@ SettingWindow::SettingWindow(QWidget *parent, QSettings *inputSettings) :
|
||||
QFile::copy(settings->fileName(), filename);
|
||||
});
|
||||
|
||||
connect(ui->tunCheckBox, &QCheckBox::toggled,
|
||||
[&](bool checked)
|
||||
{
|
||||
ui->routeCheckBox->setEnabled(checked);
|
||||
ui->dnsHijackCheckBox->setEnabled(checked);
|
||||
});
|
||||
|
||||
connect(ui->dnsAutoCheckBox, &QCheckBox::toggled,
|
||||
[&](bool checked)
|
||||
{
|
||||
ui->dnsLineEdit->setEnabled(!checked);
|
||||
});
|
||||
|
||||
connect(ui->passwordVisibleCheckBox, &QCheckBox::checkStateChanged,
|
||||
[&](Qt::CheckState state)
|
||||
{
|
||||
@@ -166,6 +155,16 @@ void SettingWindow::loadSettings()
|
||||
ui->shadowsocksUrlLineEdit->setText(settings->value("ZJUConnect/ShadowsocksURL").toString());
|
||||
ui->dialDirectProxyLineEdit->setText(settings->value("ZJUConnect/DialDirectProxy").toString());
|
||||
|
||||
if (settings->value("ZJUConnect/Protocol").toString() == "atrust")
|
||||
ui->atrustRadioButton->setChecked(true);
|
||||
else
|
||||
ui->easyconnectRadioButton->setChecked(true);
|
||||
ui->loginDomainLineEdit->setText(settings->value("ZJUConnect/LoginDomain").toString());
|
||||
if (settings->value("ZJUConnect/AuthType").toString() == "cas")
|
||||
ui->casRadioButton->setChecked(true);
|
||||
else
|
||||
ui->pswRadioButton->setChecked(true);
|
||||
ui->casLoginUrlLineEdit->setText(settings->value("ZJUConnect/CasLoginURL").toString());
|
||||
|
||||
ui->multiLineCheckBox->setChecked(settings->value("ZJUConnect/MultiLine").toBool());
|
||||
ui->keepAliveCheckBox->setChecked(settings->value("ZJUConnect/KeepAlive").toBool());
|
||||
@@ -224,6 +223,10 @@ void SettingWindow::applySettings()
|
||||
settings->setValue("ZJUConnect/ShadowsocksURL", ui->shadowsocksUrlLineEdit->text());
|
||||
settings->setValue("ZJUConnect/DialDirectProxy", ui->dialDirectProxyLineEdit->text());
|
||||
|
||||
settings->setValue("ZJUConnect/Protocol", ui->atrustRadioButton->isChecked() ? "atrust" : "easyconnect");
|
||||
settings->setValue("ZJUConnect/LoginDomain", ui->loginDomainLineEdit->text());
|
||||
settings->setValue("ZJUConnect/AuthType", ui->casRadioButton->isChecked() ? "cas" : "psw");
|
||||
settings->setValue("ZJUConnect/CasLoginURL", ui->casLoginUrlLineEdit->text());
|
||||
|
||||
settings->setValue("ZJUConnect/MultiLine", ui->multiLineCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/KeepAlive", ui->keepAliveCheckBox->isChecked());
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>486</width>
|
||||
<height>500</height>
|
||||
<width>514</width>
|
||||
<height>519</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -29,94 +29,7 @@
|
||||
<attribute name="title">
|
||||
<string>通用</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="credentialGroup">
|
||||
<property name="title">
|
||||
<string>保存的信息</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="4" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Policy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLineEdit" name="totpSecretLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::EchoMode::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>可选,以通过 TOTP 验证器</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="commonTabLable3">
|
||||
<property name="text">
|
||||
<string>密码</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="commonTabLable2">
|
||||
<property name="text">
|
||||
<string>账号</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel6_2">
|
||||
<property name="text">
|
||||
<string>TOTP 密钥</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="passwordLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::EchoMode::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>VPN 密码</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QCheckBox" name="passwordVisibleCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QLineEdit" name="usernameLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>VPN 账号</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QCheckBox" name="totpSecretVisibleCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout">
|
||||
<item row="7" column="0">
|
||||
<spacer name="commonTabVerticalSpacer">
|
||||
<property name="orientation">
|
||||
@@ -217,6 +130,12 @@
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="2">
|
||||
@@ -270,6 +189,9 @@
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="reconnectTimeSpinBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>86400</number>
|
||||
</property>
|
||||
@@ -299,6 +221,232 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="loginTab">
|
||||
<attribute name="title">
|
||||
<string>登录</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="authInfoGroupBox">
|
||||
<property name="title">
|
||||
<string>认证信息(aTrust)</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>认证方式</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QRadioButton" name="casRadioButton">
|
||||
<property name="text">
|
||||
<string>单点认证</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QRadioButton" name="pswRadioButton">
|
||||
<property name="text">
|
||||
<string>密码</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="loginDomainLineEdit">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>可自动获取,默认 local</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QPushButton" name="authSelectPushButton">
|
||||
<property name="text">
|
||||
<string>获取认证方式</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Policy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>登录域</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>单点认证地址</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="casLoginUrlLineEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>可自动获取,仅用于单点登录</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="protocolGroupBox">
|
||||
<property name="title">
|
||||
<string>协议</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="atrustRadioButton">
|
||||
<property name="text">
|
||||
<string>aTrust</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="easyconnectRadioButton">
|
||||
<property name="text">
|
||||
<string>EasyConnect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="credentialGroup">
|
||||
<property name="title">
|
||||
<string>保存的信息</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="3" column="2">
|
||||
<widget class="QLineEdit" name="totpSecretLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::EchoMode::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>可选,以通过 TOTP 验证器</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="commonTabLable2">
|
||||
<property name="text">
|
||||
<string>账号</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="passwordLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::EchoMode::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>VPN 密码</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QCheckBox" name="passwordVisibleCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" colspan="2">
|
||||
<widget class="QLineEdit" name="usernameLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>VPN 账号</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel6_2">
|
||||
<property name="text">
|
||||
<string>TOTP 密钥</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Policy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QCheckBox" name="totpSecretVisibleCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="commonTabLable3">
|
||||
<property name="text">
|
||||
<string>密码</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="zjuConnectTab">
|
||||
<attribute name="title">
|
||||
<string>核心</string>
|
||||
@@ -407,7 +555,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="serverAddressLineEdit">
|
||||
<property name="text">
|
||||
<string>vpn.hitsz.edu.cn</string>
|
||||
<string>trust.hitsz.edu.cn</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -622,5 +770,101 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>atrustRadioButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>authInfoGroupBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>255</x>
|
||||
<y>72</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>256</x>
|
||||
<y>186</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>casRadioButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>casLoginUrlLineEdit</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>397</x>
|
||||
<y>221</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>327</x>
|
||||
<y>247</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>dnsAutoCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>dnsLineEdit</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>445</x>
|
||||
<y>85</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>282</x>
|
||||
<y>85</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>tunCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>routeCheckBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>108</x>
|
||||
<y>379</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>256</x>
|
||||
<y>379</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>tunCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>dnsHijackCheckBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>108</x>
|
||||
<y>379</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>405</x>
|
||||
<y>379</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>autoReconnectCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>reconnectTimeSpinBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>463</x>
|
||||
<y>173</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>311</x>
|
||||
<y>173</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
||||
82
ssologinwebview/ssologinwebview.cpp
Normal file
82
ssologinwebview/ssologinwebview.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#include "ssologinwebview.h"
|
||||
#include "ui_ssologinwebview.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLineEdit>
|
||||
#include <QToolButton>
|
||||
#include <QWebEngineHistory>
|
||||
#include <QWebEngineView>
|
||||
#include <QWebEnginePage>
|
||||
#include <QtWebEngineCore>
|
||||
#include <QUrl>
|
||||
|
||||
SsoLoginWebView::SsoLoginWebView(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::SsoLoginWebView)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setModal(true);
|
||||
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
SsoLoginWebView::~SsoLoginWebView()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SsoLoginWebView::setupConnections()
|
||||
{
|
||||
connect(ui->backButton, &QToolButton::clicked, ui->webEngineView, &QWebEngineView::back);
|
||||
connect(ui->forwardButton, &QToolButton::clicked, ui->webEngineView, &QWebEngineView::forward);
|
||||
connect(ui->reloadButton, &QToolButton::clicked, ui->webEngineView, &QWebEngineView::reload);
|
||||
|
||||
connect(ui->addressLineEdit, &QLineEdit::returnPressed, this, [&]()
|
||||
{
|
||||
const QUrl target = QUrl::fromUserInput(ui->addressLineEdit->text());
|
||||
ui->webEngineView->load(target);
|
||||
});
|
||||
|
||||
connect(ui->webEngineView, &QWebEngineView::urlChanged, this, [&](const QUrl &url)
|
||||
{
|
||||
ui->addressLineEdit->setText(url.toString());
|
||||
});
|
||||
|
||||
connect(ui->webEngineView->page(), &QWebEnginePage::navigationRequested, this,
|
||||
[&](QWebEngineNavigationRequest &request) {
|
||||
if (request.navigationType() == QWebEngineNavigationRequest::NavigationType::RedirectNavigation &&
|
||||
request.url().host() == callbackServerHost)
|
||||
{
|
||||
QUrlQuery queries(request.url());
|
||||
loginCompleted(queries.queryItemValue("ticket"));
|
||||
request.reject();
|
||||
this->close();
|
||||
}
|
||||
else
|
||||
request.accept();
|
||||
});
|
||||
|
||||
|
||||
connect(ui->dialogButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
void SsoLoginWebView::setInitialUrl(const QUrl &url)
|
||||
{
|
||||
if (!url.isEmpty())
|
||||
{
|
||||
ui->addressLineEdit->setText(url.toString());
|
||||
ui->webEngineView->load(url);
|
||||
}
|
||||
}
|
||||
|
||||
void SsoLoginWebView::setCallbackServerHost(const QString &host)
|
||||
{
|
||||
callbackServerHost = host;
|
||||
}
|
||||
|
||||
QUrl SsoLoginWebView::currentUrl() const
|
||||
{
|
||||
return ui->webEngineView->url();
|
||||
}
|
||||
35
ssologinwebview/ssologinwebview.h
Normal file
35
ssologinwebview/ssologinwebview.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef SSOLOGINWEBVIEW_H
|
||||
#define SSOLOGINWEBVIEW_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QUrl>
|
||||
#include <QString>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SsoLoginWebView;
|
||||
}
|
||||
|
||||
class SsoLoginWebView : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SsoLoginWebView(QWidget *parent = nullptr);
|
||||
~SsoLoginWebView() override;
|
||||
|
||||
void setInitialUrl(const QUrl &url);
|
||||
void setCallbackServerHost(const QString &host);
|
||||
QUrl currentUrl() const;
|
||||
|
||||
signals:
|
||||
void loginCompleted(const QString &ticket);
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
|
||||
Ui::SsoLoginWebView *ui;
|
||||
QString callbackServerHost;
|
||||
};
|
||||
|
||||
#endif // SSOLOGINWEBVIEW_H
|
||||
99
ssologinwebview/ssologinwebview.ui
Normal file
99
ssologinwebview/ssologinwebview.ui
Normal file
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SsoLoginWebView</class>
|
||||
<widget class="QDialog" name="SsoLoginWebView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>640</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SSO 登录</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="_2">
|
||||
<item>
|
||||
<widget class="QWidget" name="navigationWidget" native="true">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="backButton">
|
||||
<property name="toolTip">
|
||||
<string>后退</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>⬅️</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="forwardButton">
|
||||
<property name="toolTip">
|
||||
<string>前进</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>➡️</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="reloadButton">
|
||||
<property name="toolTip">
|
||||
<string>重新载入</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>🔄</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="addressLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWebEngineView" name="webEngineView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="dialogButtonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QWebEngineView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">QtWebEngineWidgets/QWebEngineView</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -306,7 +306,7 @@ void Utils::resetDefaultSettings(QSettings& settings)
|
||||
settings.setValue("Common/SystemProxyBypass", "");
|
||||
|
||||
|
||||
settings.setValue("ZJUConnect/ServerAddress", "vpn.hitsz.edu.cn");
|
||||
settings.setValue("ZJUConnect/ServerAddress", "trust.hitsz.edu.cn");
|
||||
settings.setValue("ZJUConnect/ServerPort", 443);
|
||||
settings.setValue("ZJUConnect/DNS", "");
|
||||
settings.setValue("ZJUConnect/DNSAuto", true);
|
||||
@@ -317,6 +317,9 @@ void Utils::resetDefaultSettings(QSettings& settings)
|
||||
settings.setValue("ZJUConnect/ShadowsocksURL", "");
|
||||
settings.setValue("ZJUConnect/DialDirectProxy", "");
|
||||
|
||||
settings.setValue("ZJUConnect/Protocol", "atrust");
|
||||
settings.setValue("ZJUConnect/LoginDomain", "hitcas");
|
||||
settings.setValue("ZJUConnect/AuthType", "cas");
|
||||
|
||||
settings.setValue("ZJUConnect/MultiLine", false);
|
||||
settings.setValue("ZJUConnect/KeepAlive", false);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Utils
|
||||
|
||||
const inline QString APP_NAME("EZ4Connect");
|
||||
|
||||
constexpr inline int CONFIG_VERSION = 4;
|
||||
constexpr inline int CONFIG_VERSION = 5;
|
||||
|
||||
QString ConsoleOutputToQString(const QByteArray &byteArray);
|
||||
|
||||
|
||||
@@ -74,6 +74,10 @@ ZjuConnectController::ZjuConnectController()
|
||||
|
||||
void ZjuConnectController::start(
|
||||
const QString& program,
|
||||
const QString& protocol,
|
||||
const QString& authType,
|
||||
const QString& loginDomain,
|
||||
const QString& casTicket,
|
||||
const QString& username,
|
||||
const QString& password,
|
||||
const QString& totpSecret,
|
||||
@@ -107,6 +111,30 @@ void ZjuConnectController::start(
|
||||
{
|
||||
QStringList args;
|
||||
|
||||
if (!protocol.isEmpty())
|
||||
{
|
||||
args.append("-protocol");
|
||||
args.append(protocol);
|
||||
}
|
||||
|
||||
if (!authType.isEmpty())
|
||||
{
|
||||
args.append("-auth-type");
|
||||
args.append("auth/" + authType);
|
||||
}
|
||||
|
||||
if (!loginDomain.isEmpty())
|
||||
{
|
||||
args.append("-login-domain");
|
||||
args.append(loginDomain);
|
||||
}
|
||||
|
||||
if (!casTicket.isEmpty())
|
||||
{
|
||||
args.append("-cas-ticket");
|
||||
args.append(casTicket);
|
||||
}
|
||||
|
||||
if (!server.isEmpty())
|
||||
{
|
||||
args.append("-server");
|
||||
@@ -255,10 +283,19 @@ void ZjuConnectController::start(
|
||||
QString timeString = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
|
||||
emit outputRead(timeString + " VPN 启动!参数:" + args.join(' '));
|
||||
|
||||
QStringList credentialList({
|
||||
"-username", username,
|
||||
"-password", password,
|
||||
});
|
||||
QStringList credentialList;
|
||||
|
||||
if (!username.isEmpty())
|
||||
{
|
||||
credentialList.append("-username");
|
||||
credentialList.append(username);
|
||||
}
|
||||
|
||||
if (!password.isEmpty())
|
||||
{
|
||||
credentialList.append("-password");
|
||||
credentialList.append(password);
|
||||
}
|
||||
|
||||
if (!totpSecret.isEmpty())
|
||||
{
|
||||
|
||||
@@ -27,6 +27,10 @@ public:
|
||||
|
||||
void start(
|
||||
const QString& program,
|
||||
const QString& protocol,
|
||||
const QString& authType,
|
||||
const QString& loginDomain,
|
||||
const QString& casTicket,
|
||||
const QString& username,
|
||||
const QString& password,
|
||||
const QString& totpSecret,
|
||||
|
||||
@@ -113,8 +113,10 @@ void MainWindow::initZjuConnect()
|
||||
|
||||
QString username_ = settings->value("Credential/Username", "").toString();
|
||||
QString password_ = QByteArray::fromBase64(settings->value("Credential/Password", "").toString().toUtf8());
|
||||
QString protocol = settings->value("ZJUConnect/Protocol", "easyconnect").toString();
|
||||
QString authtype = settings->value("ZJUConnect/AuthType", "psw").toString();
|
||||
|
||||
auto startZjuConnect = [this](const QString &username, const QString &password) {
|
||||
auto startZjuConnect = [this](const QString &username, const QString &password, const QString &casTicket) {
|
||||
QString program_path = Utils::getCorePath();
|
||||
QString bind_prefix = settings->value("ZJUConnect/OutsideAccess", false).toBool() ? "[::]:" : "127.0.0.1:";
|
||||
|
||||
@@ -128,9 +130,9 @@ void MainWindow::initZjuConnect()
|
||||
}
|
||||
|
||||
zjuConnectController->start(
|
||||
program_path,
|
||||
username,
|
||||
password,
|
||||
program_path, settings->value("ZJUConnect/Protocol").toString(),
|
||||
settings->value("ZJUConnect/AuthType").toString(),
|
||||
settings->value("ZJUConnect/LoginDomain").toString(), casTicket, username, password,
|
||||
settings->value("Credential/TOTPSecret").toString(),
|
||||
settings->value("ZJUConnect/ServerAddress").toString(),
|
||||
settings->value("ZJUConnect/ServerPort").toInt(),
|
||||
@@ -157,16 +159,31 @@ void MainWindow::initZjuConnect()
|
||||
settings->value("ZJUConnect/UdpPortForwarding").toString(),
|
||||
settings->value("ZJUConnect/CustomDNS", "").toString(),
|
||||
settings->value("ZJUConnect/CustomProxyDomain", "").toString(),
|
||||
settings->value("ZJUConnect/ExtraArguments", "").toString()
|
||||
);
|
||||
settings->value("ZJUConnect/ExtraArguments", "").toString());
|
||||
};
|
||||
|
||||
if (username_.isEmpty() || password_.isEmpty())
|
||||
if (protocol == "atrust" && authtype == "cas")
|
||||
{
|
||||
login_window = new LoginWindow(this);
|
||||
login_window->setDetail(username_, password_);
|
||||
ssoLoginWebView = new SsoLoginWebView(this);
|
||||
connect(ssoLoginWebView, &SsoLoginWebView::loginCompleted, [=](const QString &ticket) {
|
||||
startZjuConnect(username_, password_, ticket);
|
||||
});
|
||||
|
||||
connect(login_window, &LoginWindow::login, this,
|
||||
const QString ssoUrl = settings->value("ZJUConnect/CasLoginURL", "about:blank").toString();
|
||||
|
||||
addLog(QStringLiteral("单点登录:") + ssoUrl);
|
||||
ssoLoginWebView->setInitialUrl(QUrl::fromUserInput(ssoUrl));
|
||||
ssoLoginWebView->setCallbackServerHost(settings->value("ZJUConnect/ServerAddress", "trust.hitsz.edu.cn").toString());
|
||||
ssoLoginWebView->show();
|
||||
ssoLoginWebView->raise();
|
||||
ssoLoginWebView->activateWindow();
|
||||
}
|
||||
else if (username_.isEmpty() || password_.isEmpty())
|
||||
{
|
||||
loginWindow = new LoginWindow(this);
|
||||
loginWindow->setDetail(username_, password_);
|
||||
|
||||
connect(loginWindow, &LoginWindow::login, this,
|
||||
[&, startZjuConnect](const QString& username, const QString& password, bool saveDetail)
|
||||
{
|
||||
if (saveDetail)
|
||||
@@ -175,14 +192,14 @@ void MainWindow::initZjuConnect()
|
||||
settings->setValue("Credential/Password", QString(password.toUtf8().toBase64()));
|
||||
settings->sync();
|
||||
}
|
||||
startZjuConnect(username, password);
|
||||
startZjuConnect(username, password, "");
|
||||
}
|
||||
);
|
||||
login_window->show();
|
||||
loginWindow->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
startZjuConnect(username_, password_);
|
||||
startZjuConnect(username_, password_, "");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user