mirror of
https://github.com/chenx-dust/EZ4Connect.git
synced 2026-09-20 10:23:33 +08:00
feat: support many new settings;
refactor: config format
This commit is contained in:
@@ -34,7 +34,7 @@ set(SOURCE_FILES
|
||||
mainwindow.cpp
|
||||
zjuconnectmode.cpp
|
||||
zjuconnectcontroller/zjuconnectcontroller.cpp
|
||||
portforwardingwindow/portforwardingwindow.cpp
|
||||
extrasettingwindow/extrasettingwindow.cpp
|
||||
settingwindow/settingwindow.cpp
|
||||
loginwindow/loginwindow.cpp
|
||||
utils/utils.cpp
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
- [X] 支持 Linux 系统
|
||||
- [X] 支持手动设置 Proxy Bypass
|
||||
- [ ] 上传 AUR 包
|
||||
- [ ] 使用密钥链存储密码等信息
|
||||
|
||||
## 相关项目
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "portforwardingwindow.h"
|
||||
#include "ui_portforwardingwindow.h"
|
||||
#include "extrasettingwindow.h"
|
||||
#include "ui_extrasettingwindow.h"
|
||||
|
||||
PortForwardingWindow::PortForwardingWindow(QDialog *parent) :
|
||||
ExtraSettingWindow::ExtraSettingWindow(QDialog *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PortForwardingWindow)
|
||||
ui(new Ui::ExtraSettingWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -20,7 +20,7 @@ PortForwardingWindow::PortForwardingWindow(QDialog *parent) :
|
||||
QStringList tcpPortForwardingList;
|
||||
QStringList udpPortForwardingList;
|
||||
|
||||
QStringList portForwardingList = ui->textEdit->toPlainText().split("\n");
|
||||
QStringList portForwardingList = ui->forwardTextEdit->toPlainText().split("\n");
|
||||
|
||||
for (const auto &forwarding: portForwardingList)
|
||||
{
|
||||
@@ -43,17 +43,38 @@ PortForwardingWindow::PortForwardingWindow(QDialog *parent) :
|
||||
}
|
||||
}
|
||||
|
||||
emit applied(tcpPortForwardingList.join(","), udpPortForwardingList.join(","));
|
||||
QStringList customDnsList;
|
||||
|
||||
for (const auto& hosts : ui->hostsTextEdit->toPlainText().split("\n"))
|
||||
{
|
||||
QStringList hostsItem = hosts.split(" ");
|
||||
if (hostsItem.size() == 2)
|
||||
{
|
||||
customDnsList.append(
|
||||
hostsItem[1].simplified() + ":" + hostsItem[0].simplified()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList customProxyDomainsList = ui->proxyTextEdit->toPlainText().split("\n");
|
||||
|
||||
emit applied(
|
||||
tcpPortForwardingList.join(","),
|
||||
udpPortForwardingList.join(","),
|
||||
customDnsList.join(","),
|
||||
customProxyDomainsList.join(","),
|
||||
ui->extraArgTextEdit->toPlainText().replace("\n", " ")
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
PortForwardingWindow::~PortForwardingWindow()
|
||||
ExtraSettingWindow::~ExtraSettingWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PortForwardingWindow::setPortForwarding(const QString &tcpPortForwarding, const QString &udpPortForwarding)
|
||||
void ExtraSettingWindow::setup(const QString& tcpPortForwarding, const QString& udpPortForwarding, const QString& customDns, const QString& customProxyDomains, const QString& extraArguments)
|
||||
{
|
||||
QStringList tcpPortForwardingList = tcpPortForwarding.split(",");
|
||||
|
||||
@@ -63,7 +84,7 @@ void PortForwardingWindow::setPortForwarding(const QString &tcpPortForwarding, c
|
||||
|
||||
if (tcpPortForwardingItem.size() == 2)
|
||||
{
|
||||
ui->textEdit->append(
|
||||
ui->forwardTextEdit->append(
|
||||
"TCP," + tcpPortForwardingItem[0].simplified() + "," + tcpPortForwardingItem[1].simplified()
|
||||
);
|
||||
}
|
||||
@@ -77,9 +98,32 @@ void PortForwardingWindow::setPortForwarding(const QString &tcpPortForwarding, c
|
||||
|
||||
if (udpPortForwardingItem.size() == 2)
|
||||
{
|
||||
ui->textEdit->append(
|
||||
ui->forwardTextEdit->append(
|
||||
"UDP," + udpPortForwardingItem[0].simplified() + "," + udpPortForwardingItem[1].simplified()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList customDnsList = customDns.split(",");
|
||||
|
||||
for (const auto& hosts : customDnsList)
|
||||
{
|
||||
QStringList hostsItem = hosts.split(":");
|
||||
|
||||
if (hostsItem.size() == 2)
|
||||
{
|
||||
ui->hostsTextEdit->append(
|
||||
hostsItem[1].simplified() + " " + hostsItem[0].simplified()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList customProxyDomainsList = customProxyDomains.split(",");
|
||||
|
||||
for (const auto& domain : customProxyDomainsList)
|
||||
{
|
||||
ui->proxyTextEdit->append(domain.trimmed());
|
||||
}
|
||||
|
||||
ui->extraArgTextEdit->setPlainText(extraArguments);
|
||||
}
|
||||
30
extrasettingwindow/extrasettingwindow.h
Normal file
30
extrasettingwindow/extrasettingwindow.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef EXTRASETTINGWINDOW_H
|
||||
#define EXTRASETTINGWINDOW_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_extrasettingwindow.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ExtraSettingWindow;
|
||||
}
|
||||
|
||||
class ExtraSettingWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExtraSettingWindow(QDialog *parent = nullptr);
|
||||
|
||||
~ExtraSettingWindow() override;
|
||||
|
||||
void setup(const QString &tcpPortForwarding, const QString &udpPortForwarding, const QString &customDns, const QString &customProxyDomains, const QString &extraArguments);
|
||||
|
||||
signals:
|
||||
void applied(const QString &tcpPortForwarding, const QString &udpPortForwarding, const QString& customDns, const QString& customProxyDomains, const QString& extraArguments);
|
||||
|
||||
private:
|
||||
Ui::ExtraSettingWindow *ui;
|
||||
};
|
||||
|
||||
#endif //EXTRASETTINGWINDOW_H
|
||||
202
extrasettingwindow/extrasettingwindow.ui
Normal file
202
extrasettingwindow/extrasettingwindow.ui
Normal file
@@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ExtraSettingWindow</class>
|
||||
<widget class="QDialog" name="ExtraSettingWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>509</width>
|
||||
<height>863</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>其他设置</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>端口转发</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>在下面的输入框内输入端口转发规则,一行一条规则</p><p>例如,在内网主机 10.10.98.98 的 13389 端口上存在 RDP 远程桌面服务(TCP 协议),<br/>需要将其转发到本机 127.0.0.1:9850 使用,规则为:<br/><span style=" font-weight:700;">TCP,127.0.0.1:9850,10.10.98.98:13389</span></p><p>支持的协议:TCP、UDP</p></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="forwardTextEdit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Consolas</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>TCP,127.0.0.1:9850,10.10.98.98:13389
|
||||
UDP,127.0.0.1:25565,10.248.98.98:25565</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>自定义 DNS 解析(Hosts)</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>在下面的输入框内输入解析规则,一行一条规则</p><p>例如,将 google.com 解析为 127.0.0.1,规则为:<br/><span style=" font-weight:700;">127.0.0.1 google.com</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="hostsTextEdit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Consolas</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>8.8.8.8 dns.google
|
||||
127.0.0.1 www.mihoyo.com</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>强制 VPN 分流域名</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>在下面的输入框内输入强制 VPN 分流规则,一行一条规则</p><p>例如,要将 www.cnki.net 强制走 VPN 分流,规则为:<br/><span style=" font-weight:700;">www.cnki.net</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="proxyTextEdit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Consolas</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>www.cnki.net</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>额外参数</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>在下面的输入框内输入额外的内核参数,可以用回车代替空格</p></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="extraArgTextEdit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Consolas</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>--version</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ExtraSettingWindow</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>244</x>
|
||||
<y>295</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>244</x>
|
||||
<y>158</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ExtraSettingWindow</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>244</x>
|
||||
<y>295</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>244</x>
|
||||
<y>158</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "loginwindow/loginwindow.h"
|
||||
#include "portforwardingwindow/portforwardingwindow.h"
|
||||
#include "extrasettingwindow/extrasettingwindow.h"
|
||||
#include "zjuconnectcontroller/zjuconnectcontroller.h"
|
||||
#include "settingwindow/settingwindow.h"
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef PORTFORWARDINGWINDOW_H
|
||||
#define PORTFORWARDINGWINDOW_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_portforwardingwindow.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PortForwardingWindow;
|
||||
}
|
||||
|
||||
class PortForwardingWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PortForwardingWindow(QDialog *parent = nullptr);
|
||||
|
||||
~PortForwardingWindow() override;
|
||||
|
||||
void setPortForwarding(const QString &tcpPortForwarding, const QString &udpPortForwarding);
|
||||
|
||||
signals:
|
||||
void applied(const QString &tcpPortForwarding, const QString &udpPortForwarding);
|
||||
|
||||
private:
|
||||
Ui::PortForwardingWindow *ui;
|
||||
};
|
||||
|
||||
#endif //PORTFORWARDINGWINDOW_H
|
||||
@@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PortForwardingWindow</class>
|
||||
<widget class="QDialog" name="PortForwardingWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>489</width>
|
||||
<height>317</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>端口转发</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
hr { height: 1px; border-width: 0; }
|
||||
li.unchecked::marker { content: "\2610"; }
|
||||
li.checked::marker { content: "\2612"; }
|
||||
</style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>在下面的输入框内输入端口转发规则,一行一条规则</p><p>例如,在内网主机 10.10.98.98 的 13389 端口上存在 RDP 远程桌面服务(TCP 协议),<br/>需要将其转发到本机 127.0.0.1:9850 使用,规则为:<br/><span style=" font-weight:700;">TCP,127.0.0.1:9850,10.10.98.98:13389</span></p><p>例如,在内网主机 10.10.98.98 的 2222 端口上存在 SSH 服务(TCP 协议),<br/>需要将其转发到本机 9852 端口供本机和 LAN 下其他设备使用,规则为:<br/><span style=" font-weight:700;">TCP,0.0.0.0:9852,10.10.98.98:2222</span></p><p>支持的协议:TCP、UDP</p><p>输入后点击确定并应用,断开并重新连接后方可生效</p></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>PortForwardingWindow</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>244</x>
|
||||
<y>295</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>244</x>
|
||||
<y>158</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>PortForwardingWindow</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>244</x>
|
||||
<y>295</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>244</x>
|
||||
<y>158</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -25,70 +25,34 @@ SettingWindow::SettingWindow(QWidget *parent, QSettings *inputSettings) :
|
||||
connect(ui->portForwardingPushButton, &QPushButton::clicked,
|
||||
[&]()
|
||||
{
|
||||
portForwardingWindow = new PortForwardingWindow(this);
|
||||
portForwardingWindow->setPortForwarding(tcpPortForwarding, udpPortForwarding);
|
||||
extraSettingWindow = new ExtraSettingWindow(this);
|
||||
extraSettingWindow->setup(tcpPortForwarding, udpPortForwarding, customDNS, customProxyDomain, extraArguments);
|
||||
|
||||
connect(portForwardingWindow, &PortForwardingWindow::applied, this,
|
||||
[&](const QString &tcpForwarding, const QString &udpForwarding)
|
||||
{
|
||||
tcpPortForwarding = tcpForwarding;
|
||||
udpPortForwarding = udpForwarding;
|
||||
});
|
||||
connect(extraSettingWindow, &ExtraSettingWindow::applied, this,
|
||||
[&](const QString& tcpForwarding, const QString& udpForwarding, const QString& customDNS_, const QString& customProxyDomain_, const QString& extraArg)
|
||||
{
|
||||
tcpPortForwarding = tcpForwarding;
|
||||
udpPortForwarding = udpForwarding;
|
||||
customDNS = customDNS_;
|
||||
customProxyDomain = customProxyDomain_;
|
||||
extraArguments = extraArg;
|
||||
});
|
||||
|
||||
portForwardingWindow->show();
|
||||
extraSettingWindow->show();
|
||||
});
|
||||
|
||||
auto applySettings = [&]()
|
||||
{
|
||||
if (settings->value("Common/AutoStart").toBool() != ui->autoStartCheckBox->isChecked())
|
||||
Utils::setAutoStart(ui->autoStartCheckBox->isChecked());
|
||||
|
||||
settings->setValue("Common/Username", ui->usernameLineEdit->text());
|
||||
settings->setValue("Common/Password", QString(ui->passwordLineEdit->text().toUtf8().toBase64()));
|
||||
settings->setValue("Common/AutoStart", ui->autoStartCheckBox->isChecked());
|
||||
settings->setValue("Common/ConnectAfterStart", ui->connectAfterStartCheckBox->isChecked());
|
||||
settings->setValue("Common/CheckUpdateAfterStart", ui->checkUpdateAfterStartCheckBox->isChecked());
|
||||
|
||||
settings->setValue("ZJUConnect/ServerAddress", ui->serverAddressLineEdit->text());
|
||||
settings->setValue("ZJUConnect/ServerPort", ui->serverPortSpinBox->value());
|
||||
settings->setValue("ZJUConnect/DNS", ui->dnsLineEdit->text());
|
||||
settings->setValue("ZJUConnect/DNSAuto", ui->dnsAutoCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/Socks5Port", ui->socks5PortSpinBox->value());
|
||||
settings->setValue("ZJUConnect/HttpPort", ui->httpPortSpinBox->value());
|
||||
settings->setValue("ZJUConnect/MultiLine", ui->multiLineCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/ProxyAll", ui->proxyAllCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/Debug", ui->debugCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/TcpPortForwarding", tcpPortForwarding);
|
||||
settings->setValue("ZJUConnect/UdpPortForwarding", udpPortForwarding);
|
||||
settings->setValue("ZJUConnect/AutoReconnect", ui->autoReconnectCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/ReconnectTime", ui->reconnectTimeSpinBox->value());
|
||||
settings->setValue("ZJUConnect/AutoSetProxy", ui->autoSetProxyCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/Route", ui->routeCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/SecondaryDNS", ui->secondaryDnsLineEdit->text());
|
||||
settings->setValue("ZJUConnect/ShadowsocksUrl", ui->shadowsocksUrlLineEdit->text());
|
||||
settings->setValue("ZJUConnect/SystemProxyBypass", ui->systemProxyBypassLineEdit->text());
|
||||
settings->setValue("ZJUConnect/KeepAlive", ui->keepAliveCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/TunMode", ui->tunCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/DNSHijack", ui->dnsHijackCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/OutsideAccess", ui->outsideAccessCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/SkipDomainResource", ui->skipDomainResourceCheckBox->isChecked());
|
||||
|
||||
settings->setValue("Common/ConfigVersion", Utils::CONFIG_VERSION);
|
||||
|
||||
settings->sync();
|
||||
};
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, [&, applySettings](){
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, [&](){
|
||||
if (!Utils::credentialCheck(ui->usernameLineEdit->text(), ui->passwordLineEdit->text()))
|
||||
return;
|
||||
applySettings();
|
||||
accept();
|
||||
});
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, [&, applySettings](){
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, [&](){
|
||||
if (!Utils::credentialCheck(ui->usernameLineEdit->text(), ui->passwordLineEdit->text()))
|
||||
return;
|
||||
applySettings();
|
||||
loadSettings();
|
||||
});
|
||||
|
||||
connect(ui->resetDefaultPushButton, &QPushButton::clicked,
|
||||
@@ -98,7 +62,8 @@ SettingWindow::SettingWindow(QWidget *parent, QSettings *inputSettings) :
|
||||
if (status == QMessageBox::Ok)
|
||||
{
|
||||
settings->clear();
|
||||
settings->sync();
|
||||
loadSettings();
|
||||
applySettings();
|
||||
loadSettings();
|
||||
}
|
||||
});
|
||||
@@ -156,6 +121,12 @@ SettingWindow::SettingWindow(QWidget *parent, QSettings *inputSettings) :
|
||||
{
|
||||
ui->passwordLineEdit->setEchoMode(state == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password);
|
||||
});
|
||||
|
||||
connect(ui->totpSecretVisibleCheckBox, &QCheckBox::checkStateChanged,
|
||||
[&](Qt::CheckState state)
|
||||
{
|
||||
ui->totpSecretLineEdit->setEchoMode(state == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password);
|
||||
});
|
||||
}
|
||||
|
||||
SettingWindow::~SettingWindow()
|
||||
@@ -165,41 +136,119 @@ SettingWindow::~SettingWindow()
|
||||
|
||||
void SettingWindow::loadSettings()
|
||||
{
|
||||
ui->usernameLineEdit->setText(settings->value("Common/Username", "").toString());
|
||||
ui->passwordLineEdit->setText(
|
||||
QByteArray::fromBase64(settings->value("Common/Password", "").toString().toUtf8())
|
||||
ui->configVersionLabel->setText(
|
||||
"当前配置文件版本:" + QString::number(settings->value("Common/ConfigVersion").toInt()) +
|
||||
"\n程序配置文件版本:" + QString::number(Utils::CONFIG_VERSION)
|
||||
);
|
||||
ui->usernameLineEdit->setText(settings->value("Credential/Username", "").toString());
|
||||
ui->passwordLineEdit->setText(
|
||||
QByteArray::fromBase64(settings->value("Credential/Password", "").toString().toUtf8())
|
||||
);
|
||||
ui->totpSecretLineEdit->setText(settings->value("Credential/TOTPSecret", "").toString());
|
||||
|
||||
ui->autoStartCheckBox->setChecked(settings->value("Common/AutoStart", false).toBool());
|
||||
ui->connectAfterStartCheckBox->setChecked(settings->value("Common/ConnectAfterStart", false).toBool());
|
||||
ui->checkUpdateAfterStartCheckBox->setChecked(settings->value("Common/CheckUpdateAfterStart", true).toBool());
|
||||
ui->autoSetProxyCheckBox->setChecked(settings->value("Common/AutoSetProxy", false).toBool());
|
||||
ui->reconnectTimeSpinBox->setValue(settings->value("Common/ReconnectTime", 1).toInt());
|
||||
ui->autoReconnectCheckBox->setChecked(settings->value("Common/AutoReconnect", false).toBool());
|
||||
ui->systemProxyBypassLineEdit->setText(settings->value("Common/SystemProxyBypass", "localhost").toString());
|
||||
|
||||
|
||||
ui->serverAddressLineEdit->setText(settings->value("ZJUConnect/ServerAddress", "vpn.hitsz.edu.cn").toString());
|
||||
ui->serverPortSpinBox->setValue(settings->value("ZJUConnect/ServerPort", 443).toInt());
|
||||
ui->dnsLineEdit->setText(settings->value("ZJUConnect/DNS").toString());
|
||||
ui->dnsAutoCheckBox->setChecked(settings->value("ZJUConnect/DNSAuto", true).toBool());
|
||||
ui->secondaryDnsLineEdit->setText(settings->value("ZJUConnect/SecondaryDNS", "").toString());
|
||||
ui->dnsTTLSpinBox->setValue(settings->value("ZJUConnect/DNSTTL", 3600).toInt());
|
||||
ui->socks5PortSpinBox->setValue(settings->value("ZJUConnect/Socks5Port", 11080).toInt());
|
||||
ui->httpPortSpinBox->setValue(settings->value("ZJUConnect/HttpPort", 11081).toInt());
|
||||
ui->shadowsocksUrlLineEdit->setText(settings->value("ZJUConnect/ShadowsocksURL", "").toString());
|
||||
ui->dialDirectProxyLineEdit->setText(settings->value("ZJUConnect/DialDirectProxy", "").toString());
|
||||
|
||||
|
||||
ui->multiLineCheckBox->setChecked(settings->value("ZJUConnect/MultiLine", false).toBool());
|
||||
ui->keepAliveCheckBox->setChecked(settings->value("ZJUConnect/KeepAlive", false).toBool());
|
||||
ui->outsideAccessCheckBox->setChecked(settings->value("ZJUConnect/OutsideAccess", false).toBool());
|
||||
|
||||
ui->skipDomainResourceCheckBox->setChecked(settings->value("ZJUConnect/SkipDomainResource", true).toBool());
|
||||
ui->disableServerConfigCheckBox->setChecked(settings->value("ZJUConnect/DisableServerConfig", false).toBool());
|
||||
ui->proxyAllCheckBox->setChecked(settings->value("ZJUConnect/ProxyAll", false).toBool());
|
||||
|
||||
ui->zjuDefaultCheckBox->setChecked(settings->value("ZJUConnect/ZJUDefault", false).toBool());
|
||||
ui->disableDNSCheckBox->setChecked(settings->value("ZJUConnect/DisableZJUDNS", false).toBool());
|
||||
ui->debugCheckBox->setChecked(settings->value("ZJUConnect/Debug", false).toBool());
|
||||
|
||||
ui->tunCheckBox->setChecked(settings->value("ZJUConnect/TunMode", false).toBool());
|
||||
ui->routeCheckBox->setChecked(settings->value("ZJUConnect/AddRoute", false).toBool());
|
||||
ui->dnsHijackCheckBox->setChecked(settings->value("ZJUConnect/DNSHijack", false).toBool());
|
||||
|
||||
tcpPortForwarding = settings->value("ZJUConnect/TcpPortForwarding", "").toString();
|
||||
udpPortForwarding = settings->value("ZJUConnect/UdpPortForwarding", "").toString();
|
||||
ui->autoReconnectCheckBox->setChecked(settings->value("ZJUConnect/AutoReconnect", false).toBool());
|
||||
ui->reconnectTimeSpinBox->setValue(settings->value("ZJUConnect/ReconnectTime", 1).toInt());
|
||||
ui->autoSetProxyCheckBox->setChecked(settings->value("ZJUConnect/AutoSetProxy", false).toBool());
|
||||
ui->routeCheckBox->setChecked(settings->value("ZJUConnect/Route", false).toBool());
|
||||
ui->secondaryDnsLineEdit->setText(settings->value("ZJUConnect/SecondaryDNS", "").toString());
|
||||
ui->shadowsocksUrlLineEdit->setText(settings->value("ZJUConnect/ShadowsocksUrl", "").toString());
|
||||
ui->systemProxyBypassLineEdit->setText(settings->value("ZJUConnect/SystemProxyBypass", "localhost").toString());
|
||||
ui->keepAliveCheckBox->setChecked(settings->value("ZJUConnect/KeepAlive", false).toBool());
|
||||
ui->tunCheckBox->setChecked(settings->value("ZJUConnect/TunMode", false).toBool());
|
||||
ui->dnsHijackCheckBox->setChecked(settings->value("ZJUConnect/DNSHijack", false).toBool());
|
||||
ui->outsideAccessCheckBox->setChecked(settings->value("ZJUConnect/OutsideAccess", false).toBool());
|
||||
ui->skipDomainResourceCheckBox->setChecked(settings->value("ZJUConnect/SkipDomainResource", true).toBool());
|
||||
customDNS = settings->value("ZJUConnect/CustomDNS", "").toString();
|
||||
customProxyDomain = settings->value("ZJUConnect/CustomProxyDomain", "").toString();
|
||||
extraArguments = settings->value("ZJUConnect/ExtraArguments", "").toString();
|
||||
|
||||
ui->routeCheckBox->setEnabled(ui->tunCheckBox->isChecked());
|
||||
ui->dnsHijackCheckBox->setEnabled(ui->tunCheckBox->isChecked());
|
||||
|
||||
ui->dnsLineEdit->setEnabled(!ui->dnsAutoCheckBox->isChecked());
|
||||
}
|
||||
|
||||
void SettingWindow::applySettings()
|
||||
{
|
||||
if (settings->value("Common/AutoStart", false).toBool() != ui->autoStartCheckBox->isChecked())
|
||||
Utils::setAutoStart(ui->autoStartCheckBox->isChecked());
|
||||
|
||||
settings->setValue("Credential/Username", ui->usernameLineEdit->text());
|
||||
settings->setValue("Credential/Password", QString(ui->passwordLineEdit->text().toUtf8().toBase64()));
|
||||
settings->setValue("Credential/TOTPSecret", ui->totpSecretLineEdit->text());
|
||||
|
||||
settings->setValue("Common/AutoStart", ui->autoStartCheckBox->isChecked());
|
||||
settings->setValue("Common/ConnectAfterStart", ui->connectAfterStartCheckBox->isChecked());
|
||||
settings->setValue("Common/CheckUpdateAfterStart", ui->checkUpdateAfterStartCheckBox->isChecked());
|
||||
settings->setValue("Common/AutoSetProxy", ui->autoSetProxyCheckBox->isChecked());
|
||||
settings->setValue("Common/ReconnectTime", ui->reconnectTimeSpinBox->value());
|
||||
settings->setValue("Common/AutoReconnect", ui->autoReconnectCheckBox->isChecked());
|
||||
settings->setValue("Common/SystemProxyBypass", ui->systemProxyBypassLineEdit->text());
|
||||
|
||||
|
||||
settings->setValue("ZJUConnect/ServerAddress", ui->serverAddressLineEdit->text());
|
||||
settings->setValue("ZJUConnect/ServerPort", ui->serverPortSpinBox->value());
|
||||
settings->setValue("ZJUConnect/DNS", ui->dnsLineEdit->text());
|
||||
settings->setValue("ZJUConnect/DNSAuto", ui->dnsAutoCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/SecondaryDNS", ui->secondaryDnsLineEdit->text());
|
||||
settings->setValue("ZJUConnect/DNSTTL", ui->dnsTTLSpinBox->value());
|
||||
settings->setValue("ZJUConnect/Socks5Port", ui->socks5PortSpinBox->value());
|
||||
settings->setValue("ZJUConnect/HttpPort", ui->httpPortSpinBox->value());
|
||||
settings->setValue("ZJUConnect/ShadowsocksURL", ui->shadowsocksUrlLineEdit->text());
|
||||
settings->setValue("ZJUConnect/DialDirectProxy", ui->dialDirectProxyLineEdit->text());
|
||||
|
||||
|
||||
settings->setValue("ZJUConnect/MultiLine", ui->multiLineCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/KeepAlive", ui->keepAliveCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/OutsideAccess", ui->outsideAccessCheckBox->isChecked());
|
||||
|
||||
settings->setValue("ZJUConnect/SkipDomainResource", ui->skipDomainResourceCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/DisableServerConfig", ui->disableServerConfigCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/ProxyAll", ui->proxyAllCheckBox->isChecked());
|
||||
|
||||
settings->setValue("ZJUConnect/DisableZJUDNS", ui->disableDNSCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/ZJUDefault", ui->zjuDefaultCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/Debug", ui->debugCheckBox->isChecked());
|
||||
|
||||
settings->setValue("ZJUConnect/TunMode", ui->tunCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/AddRoute", ui->routeCheckBox->isChecked());
|
||||
settings->setValue("ZJUConnect/DNSHijack", ui->dnsHijackCheckBox->isChecked());
|
||||
|
||||
|
||||
settings->setValue("ZJUConnect/TcpPortForwarding", tcpPortForwarding);
|
||||
settings->setValue("ZJUConnect/UdpPortForwarding", udpPortForwarding);
|
||||
settings->setValue("ZJUConnect/CustomDNS", customDNS);
|
||||
settings->setValue("ZJUConnect/CustomProxyDomain", customProxyDomain);
|
||||
settings->setValue("ZJUConnect/ExtraArguments", extraArguments);
|
||||
|
||||
settings->setValue("Common/ConfigVersion", Utils::CONFIG_VERSION);
|
||||
|
||||
settings->sync();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QDialog>
|
||||
#include <QSettings>
|
||||
#include "ui_settingwindow.h"
|
||||
#include "../portforwardingwindow/portforwardingwindow.h"
|
||||
#include "../extrasettingwindow/extrasettingwindow.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -22,15 +22,19 @@ public:
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
void applySettings();
|
||||
|
||||
Ui::SettingWindow *ui;
|
||||
|
||||
QSettings *settings;
|
||||
|
||||
PortForwardingWindow *portForwardingWindow;
|
||||
ExtraSettingWindow *extraSettingWindow;
|
||||
|
||||
QString tcpPortForwarding;
|
||||
QString udpPortForwarding;
|
||||
QString customDNS;
|
||||
QString customProxyDomain;
|
||||
QString extraArguments;
|
||||
};
|
||||
|
||||
#endif //SETTINGWINDOW_H
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>486</width>
|
||||
<height>456</height>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -16,15 +16,8 @@
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="locale">
|
||||
<locale language="Chinese" country="China"/>
|
||||
@@ -32,35 +25,40 @@
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="commonTab">
|
||||
<widget class="QWidget" name="generalTab">
|
||||
<attribute name="title">
|
||||
<string>通用</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="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="0" column="0">
|
||||
<widget class="QLabel" name="commonTabLable2">
|
||||
<property name="text">
|
||||
<string>账号</string>
|
||||
<item row="4" column="0">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<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="0" column="2" colspan="2">
|
||||
<widget class="QLineEdit" name="usernameLineEdit">
|
||||
<item row="3" column="2">
|
||||
<widget class="QLineEdit" name="totpSecretLineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::EchoMode::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>VPN 账号</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="passwordVisibleCheckBox">
|
||||
<property name="text">
|
||||
<string>显示密码</string>
|
||||
<string>可选,以通过 TOTP 验证器</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -71,6 +69,20 @@
|
||||
</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">
|
||||
@@ -81,81 +93,22 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<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>100</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="onStartUpGroup">
|
||||
<property name="title">
|
||||
<string>启动时</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="commonTabLable6">
|
||||
<property name="text">
|
||||
<string>启动后检查更新</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="commonTabLable4">
|
||||
<property name="text">
|
||||
<string>开机自启动</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="3">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>221</width>
|
||||
<height>72</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="commonTabLable5">
|
||||
<property name="text">
|
||||
<string>启动后自动连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QCheckBox" name="checkUpdateAfterStartCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QCheckBox" name="connectAfterStartCheckBox">
|
||||
<widget class="QCheckBox" name="passwordVisibleCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QCheckBox" name="autoStartCheckBox">
|
||||
<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>
|
||||
@@ -164,7 +117,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<item row="7" column="0">
|
||||
<spacer name="commonTabVerticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
@@ -183,27 +136,170 @@
|
||||
<string>配置文件</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="exportPushButton">
|
||||
<property name="text">
|
||||
<string>导出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="configVersionLabel">
|
||||
<property name="text">
|
||||
<string>当前配置文件版本:?
|
||||
程序配置文件版本:?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="resetDefaultPushButton">
|
||||
<property name="text">
|
||||
<string>恢复默认</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="importPushButton">
|
||||
<property name="text">
|
||||
<string>导入</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="exportPushButton">
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="commonGroup">
|
||||
<property name="title">
|
||||
<string>常规</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="checkUpdateAfterStartCheckBox">
|
||||
<property name="text">
|
||||
<string>导出</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="autoStartCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel7">
|
||||
<property name="text">
|
||||
<string>自动重连(秒)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="commonTabLable4">
|
||||
<property name="text">
|
||||
<string>开机自启动</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QCheckBox" name="autoReconnectCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>断线自动重连</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="4">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="systemProxyBypassLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>与操作系统有关,一般用半角分号;进行分隔</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="commonTabLable5">
|
||||
<property name="text">
|
||||
<string>自动连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel11">
|
||||
<property name="text">
|
||||
<string>系统代理排除</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="commonTabLable6">
|
||||
<property name="text">
|
||||
<string>自动检查更新</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="autoSetProxyCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>连接服务器后自动设置代理</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="connectAfterStartCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="commonTabLable4_2">
|
||||
<property name="text">
|
||||
<string>自动设置系统代理</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="reconnectTimeSpinBox">
|
||||
<property name="maximum">
|
||||
<number>86400</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -211,10 +307,10 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="zjuConnectTab">
|
||||
<attribute name="title">
|
||||
<string>高级</string>
|
||||
<string>核心</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="12" column="0" colspan="4">
|
||||
<item row="15" column="0" colspan="4">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="keepAliveCheckBox">
|
||||
@@ -226,6 +322,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="disableServerConfigCheckBox">
|
||||
<property name="text">
|
||||
<string>忽略服务器配置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="tunCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>TUN 模式下有效</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TUN 模式</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="outsideAccessCheckBox">
|
||||
<property name="toolTip">
|
||||
@@ -236,6 +349,30 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="skipDomainResourceCheckBox">
|
||||
<property name="text">
|
||||
<string>忽略域名资源</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="proxyAllCheckBox">
|
||||
<property name="text">
|
||||
<string>代理全部流量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="routeCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>TUN 模式下有效</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>设置路由(TUN)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="multiLineCheckBox">
|
||||
<property name="text">
|
||||
@@ -249,51 +386,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="skipDomainResourceCheckBox">
|
||||
<property name="text">
|
||||
<string>忽略域名资源</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="autoSetProxyCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>连接服务器后自动设置代理</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>自动设置系统代理</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="proxyAllCheckBox">
|
||||
<property name="text">
|
||||
<string>代理全部流量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="tunCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>TUN 模式下有效</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TUN 模式</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="routeCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>TUN 模式下有效</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>设置路由(TUN)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="dnsHijackCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>TUN 模式下有效</string>
|
||||
@@ -303,10 +396,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="debugCheckBox">
|
||||
<property name="text">
|
||||
<string>核心调试模式(谨慎开启,日志量过大会导致 UI 崩溃)</string>
|
||||
<string>核心调试</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="zjuDefaultCheckBox">
|
||||
<property name="text">
|
||||
<string>ZJU 默认配置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="disableDNSCheckBox">
|
||||
<property name="text">
|
||||
<string>禁用内部 DNS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -319,7 +426,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="3">
|
||||
<item row="7" column="1" colspan="3">
|
||||
<widget class="QSpinBox" name="httpPortSpinBox">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
@@ -329,7 +436,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="4">
|
||||
<item row="14" column="0" colspan="4">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
@@ -343,6 +450,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="shadowsocksUrlLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>不填则不启用,格式:ss://chiper:password@server:port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2" colspan="2">
|
||||
<widget class="QCheckBox" name="dnsAutoCheckBox">
|
||||
<property name="text">
|
||||
@@ -357,14 +471,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel11">
|
||||
<property name="text">
|
||||
<string>系统代理排除</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0" colspan="4">
|
||||
<item row="19" column="0" colspan="4">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
@@ -377,14 +484,17 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel10">
|
||||
<property name="text">
|
||||
<string>Shadowsocks 服务器</string>
|
||||
<item row="5" column="1" colspan="3">
|
||||
<widget class="QSpinBox" name="dnsTTLSpinBox">
|
||||
<property name="maximum">
|
||||
<number>2147483647</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3600</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel5">
|
||||
<property name="text">
|
||||
<string>SOCKS5 代理端口</string>
|
||||
@@ -401,17 +511,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QSpinBox" name="reconnectTimeSpinBox">
|
||||
<property name="maximum">
|
||||
<number>86400</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel10">
|
||||
<property name="text">
|
||||
<string>Shadowsocks 服务器</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="3">
|
||||
<item row="6" column="1" colspan="3">
|
||||
<widget class="QSpinBox" name="socks5PortSpinBox">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
@@ -421,10 +528,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="systemProxyBypassLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>与操作系统有关,一般用半角分号;进行分隔</string>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel6">
|
||||
<property name="text">
|
||||
<string>HTTP 代理端口</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -435,23 +542,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2" colspan="2">
|
||||
<widget class="QCheckBox" name="autoReconnectCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>断线自动重连</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>启用</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel6">
|
||||
<property name="text">
|
||||
<string>HTTP 代理端口</string>
|
||||
<item row="10" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="dialDirectProxyLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>直连情况下走的代理,支持:socks://... 或 http://...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -462,24 +556,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="0" colspan="4">
|
||||
<item row="18" column="0" colspan="4">
|
||||
<widget class="QPushButton" name="portForwardingPushButton">
|
||||
<property name="text">
|
||||
<string>设置端口转发</string>
|
||||
<string>其他设置(端口转发、自定义参数等)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel7">
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel6_3">
|
||||
<property name="text">
|
||||
<string>自动重连时间(秒)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="shadowsocksUrlLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>不填则不启用,格式:ss://chiper:password@server:port</string>
|
||||
<string>直连代理</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -497,10 +584,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="zjuConnectTabLabel9_2">
|
||||
<property name="text">
|
||||
<string>DNS TTL(秒)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
@@ -513,9 +614,6 @@
|
||||
<tabstop>secondaryDnsLineEdit</tabstop>
|
||||
<tabstop>socks5PortSpinBox</tabstop>
|
||||
<tabstop>httpPortSpinBox</tabstop>
|
||||
<tabstop>shadowsocksUrlLineEdit</tabstop>
|
||||
<tabstop>reconnectTimeSpinBox</tabstop>
|
||||
<tabstop>autoReconnectCheckBox</tabstop>
|
||||
<tabstop>multiLineCheckBox</tabstop>
|
||||
<tabstop>keepAliveCheckBox</tabstop>
|
||||
<tabstop>outsideAccessCheckBox</tabstop>
|
||||
|
||||
@@ -5,76 +5,52 @@ ZjuConnectController::ZjuConnectController()
|
||||
{
|
||||
zjuConnectProcess = new QProcess(this);
|
||||
|
||||
connect(zjuConnectProcess, &QProcess::readyReadStandardOutput, this, [&]()
|
||||
auto outputProcess = [&](const QString& output)
|
||||
{
|
||||
emit outputRead(output);
|
||||
|
||||
if (output.contains("Access is denied."))
|
||||
{
|
||||
emit error(ZJU_ERROR::ACCESS_DENIED);
|
||||
}
|
||||
else if (output.contains("listen failed"))
|
||||
{
|
||||
emit error(ZJU_ERROR::LISTEN_FAILED);
|
||||
}
|
||||
else if (output.contains("Invalid username or password!"))
|
||||
{
|
||||
emit error(ZJU_ERROR::INVALID_DETAIL);
|
||||
}
|
||||
else if (output.contains("You are trying brute-force login on this IP address."))
|
||||
{
|
||||
emit error(ZJU_ERROR::BRUTE_FORCE);
|
||||
}
|
||||
else if (output.contains("Login failed") || output.contains("too many login failures"))
|
||||
{
|
||||
emit error(ZJU_ERROR::OTHER_LOGIN_FAILED);
|
||||
}
|
||||
else if (output.contains("client setup error"))
|
||||
{
|
||||
emit error(ZJU_ERROR::CLIENT_FAILED);
|
||||
}
|
||||
else if (output.contains("panic"))
|
||||
{
|
||||
emit error(ZJU_ERROR::OTHER);
|
||||
}
|
||||
};
|
||||
|
||||
connect(zjuConnectProcess, &QProcess::readyReadStandardOutput, this, [&, outputProcess]()
|
||||
{
|
||||
QString output = Utils::ConsoleOutputToQString(zjuConnectProcess->readAllStandardOutput());
|
||||
|
||||
emit outputRead(output);
|
||||
|
||||
if (output.contains("Access is denied."))
|
||||
{
|
||||
emit error(ZJU_ERROR::ACCESS_DENIED);
|
||||
}
|
||||
else if (output.contains("listen failed"))
|
||||
{
|
||||
emit error(ZJU_ERROR::LISTEN_FAILED);
|
||||
}
|
||||
else if (output.contains("Invalid username or password!"))
|
||||
{
|
||||
emit error(ZJU_ERROR::INVALID_DETAIL);
|
||||
}
|
||||
else if (output.contains("You are trying brute-force login on this IP address."))
|
||||
{
|
||||
emit error(ZJU_ERROR::BRUTE_FORCE);
|
||||
}
|
||||
else if (output.contains("Login failed") || output.contains("too many login failures"))
|
||||
{
|
||||
emit error(ZJU_ERROR::OTHER_LOGIN_FAILED);
|
||||
}
|
||||
else if (output.contains("client setup error"))
|
||||
{
|
||||
emit error(ZJU_ERROR::CLIENT_FAILED);
|
||||
}
|
||||
else if (output.contains("panic"))
|
||||
{
|
||||
emit error(ZJU_ERROR::OTHER);
|
||||
}
|
||||
outputProcess(output);
|
||||
});
|
||||
|
||||
connect(zjuConnectProcess, &QProcess::readyReadStandardError, this, [&]()
|
||||
connect(zjuConnectProcess, &QProcess::readyReadStandardError, this, [&, outputProcess]()
|
||||
{
|
||||
QString output = Utils::ConsoleOutputToQString(zjuConnectProcess->readAllStandardError());
|
||||
|
||||
emit outputRead(output);
|
||||
|
||||
if (output.contains("Access is denied."))
|
||||
{
|
||||
emit error(ZJU_ERROR::ACCESS_DENIED);
|
||||
}
|
||||
else if (output.contains("listen failed"))
|
||||
{
|
||||
emit error(ZJU_ERROR::LISTEN_FAILED);
|
||||
}
|
||||
else if (output.contains("client setup error"))
|
||||
{
|
||||
emit error(ZJU_ERROR::CLIENT_FAILED);
|
||||
}
|
||||
else if (output.contains("Invalid username or password!"))
|
||||
{
|
||||
emit error(ZJU_ERROR::INVALID_DETAIL);
|
||||
}
|
||||
else if (output.contains("You are trying brute-force login on this IP address."))
|
||||
{
|
||||
emit error(ZJU_ERROR::BRUTE_FORCE);
|
||||
}
|
||||
else if (output.contains("Login failed") || output.contains("too many login failures"))
|
||||
{
|
||||
emit error(ZJU_ERROR::OTHER_LOGIN_FAILED);
|
||||
}
|
||||
else if (output.contains("panic"))
|
||||
{
|
||||
emit error(ZJU_ERROR::OTHER);
|
||||
}
|
||||
outputProcess(output);
|
||||
});
|
||||
|
||||
connect(zjuConnectProcess, &QProcess::errorOccurred, this, [&](QProcess::ProcessError err)
|
||||
@@ -100,24 +76,33 @@ void ZjuConnectController::start(
|
||||
const QString& program,
|
||||
const QString& username,
|
||||
const QString& password,
|
||||
const QString& totpSecret,
|
||||
const QString& server,
|
||||
int port,
|
||||
const QString& dns,
|
||||
bool dnsAuto,
|
||||
const QString& secondaryDns,
|
||||
bool disableMultiLine,
|
||||
bool disableKeepAlive,
|
||||
bool proxyAll,
|
||||
int dnsTtl,
|
||||
const QString& socksBind,
|
||||
const QString& httpBind,
|
||||
const QString& shadowsocksUrl,
|
||||
const QString& dialDirectProxy,
|
||||
bool disableMultiLine,
|
||||
bool disableKeepAlive,
|
||||
bool skipDomainResource,
|
||||
bool disableServerConfig,
|
||||
bool proxyAll,
|
||||
bool disableZjuDns,
|
||||
bool disableZjuConfig,
|
||||
bool debugDump,
|
||||
bool tunMode,
|
||||
bool addRoute,
|
||||
bool dnsHijack,
|
||||
bool skipDomainResource,
|
||||
bool debugDump,
|
||||
const QString& tcpPortForwarding,
|
||||
const QString& udpPortForwarding
|
||||
const QString& udpPortForwarding,
|
||||
const QString& customDNS,
|
||||
const QString& customProxyDomain,
|
||||
const QString& extraArguments
|
||||
)
|
||||
{
|
||||
QStringList args;
|
||||
@@ -147,6 +132,12 @@ void ZjuConnectController::start(
|
||||
}
|
||||
}
|
||||
|
||||
if (dnsTtl != 3600)
|
||||
{
|
||||
args.append("-dns-ttl");
|
||||
args.append(QString::number(dnsTtl));
|
||||
}
|
||||
|
||||
if (!secondaryDns.isEmpty())
|
||||
{
|
||||
args.append("-secondary-dns-server");
|
||||
@@ -163,11 +154,31 @@ void ZjuConnectController::start(
|
||||
args.append("-disable-keep-alive");
|
||||
}
|
||||
|
||||
if (disableZjuConfig)
|
||||
{
|
||||
args.append("-disable-zju-config");
|
||||
}
|
||||
|
||||
if (disableZjuDns)
|
||||
{
|
||||
args.append("-disable-zju-dns");
|
||||
}
|
||||
|
||||
if (disableServerConfig)
|
||||
{
|
||||
args.append("-disable-server-config");
|
||||
}
|
||||
|
||||
if (proxyAll)
|
||||
{
|
||||
args.append("-proxy-all");
|
||||
}
|
||||
|
||||
if (skipDomainResource)
|
||||
{
|
||||
args.append("-skip-domain-resource");
|
||||
}
|
||||
|
||||
if (tunMode)
|
||||
{
|
||||
args.append("-tun-mode");
|
||||
@@ -206,6 +217,12 @@ void ZjuConnectController::start(
|
||||
args.append(shadowsocksUrl);
|
||||
}
|
||||
|
||||
if (!dialDirectProxy.isEmpty())
|
||||
{
|
||||
args.append("-dial-direct-proxy");
|
||||
args.append(dialDirectProxy);
|
||||
}
|
||||
|
||||
if (!tcpPortForwarding.isEmpty())
|
||||
{
|
||||
args.append("-tcp-port-forwarding");
|
||||
@@ -218,15 +235,39 @@ void ZjuConnectController::start(
|
||||
args.append(udpPortForwarding);
|
||||
}
|
||||
|
||||
if (skipDomainResource)
|
||||
{
|
||||
args.append("-skip-domain-resource");
|
||||
}
|
||||
if (!customDNS.isEmpty())
|
||||
{
|
||||
args.append("-custom-dns");
|
||||
args.append(customDNS);
|
||||
}
|
||||
|
||||
if (!customProxyDomain.isEmpty())
|
||||
{
|
||||
args.append("-custom-proxy-domain");
|
||||
args.append(customProxyDomain);
|
||||
}
|
||||
|
||||
if (!extraArguments.isEmpty())
|
||||
{
|
||||
args.append(extraArguments.split(" "));
|
||||
}
|
||||
|
||||
QString timeString = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
|
||||
emit outputRead(timeString + " VPN 启动!参数:" + args.join(' '));
|
||||
|
||||
zjuConnectProcess->start(program, QStringList({ "-username", username, "-password", password }) + args);
|
||||
QStringList credentialList({
|
||||
"-username", username,
|
||||
"-password", password,
|
||||
});
|
||||
|
||||
if (!totpSecret.isEmpty())
|
||||
{
|
||||
emit outputRead(timeString + " 使用了 TOTP");
|
||||
credentialList.append("-totp-secret");
|
||||
credentialList.append(totpSecret);
|
||||
}
|
||||
|
||||
zjuConnectProcess->start(program, credentialList + args);
|
||||
zjuConnectProcess->waitForStarted();
|
||||
if (zjuConnectProcess->state() == QProcess::NotRunning)
|
||||
{
|
||||
|
||||
@@ -29,24 +29,33 @@ public:
|
||||
const QString& program,
|
||||
const QString& username,
|
||||
const QString& password,
|
||||
const QString& server = "",
|
||||
int port = 0,
|
||||
const QString& dns = "",
|
||||
bool dnsAuto = true,
|
||||
const QString& secondaryDns = "",
|
||||
bool disableMultiLine = false,
|
||||
bool disableKeepAlive = true,
|
||||
bool proxyAll = false,
|
||||
const QString& socksBind = "",
|
||||
const QString& httpBind = "",
|
||||
const QString& shadowsocksUrl = "",
|
||||
bool tunMode = false,
|
||||
bool addRoute = false,
|
||||
bool dnsHijack = false,
|
||||
bool skipDomainResource = true,
|
||||
bool debugDump = false,
|
||||
const QString& tcpPortForwarding = "",
|
||||
const QString& udpPortForwarding = ""
|
||||
const QString& totpSecret,
|
||||
const QString& server,
|
||||
int port,
|
||||
const QString& dns,
|
||||
bool dnsAuto,
|
||||
const QString& secondaryDns,
|
||||
int dnsTtl,
|
||||
const QString& socksBind,
|
||||
const QString& httpBind,
|
||||
const QString& shadowsocksUrl,
|
||||
const QString& dialDirectProxy,
|
||||
bool disableMultiLine,
|
||||
bool disableKeepAlive,
|
||||
bool skipDomainResource,
|
||||
bool disableServerConfig,
|
||||
bool proxyAll,
|
||||
bool disableZjuDns,
|
||||
bool disableZjuConfig,
|
||||
bool debugDump,
|
||||
bool tunMode,
|
||||
bool addRoute,
|
||||
bool dnsHijack,
|
||||
const QString& tcpPortForwarding,
|
||||
const QString& udpPortForwarding,
|
||||
const QString& customDNS,
|
||||
const QString& customProxyDomain,
|
||||
const QString& extraArguments
|
||||
);
|
||||
|
||||
void stop();
|
||||
|
||||
@@ -38,11 +38,11 @@ void MainWindow::initZjuConnect()
|
||||
if (
|
||||
zjuConnectError != ZJU_ERROR::NONE &&
|
||||
zjuConnectError != ZJU_ERROR::OTHER &&
|
||||
settings->value("ZJUConnect/AutoReconnect", false).toBool() &&
|
||||
settings->value("Common/AutoReconnect", false).toBool() &&
|
||||
isZjuConnectLinked
|
||||
)
|
||||
{
|
||||
QTimer::singleShot(settings->value("ZJUConnect/ReconnectTime", 1).toInt() * 1000, this, [&]()
|
||||
QTimer::singleShot(settings->value("Common/ReconnectTime", 1).toInt() * 1000, this, [&]()
|
||||
{
|
||||
if (isZjuConnectLinked)
|
||||
{
|
||||
@@ -111,8 +111,8 @@ void MainWindow::initZjuConnect()
|
||||
return;
|
||||
}
|
||||
|
||||
QString username_ = settings->value("Common/Username", "").toString();
|
||||
QString password_ = QByteArray::fromBase64(settings->value("Common/Password", "").toString().toUtf8());
|
||||
QString username_ = settings->value("Credential/Username", "").toString();
|
||||
QString password_ = QByteArray::fromBase64(settings->value("Credential/Password", "").toString().toUtf8());
|
||||
|
||||
auto startZjuConnect = [this](const QString &username, const QString &password) {
|
||||
QString program_filename;
|
||||
@@ -125,13 +125,13 @@ void MainWindow::initZjuConnect()
|
||||
program_filename = "zju-connect";
|
||||
}
|
||||
QString program_path = QCoreApplication::applicationDirPath() + "/" + program_filename;
|
||||
QString bind_prefix = settings->value("ZJUConnect/OutsideAccess", false).toBool() ? "0.0.0.0:" : "127.0.0.1:";
|
||||
QString bind_prefix = settings->value("ZJUConnect/OutsideAccess", false).toBool() ? "[::]:" : "[::1]:";
|
||||
|
||||
isZjuConnectLinked = true;
|
||||
ui->pushButton1->setText("断开服务器");
|
||||
ui->pushButton2->show();
|
||||
|
||||
if (settings->value("ZJUConnect/AutoSetProxy", false).toBool())
|
||||
if (settings->value("Common/AutoSetProxy", false).toBool())
|
||||
{
|
||||
ui->pushButton2->click();
|
||||
}
|
||||
@@ -140,24 +140,33 @@ void MainWindow::initZjuConnect()
|
||||
program_path,
|
||||
username,
|
||||
password,
|
||||
settings->value("Credential/TOTPSecret").toString(),
|
||||
settings->value("ZJUConnect/ServerAddress").toString(),
|
||||
settings->value("ZJUConnect/ServerPort").toInt(),
|
||||
settings->value("ZJUConnect/DNS").toString(),
|
||||
settings->value("ZJUConnect/DNSAuto").toBool(),
|
||||
settings->value("ZJUConnect/SecondaryDNS").toString(),
|
||||
!settings->value("ZJUConnect/MultiLine").toBool(),
|
||||
!settings->value("ZJUConnect/KeepAlive").toBool(),
|
||||
settings->value("ZJUConnect/ProxyAll").toBool(),
|
||||
settings->value("ZJUConnect/DNSTTL").toInt(),
|
||||
bind_prefix + QString::number(settings->value("ZJUConnect/Socks5Port").toInt()),
|
||||
bind_prefix + QString::number(settings->value("ZJUConnect/HttpPort").toInt()),
|
||||
settings->value("ZJUConnect/ShadowsocksUrl").toString(),
|
||||
settings->value("ZJUConnect/TunMode").toBool(),
|
||||
settings->value("ZJUConnect/Route").toBool(),
|
||||
settings->value("ZJUConnect/DNSHijack").toBool(),
|
||||
settings->value("ZJUConnect/SkipDomainResource").toBool(),
|
||||
settings->value("ZJUConnect/ShadowsocksURL").toString(),
|
||||
settings->value("ZJUConnect/DialDirectProxy").toString(),
|
||||
!settings->value("ZJUConnect/MultiLine").toBool(),
|
||||
!settings->value("ZJUConnect/KeepAlive").toBool(),
|
||||
settings->value("ZJUConnect/SkipDomainResource").toBool(),
|
||||
settings->value("ZJUConnect/DisableServerConfig").toBool(),
|
||||
settings->value("ZJUConnect/ProxyAll").toBool(),
|
||||
settings->value("ZJUConnect/DisableZJUDNS").toBool(),
|
||||
!settings->value("ZJUConnect/ZJUDefault").toBool(),
|
||||
settings->value("ZJUConnect/Debug").toBool(),
|
||||
settings->value("ZJUConnect/TunMode").toBool(),
|
||||
settings->value("ZJUConnect/AddRoute").toBool(),
|
||||
settings->value("ZJUConnect/DNSHijack").toBool(),
|
||||
settings->value("ZJUConnect/TcpPortForwarding").toString(),
|
||||
settings->value("ZJUConnect/UdpPortForwarding").toString()
|
||||
settings->value("ZJUConnect/UdpPortForwarding").toString(),
|
||||
settings->value("ZJUConnect/CustomDNS", "").toString(),
|
||||
settings->value("ZJUConnect/CustomProxyDomain", "").toString(),
|
||||
settings->value("ZJUConnect/ExtraArguments", "").toString()
|
||||
);
|
||||
};
|
||||
|
||||
@@ -171,8 +180,8 @@ void MainWindow::initZjuConnect()
|
||||
{
|
||||
if (saveDetail)
|
||||
{
|
||||
settings->setValue("Common/Username", username);
|
||||
settings->setValue("Common/Password", QString(password.toUtf8().toBase64()));
|
||||
settings->setValue("Credential/Username", username);
|
||||
settings->setValue("Credential/Password", QString(password.toUtf8().toBase64()));
|
||||
settings->sync();
|
||||
}
|
||||
startZjuConnect(username, password);
|
||||
@@ -221,7 +230,7 @@ void MainWindow::initZjuConnect()
|
||||
|
||||
Utils::setSystemProxy(settings->value("ZJUConnect/HttpPort", 11081).toInt(),
|
||||
settings->value("ZJUConnect/Socks5Port", 11080).toInt(),
|
||||
settings->value("ZJUConnect/SystemProxyBypass", "localhost").toString());
|
||||
settings->value("Common/SystemProxyBypass", "localhost").toString());
|
||||
ui->pushButton2->setText("清除系统代理");
|
||||
isSystemProxySet = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user