diff --git a/db/ConfigBuilder.cpp b/db/ConfigBuilder.cpp index cb5aec3..a1072aa 100644 --- a/db/ConfigBuilder.cpp +++ b/db/ConfigBuilder.cpp @@ -8,6 +8,8 @@ #include #include +#define BOX_UNDERLYING_DNS NekoRay::dataStore->core_box_underlying_dns.isEmpty() ? "underlying://0.0.0.0" : NekoRay::dataStore->core_box_underlying_dns + namespace NekoRay { // Common @@ -765,12 +767,9 @@ namespace NekoRay { {"detour", tagProxy}, }; - // neko only - auto underlyingStr = status->forExport ? "local" : "underlying://0.0.0.0"; - // Direct auto directDNSAddress = dataStore->direct_dns; - if (directDNSAddress == "localhost") directDNSAddress = underlyingStr; + if (directDNSAddress == "localhost") directDNSAddress = BOX_UNDERLYING_DNS; if (!status->forTest) dnsServers += QJsonObject{ {"tag", "dns-direct"}, @@ -783,7 +782,7 @@ namespace NekoRay { // Underlying 100% Working DNS dnsServers += QJsonObject{ {"tag", "dns-local"}, - {"address", underlyingStr}, + {"address", BOX_UNDERLYING_DNS}, {"detour", "direct"}, }; @@ -914,6 +913,7 @@ namespace NekoRay { .replace("%STRICT_ROUTE%", dataStore->vpn_strict_route ? "true" : "false") .replace("%SOCKS_USER_PASS%", socks_user_pass) .replace("%FINAL_OUT%", no_match_out) + .replace("%DNS_ADDRESS%", BOX_UNDERLYING_DNS) .replace("%PORT%", Int2String(dataStore->inbound_socks_port)); // hook.js auto source = qjs::ReadHookJS(); diff --git a/main/NekoRay.cpp b/main/NekoRay.cpp index cf27df0..9eb54f2 100644 --- a/main/NekoRay.cpp +++ b/main/NekoRay.cpp @@ -78,6 +78,7 @@ namespace NekoRay { _add(new configItem("core_box_auto_detect_interface", &core_box_auto_detect_interface, itemType::boolean)); _add(new configItem("core_box_clash_api", &core_box_clash_api, itemType::integer)); _add(new configItem("core_box_clash_api_secret", &core_box_clash_api_secret, itemType::string)); + _add(new configItem("core_box_underlying_dns", &core_box_underlying_dns, itemType::string)); #ifndef Q_OS_WIN _add(new configItem("vpn_already_admin", &vpn_already_admin, itemType::boolean)); #endif diff --git a/main/NekoRay_DataStore.hpp b/main/NekoRay_DataStore.hpp index b169a15..683a24e 100644 --- a/main/NekoRay_DataStore.hpp +++ b/main/NekoRay_DataStore.hpp @@ -153,6 +153,7 @@ namespace NekoRay { bool core_box_auto_detect_interface = true; int core_box_clash_api = -9090; QString core_box_clash_api_secret = ""; + QString core_box_underlying_dns = ""; // Other Core ExtraCore *extraCore = new ExtraCore; diff --git a/res/dashboard-notice.html b/res/dashboard-notice.html index 9b6c344..e42e34b 100644 --- a/res/dashboard-notice.html +++ b/res/dashboard-notice.html @@ -6,7 +6,11 @@

Please put your clash dashboard files to "nekoray/config/dashboard" dir.

For example, you can download from the following URL.

- Yacd-meta +

+ Download Yacd-meta + or + Use online +

