add: test adding allowInsecure allowInsecureCipher

This commit is contained in:
Qv2ray-dev 2020-04-13 16:03:29 +08:00
parent b16140c879
commit cca5a56643
10 changed files with 84 additions and 26 deletions

View File

@ -257,13 +257,14 @@ namespace Qv2ray::base::objects
{ {
QString serverName; QString serverName;
bool allowInsecure; bool allowInsecure;
bool allowInsecureCiphers;
QList<QString> alpn; QList<QString> alpn;
QList<CertificateObject> certificates; QList<CertificateObject> certificates;
bool disableSystemRoot; bool disableSystemRoot;
TLSObject() : serverName(), allowInsecure(), certificates(), disableSystemRoot() TLSObject() : serverName(), allowInsecure(), allowInsecureCiphers(), certificates(), disableSystemRoot()
{ {
} }
XTOSTRUCT(O(serverName, allowInsecure, alpn, certificates, disableSystemRoot)) XTOSTRUCT(O(serverName, allowInsecure, allowInsecureCiphers, alpn, certificates, disableSystemRoot))
}; };
} // namespace transfer } // namespace transfer
// //

View File

@ -217,8 +217,9 @@ namespace Qv2ray::base::config
struct Qv2rayAdvancedConfig struct Qv2rayAdvancedConfig
{ {
bool setAllowInsecure; bool setAllowInsecure;
bool setAllowInsecureCiphers;
bool testLatencyPeriodcally; bool testLatencyPeriodcally;
XTOSTRUCT(O(setAllowInsecure, testLatencyPeriodcally)) XTOSTRUCT(O(setAllowInsecure, setAllowInsecureCiphers, testLatencyPeriodcally))
}; };
struct Qv2rayNetworkConfig struct Qv2rayNetworkConfig

View File

@ -16,6 +16,22 @@ namespace Qv2ray::core::connection
if (link.startsWith("vmess://")) if (link.startsWith("vmess://"))
{ {
auto conf = ConvertConfigFromVMessString(link, prefix, errMessage); auto conf = ConvertConfigFromVMessString(link, prefix, errMessage);
//
if (GlobalConfig.advancedConfig.setAllowInsecureCiphers || GlobalConfig.advancedConfig.setAllowInsecure)
{
auto outbound = conf["outbounds"].toArray().first().toObject();
auto streamSettings = outbound["streamSettings"].toObject();
auto tlsSettings = streamSettings["tlsSettings"].toObject();
tlsSettings["allowInsecure"] = GlobalConfig.advancedConfig.setAllowInsecure;
tlsSettings["allowInsecureCiphers"] = GlobalConfig.advancedConfig.setAllowInsecureCiphers;
streamSettings["tlsSettings"] = tlsSettings;
outbound["streamSettings"] = streamSettings;
//
auto outbounds = conf["outbounds"].toArray();
outbounds[0] = outbound;
conf["outbounds"] = outbounds;
}
//
connectionConf.insert(*prefix, conf); connectionConf.insert(*prefix, conf);
} }
else if (link.startsWith("ss://")) else if (link.startsWith("ss://"))

View File

