From 180a764977804b3707d0829fae1ab916745764b1 Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Sat, 25 Mar 2023 11:43:02 +0900 Subject: [PATCH] update domain strategy --- db/ConfigBuilder.cpp | 20 +++++--------------- fmt/Preset.hpp | 5 +++-- translations/fa_IR.ts | 10 +++++----- translations/zh_CN.ts | 34 +++++----------------------------- ui/dialog_manage_routes.cpp | 3 +++ ui/dialog_manage_routes.ui | 34 ++-------------------------------- ui/mainwindow.cpp | 5 +++++ 7 files changed, 28 insertions(+), 83 deletions(-) diff --git a/db/ConfigBuilder.cpp b/db/ConfigBuilder.cpp index 91fa95c..71e3e14 100644 --- a/db/ConfigBuilder.cpp +++ b/db/ConfigBuilder.cpp @@ -568,21 +568,8 @@ namespace NekoRay { status->result->outboundStats += ent->traffic_data; if (IS_NEKO_BOX) { - auto ds = dataStore->outbound_domain_strategy; - if (status->forTest) { - ds = ""; - } else if (ds == "UseIPv4") { - ds = "ipv4_only"; - } else if (ds == "UseIPv6") { - ds = "ipv6_only"; - } else if (ds == "PreferIPv4") { - ds = "prefer_ipv4"; - } else if (ds == "PreferIPv6") { - ds = "prefer_ipv6"; - } else { - ds = ""; - } - outbound["domain_strategy"] = ds; + // apply domain_strategy + outbound["domain_strategy"] = dataStore->outbound_domain_strategy; // TODO apply mux } else { if (!status->forTest) outbound["domainStrategy"] = dataStore->outbound_domain_strategy; @@ -655,6 +642,9 @@ namespace NekoRay { }, }; } + // apply domain_strategy + inboundObj["domain_strategy"] = dataStore->outbound_domain_strategy; + // status->inbounds += inboundObj; } diff --git a/fmt/Preset.hpp b/fmt/Preset.hpp index d83c2bf..7d1ad4e 100644 --- a/fmt/Preset.hpp +++ b/fmt/Preset.hpp @@ -18,12 +18,13 @@ namespace Preset { namespace SingBox { inline QStringList VpnImplementation = {"gvisor", "system"}; - } + inline QStringList DomainStrategy = {"", "ipv4_only", "ipv6_only", "prefer_ipv4", "prefer_ipv6"}; + } // namespace SingBox namespace Windows { inline QStringList system_proxy_format{"{ip}:{http_port}", "socks={ip}:{socks_port}", "http={ip}:{http_port};https={ip}:{http_port};ftp={ip}:{http_port};socks={ip}:{socks_port}", "http=http://{ip}:{http_port};https=http://{ip}:{http_port}"}; - } + } // namespace Windows } // namespace Preset diff --git a/translations/fa_IR.ts b/translations/fa_IR.ts index a9c9b49..c085e66 100644 --- a/translations/fa_IR.ts +++ b/translations/fa_IR.ts @@ -460,10 +460,6 @@ The sniffing result is used for destination - - Outbound Domain Strategy - - Remote DNS @@ -477,7 +473,7 @@ فعال کردن مسیریابی DNS - Domain Strategy + V2Ray Domain Strategy استراتژی دامنه @@ -568,6 +564,10 @@ Remote + + Inbound & Outbound Domain Strategy + + DialogVPNSettings diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 5982152..2f7b6d5 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -99,10 +99,6 @@ Use proxy when updating subscription 更新订阅时使用代理 - - Language - 语言 - Security 安全 @@ -442,10 +438,6 @@ Routes 路由 - - Outbound Domain Strategy - 出站域名策略 - Disable 禁用 @@ -470,20 +462,12 @@ Remote DNS 远程 DNS - - Enhanced domain name resolution - 增强域名解析 - - - Using multiple overseas DNS to query the server address can alleviate the DNS pollution of the server domain name to a certain extent, which may have side effects. - 使用多个境外 DNS 查询服务器地址,一定程度上可缓解对服务器域名的 DNS 污染,可能有副作用。 - Enable DNS Routing 启用 DNS 路由 - Domain Strategy + V2Ray Domain Strategy 域名策略 @@ -574,6 +558,10 @@ Remote 远程 + + Inbound & Outbound Domain Strategy + 出入站域名策略 + DialogVPNSettings @@ -1077,14 +1065,6 @@ https://matsuridayo.github.io/n-configuration/#vpn-tun Destination 目标地址 - - End - 结束 - - - Active - 活动 - Start: %1 End: %2 @@ -1308,10 +1288,6 @@ Split by line. ProxyItem - - Remove - 删除 - Confirmation 确认 diff --git a/ui/dialog_manage_routes.cpp b/ui/dialog_manage_routes.cpp index af4f281..cea37b7 100644 --- a/ui/dialog_manage_routes.cpp +++ b/ui/dialog_manage_routes.cpp @@ -4,6 +4,7 @@ #include "qv2ray/v2/ui/widgets/editors/w_JsonEditor.hpp" #include "qv2ray/v3/components/GeositeReader/GeositeReader.hpp" #include "main/GuiUtils.hpp" +#include "fmt/Preset.hpp" #include #include @@ -31,8 +32,10 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne if (IS_NEKO_BOX) { ui->domain_v2ray->setVisible(false); + ui->outbound_domain_strategy->addItems(Preset::SingBox::DomainStrategy); } else { ui->domain_v2ray->setVisible(true); + ui->outbound_domain_strategy->addItems({"AsIs", "UseIPv4", "UseIPv6", "PreferIPv4", "PreferIPv6"}); } // ui->sniffing_mode->setCurrentIndex(NekoRay::dataStore->sniffing_mode); diff --git a/ui/dialog_manage_routes.ui b/ui/dialog_manage_routes.ui index 09a6f2f..7ca7dfd 100644 --- a/ui/dialog_manage_routes.ui +++ b/ui/dialog_manage_routes.ui @@ -67,7 +67,7 @@ - Outbound Domain Strategy + Inbound & Outbound Domain Strategy @@ -76,36 +76,6 @@ false - - - AsIs - - - - - UseIP - - - - - UseIPv4 - - - - - UseIPv6 - - - - - PreferIPv4 - - - - - PreferIPv6 - - @@ -179,7 +149,7 @@ - Domain Strategy + V2Ray Domain Strategy diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 4964269..4c7f505 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -1,6 +1,7 @@ #include "./ui_mainwindow.h" #include "mainwindow.h" +#include "fmt/Preset.hpp" #include "db/ProfileFilter.hpp" #include "db/ConfigBuilder.hpp" #include "sub/GroupUpdater.hpp" @@ -92,9 +93,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi if (IS_NEKO_BOX) { software_name = "NekoBox"; software_core_name = "sing-box"; + // replace default values if (NekoRay::dataStore->log_level == "warning") { NekoRay::dataStore->log_level = "info"; } + if (!Preset::SingBox::DomainStrategy.contains(NekoRay::dataStore->outbound_domain_strategy)) { + NekoRay::dataStore->outbound_domain_strategy = ""; + } } // top bar