diff --git a/res/vpn/sing-box-vpn.json b/res/vpn/sing-box-vpn.json index 514b871..6dddef8 100644 --- a/res/vpn/sing-box-vpn.json +++ b/res/vpn/sing-box-vpn.json @@ -3,7 +3,7 @@ "servers": [ { "tag": "dns-direct", - "address": "underlying://0.0.0.0", + "address": "%DNS_ADDRESS%", "detour": "direct" } ] diff --git a/translations/fa_IR.ts b/translations/fa_IR.ts index 4d12dd4..59b2e0d 100644 --- a/translations/fa_IR.ts +++ b/translations/fa_IR.ts @@ -237,6 +237,16 @@ Core Options + + Override underlying DNS + + + + It is recommended to leave it blank, but it sometimes does not work, at this time you can set this option. +For NekoRay, this rewrites the underlying(localhost) DNS in VPN mode. +For NekoBox, this rewrites the underlying(localhost) DNS in VPN mode, normal mode, and also URL Test. + + DialogEditGroup diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 2a59eff..914c376 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -231,6 +231,18 @@ Core Options 核心选项 + + Override underlying DNS + 覆盖底层 DNS + + + It is recommended to leave it blank, but it sometimes does not work, at this time you can set this option. +For NekoRay, this rewrites the underlying(localhost) DNS in VPN mode. +For NekoBox, this rewrites the underlying(localhost) DNS in VPN mode, normal mode, and also URL Test. + 建议留空,但有时会出现问题,这时可以设置这个选项。 +对于 NekoRay 来说,在 VPN 模式下会重写 underlying(localhost) DNS。 +对于 NekoBox 来说,在 VPN 模式、正常模式和 URL 测试中会重写 underlying(localhost) DNS。 + DialogEditGroup diff --git a/ui/dialog_basic_settings.cpp b/ui/dialog_basic_settings.cpp index 27f8fbf..ee79e87 100644 --- a/ui/dialog_basic_settings.cpp +++ b/ui/dialog_basic_settings.cpp @@ -167,8 +167,6 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent) // Core - if (!IS_NEKO_BOX) ui->core_settings->hide(); - ui->groupBox_core->setTitle(software_core_name); ui->core_v2ray_asset->setText(NekoRay::dataStore->v2ray_asset_dir); // @@ -398,8 +396,21 @@ void DialogBasicSettings::on_core_settings_clicked() { auto line = -1; QCheckBox *core_box_auto_detect_interface; QCheckBox *core_box_enable_clash_api; - QLineEdit *core_box_clash_api; - QLineEdit *core_box_clash_api_secret; + MyLineEdit *core_box_clash_api; + MyLineEdit *core_box_clash_api_secret; + MyLineEdit *core_box_underlying_dns; + // + auto core_box_underlying_dns_l = new QLabel(tr("Override underlying DNS")); + core_box_underlying_dns_l->setToolTip(tr( + "It is recommended to leave it blank, but it sometimes does not work, at this time you can set this option.\n" + "For NekoRay, this rewrites the underlying(localhost) DNS in VPN mode.\n" + "For NekoBox, this rewrites the underlying(localhost) DNS in VPN mode, normal mode, and also URL Test.")); + core_box_underlying_dns = new MyLineEdit; + core_box_underlying_dns->setText(NekoRay::dataStore->core_box_underlying_dns); + core_box_underlying_dns->setMinimumWidth(300); + layout->addWidget(core_box_underlying_dns_l, ++line, 0); + layout->addWidget(core_box_underlying_dns, line, 1); + // if (IS_NEKO_BOX) { auto core_box_auto_detect_interface_l = new QLabel("auto_detect_interface"); core_box_auto_detect_interface = new QCheckBox; @@ -430,6 +441,7 @@ void DialogBasicSettings::on_core_settings_clicked() { box->setOrientation(Qt::Horizontal); box->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); connect(box, &QDialogButtonBox::accepted, w, [=] { + NekoRay::dataStore->core_box_underlying_dns = core_box_underlying_dns->text(); if (IS_NEKO_BOX) { NekoRay::dataStore->core_box_auto_detect_interface = core_box_auto_detect_interface->isChecked(); NekoRay::dataStore->core_box_clash_api = core_box_clash_api->text().toInt() * (core_box_enable_clash_api->isChecked() ? 1 : -1); @@ -441,6 +453,7 @@ void DialogBasicSettings::on_core_settings_clicked() { connect(box, &QDialogButtonBox::rejected, w, &QDialog::reject); layout->addWidget(box, ++line, 1); // + ADD_ASTERISK(w) w->exec(); w->deleteLater(); refresh_auth();