diff --git a/db/ConfigBuilder.cpp b/db/ConfigBuilder.cpp index c5e5dd4..039e383 100644 --- a/db/ConfigBuilder.cpp +++ b/db/ConfigBuilder.cpp @@ -247,6 +247,7 @@ namespace NekoRay { QJsonObject dnsServerRemote; dnsServerRemote["address"] = dataStore->fake_dns ? "fakedns" : dataStore->remote_dns; dnsServerRemote["domains"] = QList2QJsonArray(status->domainListDNSRemote); + dnsServerRemote["queryStrategy"] = dataStore->remote_dns_strategy; if (!status->forTest) dnsServers += dnsServerRemote; // Direct @@ -276,6 +277,7 @@ namespace NekoRay { dnsServers += QJsonObject{ {"address", directDnsAddress.replace("https://", "https+local://")}, {"fallbackStrategy", "disabled"}, + {"queryStrategy", dataStore->direct_dns_strategy}, {"domains", QList2QJsonArray(status->domainListDNSDirect)}, }; @@ -754,6 +756,7 @@ namespace NekoRay { dnsServers += QJsonObject{ {"tag", "dns-remote"}, {"address_resolver", "dns-underlying"}, + {"strategy", dataStore->remote_dns_strategy}, {"address", dataStore->remote_dns}, {"detour", tagProxy}, }; @@ -768,6 +771,7 @@ namespace NekoRay { dnsServers += QJsonObject{ {"tag", "dns-direct"}, {"address_resolver", "dns-underlying"}, + {"strategy", dataStore->direct_dns_strategy}, {"address", directDNSAddress.replace("+local://", "://")}, {"detour", "direct"}, }; diff --git a/main/NekoRay.cpp b/main/NekoRay.cpp index 69f77cb..1de4cbe 100644 --- a/main/NekoRay.cpp +++ b/main/NekoRay.cpp @@ -27,7 +27,9 @@ namespace NekoRay { _add(new configItem("inbound_http_port", &inbound_http_port, itemType::integer)); _add(new configItem("log_level", &log_level, itemType::string)); _add(new configItem("remote_dns", &remote_dns, itemType::string)); + _add(new configItem("remote_dns_strategy", &remote_dns_strategy, itemType::string)); _add(new configItem("direct_dns", &direct_dns, itemType::string)); + _add(new configItem("direct_dns_strategy", &direct_dns_strategy, itemType::string)); _add(new configItem("domain_matcher", &domain_matcher, itemType::integer)); _add(new configItem("domain_strategy", &domain_strategy, itemType::string)); _add(new configItem("outbound_domain_strategy", &outbound_domain_strategy, itemType::string)); diff --git a/main/NekoRay_DataStore.hpp b/main/NekoRay_DataStore.hpp index f9cf4d7..c2a7b6f 100644 --- a/main/NekoRay_DataStore.hpp +++ b/main/NekoRay_DataStore.hpp @@ -115,7 +115,9 @@ namespace NekoRay { // DNS QString remote_dns = "https://8.8.8.8/dns-query"; + QString remote_dns_strategy = ""; QString direct_dns = "localhost"; + QString direct_dns_strategy = ""; bool dns_routing = true; // Routing diff --git a/translations/fa_IR.ts b/translations/fa_IR.ts index d7ccb48..f81ae76 100644 --- a/translations/fa_IR.ts +++ b/translations/fa_IR.ts @@ -560,6 +560,14 @@ Default Outbound + + Query Strategy + + + + Remote + + DialogVPNSettings diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 02dab63..fd5d8d6 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -225,7 +225,7 @@ Maybe useful for HiDPI screens. - + 可能对 HiDPI 屏幕有用。 Skip TLS certificate authentication by default (allowInsecure) @@ -566,6 +566,14 @@ Default Outbound 默认出站 + + Query Strategy + DNS 查询策略 + + + Remote + 远程 + DialogVPNSettings diff --git a/ui/dialog_manage_routes.cpp b/ui/dialog_manage_routes.cpp index 332294c..af4f281 100644 --- a/ui/dialog_manage_routes.cpp +++ b/ui/dialog_manage_routes.cpp @@ -210,3 +210,46 @@ void DialogManageRoutes::on_load_save_clicked() { w->exec(); w->deleteLater(); } +void DialogManageRoutes::on_queryStrategy_clicked() { + auto w = new QDialog(this); + w->setWindowTitle("DNS Query Strategy"); + auto layout = new QGridLayout; + w->setLayout(layout); + // + QStringList qsValue{""}; + if (IS_NEKO_BOX) { + qsValue += QString("prefer_ipv4 prefer_ipv6 ipv4_only ipv6_only").split(" "); + } else { + qsValue += QString("use_ip use_ip4 use_ip6").split(" "); + } + // + auto remote_l = new QLabel(tr("Remote")); + auto direct_l = new QLabel(tr("Direct")); + auto remote = new QComboBox; + auto direct = new QComboBox; + remote->setEditable(true); + remote->addItems(qsValue); + remote->setCurrentText(NekoRay::dataStore->remote_dns_strategy); + direct->setEditable(true); + direct->addItems(qsValue); + direct->setCurrentText(NekoRay::dataStore->direct_dns_strategy); + // + layout->addWidget(remote_l, 0, 0); + layout->addWidget(remote, 0, 1); + layout->addWidget(direct_l, 1, 0); + layout->addWidget(direct, 1, 1); + auto box = new QDialogButtonBox; + box->setOrientation(Qt::Horizontal); + box->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); + connect(box, &QDialogButtonBox::accepted, w, [=] { + NekoRay::dataStore->remote_dns_strategy = remote->currentText(); + NekoRay::dataStore->direct_dns_strategy = direct->currentText(); + NekoRay::dataStore->Save(); + w->accept(); + }); + connect(box, &QDialogButtonBox::rejected, w, &QDialog::reject); + layout->addWidget(box, 2, 1); + // + w->exec(); + w->deleteLater(); +} diff --git a/ui/dialog_manage_routes.h b/ui/dialog_manage_routes.h index ac375b1..036631e 100644 --- a/ui/dialog_manage_routes.h +++ b/ui/dialog_manage_routes.h @@ -54,4 +54,6 @@ public slots: void SetRouteConfig(const NekoRay::Routing &conf); void on_load_save_clicked(); + + void on_queryStrategy_clicked(); }; diff --git a/ui/dialog_manage_routes.ui b/ui/dialog_manage_routes.ui index a91219d..09a6f2f 100644 --- a/ui/dialog_manage_routes.ui +++ b/ui/dialog_manage_routes.ui @@ -132,6 +132,13 @@ + + + + Query Strategy + + +