@ -13,7 +13,7 @@ namespace Qv2ray::core::handlers
DEBUG(MODULE_CORE_HANDLER, "ConnectionHandler Constructor.") DEBUG(MODULE_CORE_HANDLER, "ConnectionHandler Constructor.")
// Do we need to check how many of them are loaded? // Do we need to check how many of them are loaded?
// Do not use: for (const auto &key : connections) // Do not use: for (const auto &key : connections), why?
for (auto i = 0; i < GlobalConfig.connections.count(); i++) for (auto i = 0; i < GlobalConfig.connections.count(); i++)
{ {
auto const &id = ConnectionId(GlobalConfig.connections.keys().at(i)); auto const &id = ConnectionId(GlobalConfig.connections.keys().at(i));
@ -87,10 +87,9 @@ namespace Qv2ray::core::handlers
httpHelper = new QvHttpRequestHelper(this); httpHelper = new QvHttpRequestHelper(this);
connect(tcpingHelper, &QvTCPingHelper::OnLatencyTestCompleted, this, &QvConfigHandler::OnLatencyDataArrived_p); connect(tcpingHelper, &QvTCPingHelper::OnLatencyTestCompleted, this, &QvConfigHandler::OnLatencyDataArrived_p);
// //
// Save per 2 minutes. // Save per 1 minutes.
saveTimerId = startTimer(2 * 60 * 1000); saveTimerId = startTimer(1 * 60 * 1000);
// Do not ping all... // Do not ping all...
// pingAllTimerId = startTimer(5 * 60 * 1000);
pingConnectionTimerId = startTimer(60 * 1000); pingConnectionTimerId = startTimer(60 * 1000);
} }
@ -141,7 +140,7 @@ namespace Qv2ray::core::handlers
else if (event->timerId() == pingConnectionTimerId) else if (event->timerId() == pingConnectionTimerId)
{ {
auto id = kernelHandler->CurrentConnection(); auto id = kernelHandler->CurrentConnection();
if (id != NullConnectionId) if (id != NullConnectionId && GlobalConfig.advancedConfig.testLatencyPeriodcally)
{ {
StartLatencyTest(id); StartLatencyTest(id);
} }

View File

@ -139,6 +139,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent), Current
// //
// Advanced config. // Advanced config.
setAllowInsecureCB->setChecked(CurrentConfig.advancedConfig.setAllowInsecure); setAllowInsecureCB->setChecked(CurrentConfig.advancedConfig.setAllowInsecure);
setAllowInsecureCiphersCB->setChecked(CurrentConfig.advancedConfig.setAllowInsecureCiphers);
setTestLatenctCB->setChecked(CurrentConfig.advancedConfig.testLatencyPeriodcally); setTestLatenctCB->setChecked(CurrentConfig.advancedConfig.testLatencyPeriodcally);
// //
DNSListTxt->clear(); DNSListTxt->clear();
@ -1156,13 +1157,29 @@ void PreferencesWindow::on_qvUseProxyCB_stateChanged(int arg1)
void PreferencesWindow::on_setAllowInsecureCB_stateChanged(int arg1) void PreferencesWindow::on_setAllowInsecureCB_stateChanged(int arg1)
{ {
LOADINGCHECK LOADINGCHECK
QvMessageBoxWarn(this, tr("Dangerous Operation"), tr("You may under MITM attack, which is just what TLS is protective for.")); if (arg1 == Qt::Checked)
{
QvMessageBoxWarn(this, tr("Dangerous Operation"), tr("You will lose the advantage of TLS and make your connection under MITM attack."));
}
CurrentConfig.advancedConfig.setAllowInsecure = arg1 == Qt::Checked; CurrentConfig.advancedConfig.setAllowInsecure = arg1 == Qt::Checked;
} }
void PreferencesWindow::on_setTestLatenctCB_stateChanged(int arg1) void PreferencesWindow::on_setTestLatenctCB_stateChanged(int arg1)
{ {
LOADINGCHECK LOADINGCHECK
QvMessageBoxWarn(this, tr("Dangerous Operation"), tr("This will (probably) makes it easy to fingerprint your connection.")); if (arg1 == Qt::Checked)
{
QvMessageBoxWarn(this, tr("Dangerous Operation"), tr("This will (probably) makes it easy to fingerprint your connection."));
}
CurrentConfig.advancedConfig.testLatencyPeriodcally = arg1 == Qt::Checked; CurrentConfig.advancedConfig.testLatencyPeriodcally = arg1 == Qt::Checked;
} }
void PreferencesWindow::on_setAllowInsecureCiphersCB_stateChanged(int arg1)
{
LOADINGCHECK
if (arg1 == Qt::Checked)
{
QvMessageBoxWarn(this, tr("Dangerous Operation"), tr("You will lose the advantage of TLS and make your connection under MITM attack."));
}
CurrentConfig.advancedConfig.setAllowInsecureCiphers = arg1 == Qt::Checked;
}

View File

@ -174,6 +174,8 @@ class PreferencesWindow
void on_setTestLatenctCB_stateChanged(int arg1); void on_setTestLatenctCB_stateChanged(int arg1);
void on_setAllowInsecureCiphersCB_stateChanged(int arg1);
private: private:
// //
RouteSettingsMatrixWidget *routeSettingsWidget; RouteSettingsMatrixWidget *routeSettingsWidget;

View File

@ -347,14 +347,14 @@ This could resolve the certificate issues, but also could let one performing TLS
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_83"> <widget class="QLabel" name="label_83">
<property name="text"> <property name="text">
<string>Test Latency Periodcally</string> <string>Test Latency Periodcally</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QCheckBox" name="setTestLatenctCB"> <widget class="QCheckBox" name="setTestLatenctCB">
<property name="toolTip"> <property name="toolTip">
<string>Run TCPing or ICMPing periodcally after connecting to a server. <string>Run TCPing or ICMPing periodcally after connecting to a server.
@ -383,6 +383,20 @@ But could damage your server if improperly used.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label_85">
<property name="text">
<string>AllowInsecureCiphers By Default</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="setAllowInsecureCiphersCB">
<property name="text">
<string>Enabled</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -22,7 +22,7 @@ QvMessageBusSlotImpl(StreamSettingsWidget)
} }
} }
StreamSettingsObject StreamSettingsWidget::GetStreamSettings() StreamSettingsObject StreamSettingsWidget::GetStreamSettings() const
{ {
return stream; return stream;
} }
@ -36,6 +36,7 @@ void StreamSettingsWidget::SetStreamObject(const StreamSettingsObject &sso)
tlsCB->setChecked(stream.security == "tls"); tlsCB->setChecked(stream.security == "tls");
serverNameTxt->setText(stream.tlsSettings.serverName); serverNameTxt->setText(stream.tlsSettings.serverName);
allowInsecureCB->setChecked(stream.tlsSettings.allowInsecure); allowInsecureCB->setChecked(stream.tlsSettings.allowInsecure);
allowInsecureCiphersCB->setChecked(stream.tlsSettings.allowInsecureCiphers);
alpnTxt->setPlainText(stream.tlsSettings.alpn.join(NEWLINE)); alpnTxt->setPlainText(stream.tlsSettings.alpn.join(NEWLINE));
// TCP // TCP
tcpHeaderTypeCB->setCurrentText(stream.tcpSettings.header.type); tcpHeaderTypeCB->setCurrentText(stream.tcpSettings.header.type);
@ -47,9 +48,9 @@ void StreamSettingsWidget::SetStreamObject(const StreamSettingsObject &sso)
// WS // WS
wsPathTxt->setText(stream.wsSettings.path); wsPathTxt->setText(stream.wsSettings.path);
QString wsHeaders; QString wsHeaders;
for (auto index = 0; index < stream.wsSettings.headers.count(); index++) for (auto i = 0; i < stream.wsSettings.headers.count(); i++)
{ {
wsHeaders = wsHeaders % stream.wsSettings.headers.keys().at(index) % "|" % stream.wsSettings.headers.values().at(index) % NEWLINE; wsHeaders = wsHeaders % stream.wsSettings.headers.keys().at(i) % "|" % stream.wsSettings.headers.values().at(i) % NEWLINE;
} }
wsHeadersTxt->setPlainText(wsHeaders); wsHeadersTxt->setPlainText(wsHeaders);
@ -284,3 +285,8 @@ void StreamSettingsWidget::on_alpnTxt_textChanged()
{ {
stream.tlsSettings.alpn = SplitLines(alpnTxt->toPlainText()); stream.tlsSettings.alpn = SplitLines(alpnTxt->toPlainText());
} }
void StreamSettingsWidget::on_allowInsecureCiphersCB_stateChanged(int arg1)
{
stream.tlsSettings.allowInsecureCiphers = arg1 == Qt::Checked;
}

