update dns options

This commit is contained in:
arm64v8a
2023-04-14 18:58:49 +09:00
parent 77ee9e369c
commit 4620d8aca2
8 changed files with 52 additions and 11 deletions

View File

@@ -8,6 +8,8 @@
#include <QFile>
#include <QFileInfo>
#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();

View File

@@ -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

View File

@@ -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;

View File

@@ -6,7 +6,11 @@
<h3>
<p>Please put your clash dashboard files to "nekoray/config/dashboard" dir.</p>
<p>For example, you can download from the following URL.</p>
<a href="https://github.com/MetaCubeX/Yacd-meta/archive/refs/heads/gh-pages.zip">Yacd-meta</a>
<p>
<a href="https://github.com/MetaCubeX/Yacd-meta/archive/refs/heads/gh-pages.zip">Download Yacd-meta</a>
or
<a href="http://yacd.metacubex.one/">Use online</a>
</p>
</h3>
</body>

View File

@@ -3,7 +3,7 @@
"servers": [
{
"tag": "dns-direct",
"address": "underlying://0.0.0.0",
"address": "%DNS_ADDRESS%",
"detour": "direct"
}
]

View File

@@ -237,6 +237,16 @@
<source>Core Options</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Override underlying DNS</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>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.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DialogEditGroup</name>

View File

@@ -231,6 +231,18 @@
<source>Core Options</source>
<translation></translation>
</message>
<message>
<source>Override underlying DNS</source>
<translation> DNS</translation>
</message>
<message>
<source>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.</source>
<translation>
NekoRay VPN underlying(localhost) DNS
NekoBox VPN URL underlying(localhost) DNS</translation>
</message>
</context>
<context>
<name>DialogEditGroup</name>

View File

@@ -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();