From 8c4feac34e7e906ff9a60ea29a95b8b7a4fe235f Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Fri, 10 Feb 2023 17:43:12 +0900 Subject: [PATCH] fix --- db/ConfigBuilder.cpp | 11 +++++++---- db/Database.cpp | 1 + db/ProxyEntity.hpp | 1 - ui/mainwindow.cpp | 34 +++++++++++++++++++--------------- ui/mainwindow_grpc.cpp | 2 +- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/db/ConfigBuilder.cpp b/db/ConfigBuilder.cpp index dffd462..c5e5dd4 100644 --- a/db/ConfigBuilder.cpp +++ b/db/ConfigBuilder.cpp @@ -27,7 +27,7 @@ namespace NekoRay { } // hook.js - if (result->error.isEmpty()) { + if (result->error.isEmpty() && !forTest) { auto source = qjs::ReadHookJS(); if (!source.isEmpty()) { qjs::QJS js(source); @@ -274,7 +274,7 @@ namespace NekoRay { }); } dnsServers += QJsonObject{ - {"address", directDnsAddress}, + {"address", directDnsAddress.replace("https://", "https+local://")}, {"fallbackStrategy", "disabled"}, {"domains", QList2QJsonArray(status->domainListDNSDirect)}, }; @@ -595,9 +595,12 @@ namespace NekoRay { auto stream = GetStreamSettings(ent->bean.data()); if (stream != nullptr && !stream->packet_encoding.isEmpty()) { muxObj["packetEncoding"] = stream->packet_encoding; + } else if (stream != nullptr && stream->network == "grpc") { + // ignore mux.cool for gRPC + } else { + outbound["mux"] = muxObj; + muxApplied = true; } - outbound["mux"] = muxObj; - muxApplied = true; } } } diff --git a/db/Database.cpp b/db/Database.cpp index 0a69ebe..389b9e6 100644 --- a/db/Database.cpp +++ b/db/Database.cpp @@ -109,6 +109,7 @@ namespace NekoRay { _add(new configItem("id", &id, itemType::integer)); _add(new configItem("gid", &gid, itemType::integer)); _add(new configItem("yc", &latency, itemType::integer)); + _add(new configItem("report", &full_test_report, itemType::string)); // 可以不关联 bean,只加载 ProxyEntity 的信息 if (bean != nullptr) { diff --git a/db/ProxyEntity.hpp b/db/ProxyEntity.hpp index 9195408..ae28431 100644 --- a/db/ProxyEntity.hpp +++ b/db/ProxyEntity.hpp @@ -31,7 +31,6 @@ namespace NekoRay { QSharedPointer bean; QSharedPointer traffic_data = QSharedPointer(new traffic::TrafficData("")); - // Cache QString full_test_report; ProxyEntity(fmt::AbstractBean *bean, const QString &type_); diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index bed363b..e9d3c47 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -831,6 +831,7 @@ void MainWindow::refresh_proxy_list_impl(const int &id, NekoRay::GroupSortAction } case NekoRay::GroupSortMethod::ByAddress: case NekoRay::GroupSortMethod::ByName: + case NekoRay::GroupSortMethod::ByLatency: case NekoRay::GroupSortMethod::ByType: { std::sort(ui->proxyListTable->order.begin(), ui->proxyListTable->order.end(), [=](int a, int b) { @@ -845,25 +846,27 @@ void MainWindow::refresh_proxy_list_impl(const int &id, NekoRay::GroupSortAction } else if (groupSortAction.method == NekoRay::GroupSortMethod::ByAddress) { ms_a = NekoRay::profileManager->GetProfile(a)->bean->DisplayAddress(); ms_b = NekoRay::profileManager->GetProfile(b)->bean->DisplayAddress(); + } else if (groupSortAction.method == NekoRay::GroupSortMethod::ByLatency) { + ms_a = NekoRay::profileManager->GetProfile(a)->full_test_report; + ms_b = NekoRay::profileManager->GetProfile(b)->full_test_report; } if (groupSortAction.descending) { + if (groupSortAction.method == NekoRay::GroupSortMethod::ByLatency) { + auto int_a = NekoRay::profileManager->GetProfile(a)->latency; + auto int_b = NekoRay::profileManager->GetProfile(b)->latency; + if (int_a > 0 && int_b > 0) { + return int_a > int_b; + } + } return ms_a > ms_b; } else { - return ms_a < ms_b; - } - }); - break; - } - case NekoRay::GroupSortMethod::ByLatency: { - std::sort(ui->proxyListTable->order.begin(), ui->proxyListTable->order.end(), - [=](int a, int b) { - auto ms_a = NekoRay::profileManager->GetProfile(a)->latency; - auto ms_b = NekoRay::profileManager->GetProfile(b)->latency; - if (ms_a <= 0) ms_a = 114514; - if (ms_b <= 0) ms_b = 114514; - if (groupSortAction.descending) { - return ms_a > ms_b; - } else { + if (groupSortAction.method == NekoRay::GroupSortMethod::ByLatency) { + auto int_a = NekoRay::profileManager->GetProfile(a)->latency; + auto int_b = NekoRay::profileManager->GetProfile(b)->latency; + if (int_a > 0 && int_b > 0) { + return int_a < int_b; + } + } return ms_a < ms_b; } }); @@ -1283,6 +1286,7 @@ void MainWindow::on_menu_resolve_domain_triggered() { } if (mw_sub_updating) return; mw_sub_updating = true; + NekoRay::dataStore->resolve_count = profiles.count(); for (const auto &profile: profiles) { profile->bean->ResolveDomainToIP([=] { diff --git a/ui/mainwindow_grpc.cpp b/ui/mainwindow_grpc.cpp index fc35556..5060626 100644 --- a/ui/mainwindow_grpc.cpp +++ b/ui/mainwindow_grpc.cpp @@ -66,7 +66,7 @@ void MainWindow::speedtest_current_group(int mode) { runOnNewThread([this, profiles, mode, full_test_flags]() { QMutex lock_write; QMutex lock_return; - int threadN = mode == libcore::FullTest ? 1 : NekoRay::dataStore->test_concurrent; + int threadN = NekoRay::dataStore->test_concurrent; int threadN_finished = 0; auto profiles_test = profiles; // copy