diff --git a/db/ConfigBuilder.cpp b/db/ConfigBuilder.cpp index a94c846..683b587 100644 --- a/db/ConfigBuilder.cpp +++ b/db/ConfigBuilder.cpp @@ -290,7 +290,7 @@ namespace NekoRay { routing["domainMatcher"] = dataStore->domain_matcher == DomainMatcher::MPH ? "mph" : "linear"; if (status->forTest) routing["domainStrategy"] = "AsIs"; - // final add block route + // final add user rule (block) QJsonObject routingRule_tmp; routingRule_tmp["type"] = "field"; routingRule_tmp["outboundTag"] = "block"; @@ -305,7 +305,7 @@ namespace NekoRay { status->routingRules += tmp; } - // final add proxy route + // final add user rule (proxy) routingRule_tmp["outboundTag"] = "proxy"; if (!status->ipListRemote.isEmpty()) { auto tmp = routingRule_tmp; @@ -318,7 +318,7 @@ namespace NekoRay { status->routingRules += tmp; } - // final add bypass route + // final add user rule (bypass) routingRule_tmp["outboundTag"] = "bypass"; if (!status->ipListDirect.isEmpty()) { auto tmp = routingRule_tmp; @@ -331,8 +331,14 @@ namespace NekoRay { status->routingRules += tmp; } + // def_outbound + status->routingRules += QJsonObject{ + {"type", "field"}, + {"port", "0-65535"}, + {"outboundTag", dataStore->routing->def_outbound}, + }; + // final add routing rule - // custom routing rule auto routingRules = QString2QJsonObject(dataStore->routing->custom)["rules"].toArray(); if (status->forTest) routingRules = {}; if (!status->forTest) QJSONARRAY_ADD(routingRules, QString2QJsonObject(dataStore->custom_route_global)["rules"].toArray()) @@ -604,11 +610,7 @@ namespace NekoRay { // Bypass Lookup for the first profile if (isFirstProfile && !IsIpAddress(ent->bean->serverAddress)) { - if (dataStore->enhance_resolve_server_domain && !IS_NEKO_BOX) { - status->result->tryDomains += ent->bean->serverAddress; - } else { - status->domainListDNSDirect += "full:" + ent->bean->serverAddress; - } + status->domainListDNSDirect += "full:" + ent->bean->serverAddress; } status->outbounds += outbound; @@ -791,22 +793,18 @@ namespace NekoRay { // Routing - // custom routing rule (top) - auto routingRules = QString2QJsonObject(dataStore->routing->custom)["rules"].toArray(); - if (status->forTest) routingRules = {}; - // dns hijack - if (!status->forTest) routingRules += QJsonObject{{"protocol", "dns"}, {"outbound", "dns-out"}}; + if (!status->forTest) status->routingRules += QJsonObject{{"protocol", "dns"}, {"outbound", "dns-out"}}; // sing-box routing rule object auto add_rule_route = [&](const QStringList &list, bool isIP, const QString &out) { auto rule = make_rule(list, isIP); if (rule.isEmpty()) return; rule["outbound"] = out; - routingRules += rule; + status->routingRules += rule; }; - // final add routing rule + // final add user rule add_rule_route(status->ipListBlock, true, "block"); add_rule_route(status->ipListRemote, true, tagProxy); add_rule_route(status->ipListDirect, true, "bypass"); @@ -814,6 +812,12 @@ namespace NekoRay { add_rule_route(status->domainListRemote, false, tagProxy); add_rule_route(status->domainListDirect, false, "bypass"); + // def_outbound + status->routingRules += QJsonObject{ + {"port_range", ":"}, + {"outbound", dataStore->routing->def_outbound}, + }; + // geopath auto geoip = FindCoreAsset("geoip.db"); auto geosite = FindCoreAsset("geosite.db"); @@ -821,6 +825,8 @@ namespace NekoRay { if (geosite.isEmpty()) status->result->error = +"geosite.db not found"; // final add routing rule + auto routingRules = QString2QJsonObject(dataStore->routing->custom)["rules"].toArray(); + if (status->forTest) routingRules = {}; if (!status->forTest) QJSONARRAY_ADD(routingRules, QString2QJsonObject(dataStore->custom_route_global)["rules"].toArray()) QJSONARRAY_ADD(routingRules, status->routingRules) auto routeObj = QJsonObject{ diff --git a/db/ConfigBuilder.hpp b/db/ConfigBuilder.hpp index 7ca4925..1fa35dc 100644 --- a/db/ConfigBuilder.hpp +++ b/db/ConfigBuilder.hpp @@ -8,7 +8,6 @@ namespace NekoRay { public: QString error; QJsonObject coreConfig; - QStringList tryDomains; QList> outboundStats; // all, but not including "bypass" "block" QSharedPointer outboundStat; // main diff --git a/main/NekoRay.cpp b/main/NekoRay.cpp index 89f207d..91371d8 100644 --- a/main/NekoRay.cpp +++ b/main/NekoRay.cpp @@ -41,7 +41,6 @@ namespace NekoRay { _add(new configItem("custom_route", &custom_route_global, itemType::string)); _add(new configItem("v2ray_asset_dir", &v2ray_asset_dir, itemType::string)); _add(new configItem("sub_use_proxy", &sub_use_proxy, itemType::boolean)); - _add(new configItem("enhance_domain", &enhance_resolve_server_domain, itemType::boolean)); _add(new configItem("remember_id", &remember_id, itemType::integer)); _add(new configItem("remember_enable", &remember_enable, itemType::boolean)); _add(new configItem("language", &language, itemType::integer)); @@ -108,6 +107,7 @@ namespace NekoRay { _add(new configItem("proxy_domain", &this->proxy_domain, itemType::string)); _add(new configItem("block_ip", &this->block_ip, itemType::string)); _add(new configItem("block_domain", &this->block_domain, itemType::string)); + _add(new configItem("def_outbound", &this->def_outbound, itemType::string)); _add(new configItem("custom", &this->custom, itemType::string)); } diff --git a/main/NekoRay_DataStore.hpp b/main/NekoRay_DataStore.hpp index 3d7d5c3..4b8b28e 100644 --- a/main/NekoRay_DataStore.hpp +++ b/main/NekoRay_DataStore.hpp @@ -10,6 +10,7 @@ namespace NekoRay { QString proxy_domain; QString block_ip; QString block_domain; + QString def_outbound = "proxy"; QString custom = "{\"rules\": []}"; explicit Routing(int preset = 0); @@ -116,7 +117,6 @@ namespace NekoRay { QString remote_dns = "https://8.8.8.8/dns-query"; QString direct_dns = "localhost"; bool dns_routing = true; - bool enhance_resolve_server_domain = false; // Routing bool fake_dns = false; diff --git a/translations/fa_IR.ts b/translations/fa_IR.ts index 01f3c02..1c26439 100644 --- a/translations/fa_IR.ts +++ b/translations/fa_IR.ts @@ -468,14 +468,6 @@ Direct DNS - - 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. - - - - Enhanced domain name resolution - - Enable DNS Routing @@ -560,6 +552,10 @@ Remove routing: %1 + + Default Outbound + + DialogVPNSettings diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 25f699c..b3c952f 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -468,11 +468,11 @@ 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 污染,可能有副作用。 + 使用多个境外 DNS 查询服务器地址,一定程度上可缓解对服务器域名的 DNS 污染,可能有副作用。 Enable DNS Routing @@ -558,6 +558,10 @@ Custom (global) 自定义 (全局) + + Default Outbound + 默认出站 + DialogVPNSettings diff --git a/ui/dialog_manage_routes.cpp b/ui/dialog_manage_routes.cpp index 82c01ce..332294c 100644 --- a/ui/dialog_manage_routes.cpp +++ b/ui/dialog_manage_routes.cpp @@ -9,11 +9,11 @@ #include #include -#define REFRESH_ACTIVE_ROUTING(a, r) \ - active_routing = a; \ - ui->active_routing->setText("[" + active_routing + "]"); \ - setWindowTitle(title_base + " [" + a + "]"); \ - SetRouteConfig(*r); +#define REFRESH_ACTIVE_ROUTING(name, obj) \ + this->active_routing = name; \ + ui->active_routing->setText(name); \ + setWindowTitle(title_base + " [" + name + "]"); \ + SetRouteConfig(*obj); #define SAVE_TO_ROUTING(r) \ r->direct_ip = directIPTxt->toPlainText(); \ @@ -22,6 +22,7 @@ r->proxy_domain = proxyDomainTxt->toPlainText(); \ r->block_ip = blockIPTxt->toPlainText(); \ r->block_domain = blockDomainTxt->toPlainText(); \ + r->def_outbound = ui->def_outbound->currentText(); \ r->custom = CACHE.custom_route; DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(new Ui::DialogManageRoutes) { @@ -29,10 +30,8 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne title_base = windowTitle(); if (IS_NEKO_BOX) { - ui->enhance_resolve_server_domain->setVisible(false); ui->domain_v2ray->setVisible(false); } else { - ui->enhance_resolve_server_domain->setVisible(true); ui->domain_v2ray->setVisible(true); } // @@ -43,7 +42,6 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne ui->dns_routing->setChecked(NekoRay::dataStore->dns_routing); ui->dns_remote->setText(NekoRay::dataStore->remote_dns); ui->dns_direct->setText(NekoRay::dataStore->direct_dns); - ui->enhance_resolve_server_domain->setChecked(NekoRay::dataStore->enhance_resolve_server_domain); D_C_LOAD_STRING(custom_route_global) // connect(ui->custom_route_edit, &QPushButton::clicked, this, [=] { @@ -93,7 +91,6 @@ void DialogManageRoutes::accept() { NekoRay::dataStore->dns_routing = ui->dns_routing->isChecked(); NekoRay::dataStore->remote_dns = ui->dns_remote->text(); NekoRay::dataStore->direct_dns = ui->dns_direct->text(); - NekoRay::dataStore->enhance_resolve_server_domain = ui->enhance_resolve_server_domain->isChecked(); D_C_SAVE_STRING(custom_route_global) bool routeChanged = false; if (NekoRay::dataStore->active_routing != active_routing) routeChanged = true; @@ -135,6 +132,7 @@ void DialogManageRoutes::SetRouteConfig(const NekoRay::Routing &conf) { proxyIPTxt->setPlainText(conf.proxy_ip); // CACHE.custom_route = conf.custom; + ui->def_outbound->setCurrentText(conf.def_outbound); } void DialogManageRoutes::on_load_save_clicked() { diff --git a/ui/dialog_manage_routes.ui b/ui/dialog_manage_routes.ui index a486f3b..60e08b7 100644 --- a/ui/dialog_manage_routes.ui +++ b/ui/dialog_manage_routes.ui @@ -13,67 +13,171 @@ Routes - - - - - - - + + + + + + + + + + + 0 + 0 + + + + Sniffing Mode + + + + + + + + Disable + + + + + The sniffing result is used for routing + + + + + The sniffing result is used for destination + + + + + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + Outbound Domain Strategy + + + + + + + false + + + + AsIs + + + + + UseIP + + + + + UseIPv4 + + + + + UseIPv6 + + + + + PreferIPv4 + + + + + PreferIPv6 + + + + + + + + + + + + Remote DNS + + + + + + + + + + Direct DNS + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + - + - + 0 0 - Sniffing Mode + Enable DNS Routing - - - - Disable - - - - - The sniffing result is used for routing - - - - - The sniffing result is used for destination - - - - - - + Qt::Vertical - - - - 0 - 0 - - + - Outbound Domain Strategy + Domain Strategy - + false @@ -84,284 +188,282 @@ - UseIP + IPIfNonMatch - UseIPv4 + IPOnDemand + + + + + + + + Matcher + + + + + + + + Original - UseIPv6 - - - - - PreferIPv4 - - - - - PreferIPv6 + Minimal Perfect Hash Matcher - - - - - - - Remote DNS + + + + + + + + + + + + + + Block + + + Qt::AlignCenter + + + + + + + + + + Direct + + + Qt::AlignCenter + + + + + + + Domain + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Proxy + + + Qt::AlignCenter + + + + + + + + + + + + + IP + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + QFrame::Box + + + + + + + + + + + + + + + 0 - - - - - - - - - Direct DNS + + 0 - - - - - - - - - - 0 - 0 - + + 0 - - 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. + + 0 - - Enhanced domain name resolution + + + + + 0 + 0 + + + + Preset + + + QToolButton::InstantPopup + + + Qt::ToolButtonTextBesideIcon + + + + + + + Custom + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 - - - - - + + 0 + + + 0 + + + 0 + + + + + Default Outbound + + + + + + + + proxy + + + + + bypass + + + + + block + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Mange route set + + + + + + + Custom (global) + + + + + - - - - - - - - - 0 - 0 - - - - Enable DNS Routing - - - - - - - Qt::Vertical - - - - - - - Domain Strategy - - - - - - - false - - - - AsIs - - - - - IPIfNonMatch - - - - - IPOnDemand - - - - - - - - Matcher - - - - - - - - Original - - - - - Minimal Perfect Hash Matcher - - - - - - - - - - - - - Block - - - Qt::AlignCenter - - - - - - - - - - Direct - - - Qt::AlignCenter - - - - - - - Domain - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - Proxy - - - Qt::AlignCenter - - - - - - - - - - - - - IP - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - - - - - - - - Preset - - - QToolButton::InstantPopup - - - Qt::ToolButtonTextBesideIcon - - - - - - - Custom - - - - - - - Custom (global) - - - - - - - Mange route set - - - - - - - - 0 - 0 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - + + + + 0 + 0 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + @@ -372,33 +474,17 @@ outbound_domain_strategy dns_remote dns_direct - enhance_resolve_server_domain dns_routing domainStrategyCombo domainMatcherCombo preset custom_route_edit - custom_route_global_edit + def_outbound load_save + custom_route_global_edit - - buttonBox - accepted() - DialogManageRoutes - accept() - - - 399 - 574 - - - 399 - 299 - - - buttonBox rejected() @@ -415,5 +501,21 @@ + + buttonBox + accepted() + DialogManageRoutes + accept() + + + 399 + 574 + + + 399 + 299 + + + diff --git a/ui/mainwindow_grpc.cpp b/ui/mainwindow_grpc.cpp index 10c8949..4b3ec14 100644 --- a/ui/mainwindow_grpc.cpp +++ b/ui/mainwindow_grpc.cpp @@ -220,7 +220,6 @@ void MainWindow::neko_start(int _id) { #ifndef NKR_NO_GRPC libcore::LoadConfigReq req; req.set_coreconfig(QJsonObject2QString(result->coreConfig, true).toStdString()); - req.set_trydomains(result->tryDomains.join(",").toStdString()); // bool rpcOK; QString error = defaultClient->Start(&rpcOK, req);