mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
feat: dns query strategy
This commit is contained in:
@@ -247,6 +247,7 @@ namespace NekoRay {
|
||||
QJsonObject dnsServerRemote;
|
||||
dnsServerRemote["address"] = dataStore->fake_dns ? "fakedns" : dataStore->remote_dns;
|
||||
dnsServerRemote["domains"] = QList2QJsonArray<QString>(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<QString>(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"},
|
||||
};
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -560,6 +560,14 @@
|
||||
<source>Default Outbound</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Query Strategy</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remote</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DialogVPNSettings</name>
|
||||
|
||||
@@ -225,7 +225,7 @@
|
||||
</message>
|
||||
<message>
|
||||
<source>Maybe useful for HiDPI screens.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>可能对 HiDPI 屏幕有用。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Skip TLS certificate authentication by default (allowInsecure)</source>
|
||||
@@ -566,6 +566,14 @@
|
||||
<source>Default Outbound</source>
|
||||
<translation>默认出站</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Query Strategy</source>
|
||||
<translation>DNS 查询策略</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Remote</source>
|
||||
<translation>远程</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DialogVPNSettings</name>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -54,4 +54,6 @@ public slots:
|
||||
void SetRouteConfig(const NekoRay::Routing &conf);
|
||||
|
||||
void on_load_save_clicked();
|
||||
|
||||
void on_queryStrategy_clicked();
|
||||
};
|
||||
|
||||
@@ -132,6 +132,13 @@
|
||||
<item>
|
||||
<widget class="QLineEdit" name="dns_direct"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="queryStrategy">
|
||||
<property name="text">
|
||||
<string>Query Strategy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user