View File

@ -14,7 +14,7 @@ class StreamSettingsWidget
public: public:
explicit StreamSettingsWidget(QWidget *parent = nullptr); explicit StreamSettingsWidget(QWidget *parent = nullptr);
void SetStreamObject(const StreamSettingsObject &sso); void SetStreamObject(const StreamSettingsObject &sso);
StreamSettingsObject GetStreamSettings(); StreamSettingsObject GetStreamSettings() const;
private slots: private slots:
void on_httpPathTxt_textEdited(const QString &arg1); void on_httpPathTxt_textEdited(const QString &arg1);
@ -77,6 +77,8 @@ class StreamSettingsWidget
void on_alpnTxt_textChanged(); void on_alpnTxt_textChanged();
void on_allowInsecureCiphersCB_stateChanged(int arg1);
private: private:
QvMessageBusSlotDecl; QvMessageBusSlotDecl;
StreamSettingsObject stream; StreamSettingsObject stream;

View File

@ -635,37 +635,37 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>Server</string> <string>Server</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="serverNameTxt"/> <widget class="QLineEdit" name="serverNameTxt"/>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_14"> <widget class="QLabel" name="label_14">
<property name="text"> <property name="text">
<string>ALPN</string> <string>ALPN</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="4" column="1">
<widget class="QPlainTextEdit" name="alpnTxt"/> <widget class="QPlainTextEdit" name="alpnTxt"/>
</item> </item>
<item row="0" column="0"> <item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_13"> <widget class="QCheckBox" name="tlsCB">
<property name="text"> <property name="text">
<string>TLS</string> <string>Enable TLS</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="tlsCB"> <widget class="QCheckBox" name="allowInsecureCiphersCB">
<property name="text"> <property name="text">
<string>Enabled</string> <string>Allow Insecure Ciphers</string>
</property> </property>
</widget> </widget>
</item> </item>