diff --git a/fmt/Bean2CoreObj_box.cpp b/fmt/Bean2CoreObj_box.cpp index 241da5f..0bd6dea 100644 --- a/fmt/Bean2CoreObj_box.cpp +++ b/fmt/Bean2CoreObj_box.cpp @@ -55,6 +55,7 @@ namespace NekoRay::fmt { QJsonObject outbound; outbound["type"] = socks_http_type == type_HTTP ? "http" : "socks"; + if (socks_http_type == type_Socks4) outbound["version"] = "4"; outbound["server"] = serverAddress; outbound["server_port"] = serverPort; diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 0a72296..d5dda0e 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -850,12 +850,16 @@ void MainWindow::refresh_proxy_list_impl(const int &id, NekoRay::GroupSortAction ms_a = NekoRay::profileManager->GetProfile(a)->full_test_report; ms_b = NekoRay::profileManager->GetProfile(b)->full_test_report; } + auto get_latency_for_sort = [](int id) { + auto i = NekoRay::profileManager->GetProfile(id)->latency; + if (i < 0) i = 99999; + return i; + }; 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; + if (ms_a.isEmpty() && ms_b.isEmpty()) { + // compare latency if full_test_report is empty + return get_latency_for_sort(a) > get_latency_for_sort(b); } } return ms_a > ms_b; @@ -863,8 +867,9 @@ void MainWindow::refresh_proxy_list_impl(const int &id, NekoRay::GroupSortAction 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; + if (ms_a.isEmpty() && ms_b.isEmpty()) { + // compare latency if full_test_report is empty + return get_latency_for_sort(a) < get_latency_for_sort(b); } } return ms_a < ms_b; diff --git a/ui/mainwindow_grpc.cpp b/ui/mainwindow_grpc.cpp index 87d06c5..9cfa248 100644 --- a/ui/mainwindow_grpc.cpp +++ b/ui/mainwindow_grpc.cpp @@ -126,9 +126,13 @@ void MainWindow::speedtest_current_group(int mode) { } if (!rpcOK) return; - profile->latency = result.ms(); - if (profile->latency == 0) profile->latency = -1; // sn - profile->full_test_report = result.full_report().c_str(); + if (result.error().empty()) { + profile->latency = result.ms(); + if (profile->latency == 0) profile->latency = 1; // nekoray use 0 to represents not tested + } else { + profile->latency = -1; + } + profile->full_test_report = result.full_report().c_str(); // higher priority profile->Save(); if (!result.error().empty()) {