From 3e47e3c6cac7ddb86f4e86c4ee0b9b098f1201f9 Mon Sep 17 00:00:00 2001 From: dyhkwong <50692134+dyhkwong@users.noreply.github.com> Date: Sat, 12 Dec 2020 17:07:13 +0800 Subject: [PATCH] Feature: Option to disable latency test on connected --- src/base/models/QvSettingsObject.hpp | 3 ++- src/ui/widgets/windows/w_MainWindow.cpp | 5 ++++- src/ui/widgets/windows/w_PreferencesWindow.cpp | 11 +++++++++++ src/ui/widgets/windows/w_PreferencesWindow.hpp | 1 + src/ui/widgets/windows/w_PreferencesWindow.ui | 14 ++++++++++++++ translations/en_US.ts | 4 ++++ translations/zh_CN.ts | 4 ++++ 7 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/base/models/QvSettingsObject.hpp b/src/base/models/QvSettingsObject.hpp index ce0af572..0a66b52f 100644 --- a/src/base/models/QvSettingsObject.hpp +++ b/src/base/models/QvSettingsObject.hpp @@ -118,7 +118,8 @@ namespace Qv2ray::base::config bool setSessionResumption = false; bool testLatencyPeriodcally = false; bool disableSystemRoot = false; - JSONSTRUCT_REGISTER(Qv2rayConfig_Advanced, F(setAllowInsecure, setSessionResumption, testLatencyPeriodcally, disableSystemRoot)) + bool testLatencyOnConnected = false; + JSONSTRUCT_REGISTER(Qv2rayConfig_Advanced, F(setAllowInsecure, setSessionResumption, testLatencyPeriodcally, disableSystemRoot, testLatencyOnConnected)) }; enum Qv2rayLatencyTestingMethod diff --git a/src/ui/widgets/windows/w_MainWindow.cpp b/src/ui/widgets/windows/w_MainWindow.cpp index 57eec460..d9617fe2 100644 --- a/src/ui/widgets/windows/w_MainWindow.cpp +++ b/src/ui/widgets/windows/w_MainWindow.cpp @@ -657,7 +657,10 @@ void MainWindow::OnConnected(const ConnectionGroupPair &id) // QTimer::singleShot(1000, ConnectionManager, [id]() { // After the kernel initialization is complete, we can test the delay without worry - ConnectionManager->StartLatencyTest(id.connectionId); + if (GlobalConfig.advancedConfig.testLatencyOnConnected) + { + ConnectionManager->StartLatencyTest(id.connectionId); + } }); if (GlobalConfig.inboundConfig.systemProxySettings.setSystemProxy) { diff --git a/src/ui/widgets/windows/w_PreferencesWindow.cpp b/src/ui/widgets/windows/w_PreferencesWindow.cpp index 1a46c385..9f0cf111 100644 --- a/src/ui/widgets/windows/w_PreferencesWindow.cpp +++ b/src/ui/widgets/windows/w_PreferencesWindow.cpp @@ -194,6 +194,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QvDialog("PreferenceWind setAllowInsecureCB->setChecked(CurrentConfig.advancedConfig.setAllowInsecure); setSessionResumptionCB->setChecked(CurrentConfig.advancedConfig.setSessionResumption); setTestLatenctCB->setChecked(CurrentConfig.advancedConfig.testLatencyPeriodcally); + setTestLatenctOnConnectedCB->setChecked(CurrentConfig.advancedConfig.testLatencyOnConnected); disableSystemRootCB->setChecked(CurrentConfig.advancedConfig.disableSystemRoot); } // @@ -854,6 +855,16 @@ void PreferencesWindow::on_setTestLatenctCB_stateChanged(int arg1) CurrentConfig.advancedConfig.testLatencyPeriodcally = arg1 == Qt::Checked; } +void PreferencesWindow::on_setTestLatenctOnConnectedCB_stateChanged(int arg1) +{ + LOADINGCHECK + if (arg1 == Qt::Checked) + { + QvMessageBoxWarn(this, tr("Dangerous Operation"), tr("This will (probably) make it easy to fingerprint your connection.")); + } + CurrentConfig.advancedConfig.testLatencyOnConnected = arg1 == Qt::Checked; +} + void PreferencesWindow::on_setSessionResumptionCB_stateChanged(int arg1) { LOADINGCHECK diff --git a/src/ui/widgets/windows/w_PreferencesWindow.hpp b/src/ui/widgets/windows/w_PreferencesWindow.hpp index ea9c7ae8..867c20b8 100644 --- a/src/ui/widgets/windows/w_PreferencesWindow.hpp +++ b/src/ui/widgets/windows/w_PreferencesWindow.hpp @@ -96,6 +96,7 @@ class PreferencesWindow void on_qvProxyPortCB_valueChanged(int arg1); void on_setAllowInsecureCB_stateChanged(int arg1); void on_setTestLatenctCB_stateChanged(int arg1); + void on_setTestLatenctOnConnectedCB_stateChanged(int arg1); void on_setSessionResumptionCB_stateChanged(int arg1); void on_quietModeCB_stateChanged(int arg1); void on_tproxGroupBox_toggled(bool arg1); diff --git a/src/ui/widgets/windows/w_PreferencesWindow.ui b/src/ui/widgets/windows/w_PreferencesWindow.ui index f7b1e502..bb44fa32 100644 --- a/src/ui/widgets/windows/w_PreferencesWindow.ui +++ b/src/ui/widgets/windows/w_PreferencesWindow.ui @@ -647,6 +647,20 @@ But could damage your server if improperly used. + + + + Test Latency On Connected + + + + + + + Enabled + + + diff --git a/translations/en_US.ts b/translations/en_US.ts index 05d23a8d..3517a070 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -1335,6 +1335,10 @@ This could resolve the certificate issues, but also could let one performing TLS Test Latency Periodcally + + Test Latency On Connected + + Run TCPing or ICMPing periodcally after connecting to a server. Qv2ray will give a more accurate latency value if Enabled, but makes it easy to fingerprint the connection. diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 3298db6c..2577d149 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -1342,6 +1342,10 @@ This could resolve the certificate issues, but also could let one performing TLS Test Latency Periodcally 定时测试延迟 + + Test Latency On Connected + 连接后测试延迟 + Run TCPing or ICMPing periodcally after connecting to a server. Qv2ray will give a more accurate latency value if Enabled, but makes it easy to fingerprint the connection.