Skip to content

Commit

Permalink
update domain strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Mar 25, 2023
1 parent 69771e2 commit 180a764
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 83 deletions.
20 changes: 5 additions & 15 deletions db/ConfigBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,21 +568,8 @@ namespace NekoRay {
status->result->outboundStats += ent->traffic_data;

if (IS_NEKO_BOX) {
auto ds = dataStore->outbound_domain_strategy;
if (status->forTest) {
ds = "";
} else if (ds == "UseIPv4") {
ds = "ipv4_only";
} else if (ds == "UseIPv6") {
ds = "ipv6_only";
} else if (ds == "PreferIPv4") {
ds = "prefer_ipv4";
} else if (ds == "PreferIPv6") {
ds = "prefer_ipv6";
} else {
ds = "";
}
outbound["domain_strategy"] = ds;
// apply domain_strategy
outbound["domain_strategy"] = dataStore->outbound_domain_strategy;
// TODO apply mux
} else {
if (!status->forTest) outbound["domainStrategy"] = dataStore->outbound_domain_strategy;
Expand Down Expand Up @@ -655,6 +642,9 @@ namespace NekoRay {
},
};
}
// apply domain_strategy
inboundObj["domain_strategy"] = dataStore->outbound_domain_strategy;
//
status->inbounds += inboundObj;
}

Expand Down
5 changes: 3 additions & 2 deletions fmt/Preset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ namespace Preset {

namespace SingBox {
inline QStringList VpnImplementation = {"gvisor", "system"};
}
inline QStringList DomainStrategy = {"", "ipv4_only", "ipv6_only", "prefer_ipv4", "prefer_ipv6"};
} // namespace SingBox

namespace Windows {
inline QStringList system_proxy_format{"{ip}:{http_port}",
"socks={ip}:{socks_port}",
"http={ip}:{http_port};https={ip}:{http_port};ftp={ip}:{http_port};socks={ip}:{socks_port}",
"http=http://{ip}:{http_port};https=http://{ip}:{http_port}"};
}
} // namespace Windows
} // namespace Preset
10 changes: 5 additions & 5 deletions translations/fa_IR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,6 @@
<source>The sniffing result is used for destination</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Outbound Domain Strategy</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remote DNS</source>
<translation type="unfinished"></translation>
Expand All @@ -477,7 +473,7 @@
<translation>فعال کردن مسیریابی DNS</translation>
</message>
<message>
<source>Domain Strategy</source>
<source>V2Ray Domain Strategy</source>
<translation>استراتژی دامنه</translation>
</message>
<message>
Expand Down Expand Up @@ -568,6 +564,10 @@
<source>Remote</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inbound &amp; Outbound Domain Strategy</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DialogVPNSettings</name>
Expand Down
34 changes: 5 additions & 29 deletions translations/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@
<source>Use proxy when updating subscription</source>
<translation>更新订阅时使用代理</translation>
</message>
<message>
<source>Language</source>
<translation type="vanished">语言</translation>
</message>
<message>
<source>Security</source>
<translation>安全</translation>
Expand Down Expand Up @@ -442,10 +438,6 @@
<source>Routes</source>
<translation>路由</translation>
</message>
<message>
<source>Outbound Domain Strategy</source>
<translation>出站域名策略</translation>
</message>
<message>
<source>Disable</source>
<translation>禁用</translation>
Expand All @@ -470,20 +462,12 @@
<source>Remote DNS</source>
<translation>远程 DNS</translation>
</message>
<message>
<source>Enhanced domain name resolution</source>
<translation type="vanished">增强域名解析</translation>
</message>
<message>
<source>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.</source>
<translation type="vanished">使用多个境外 DNS 查询服务器地址,一定程度上可缓解对服务器域名的 DNS 污染,可能有副作用。</translation>
</message>
<message>
<source>Enable DNS Routing</source>
<translation>启用 DNS 路由</translation>
</message>
<message>
<source>Domain Strategy</source>
<source>V2Ray Domain Strategy</source>
<translation>域名策略</translation>
</message>
<message>
Expand Down Expand Up @@ -574,6 +558,10 @@
<source>Remote</source>
<translation>远程</translation>
</message>
<message>
<source>Inbound &amp; Outbound Domain Strategy</source>
<translation>出入站域名策略</translation>
</message>
</context>
<context>
<name>DialogVPNSettings</name>
Expand Down Expand Up @@ -1077,14 +1065,6 @@ https://matsuridayo.github.io/n-configuration/#vpn-tun</translation>
<source>Destination</source>
<translation>目标地址</translation>
</message>
<message>
<source>End</source>
<translation type="vanished">结束</translation>
</message>
<message>
<source>Active</source>
<translation type="vanished">活动</translation>
</message>
<message>
<source>Start: %1
End: %2</source>
Expand Down Expand Up @@ -1308,10 +1288,6 @@ Split by line.</source>
</context>
<context>
<name>ProxyItem</name>
<message>
<source>Remove</source>
<translation type="vanished">删除</translation>
</message>
<message>
<source>Confirmation</source>
<translation>确认</translation>
Expand Down
3 changes: 3 additions & 0 deletions ui/dialog_manage_routes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "qv2ray/v2/ui/widgets/editors/w_JsonEditor.hpp"
#include "qv2ray/v3/components/GeositeReader/GeositeReader.hpp"
#include "main/GuiUtils.hpp"
#include "fmt/Preset.hpp"

#include <QFile>
#include <QMessageBox>
Expand Down Expand Up @@ -31,8 +32,10 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne

if (IS_NEKO_BOX) {
ui->domain_v2ray->setVisible(false);
ui->outbound_domain_strategy->addItems(Preset::SingBox::DomainStrategy);
} else {
ui->domain_v2ray->setVisible(true);
ui->outbound_domain_strategy->addItems({"AsIs", "UseIPv4", "UseIPv6", "PreferIPv4", "PreferIPv6"});
}
//
ui->sniffing_mode->setCurrentIndex(NekoRay::dataStore->sniffing_mode);
Expand Down
34 changes: 2 additions & 32 deletions ui/dialog_manage_routes.ui
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Outbound Domain Strategy</string>
<string>Inbound &amp; Outbound Domain Strategy</string>
</property>
</widget>
</item>
Expand All @@ -76,36 +76,6 @@
<property name="editable">
<bool>false</bool>
</property>
<item>
<property name="text">
<string notr="true">AsIs</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">UseIP</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">UseIPv4</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">UseIPv6</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">PreferIPv4</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">PreferIPv6</string>
</property>
</item>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -179,7 +149,7 @@
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Domain Strategy</string>
<string>V2Ray Domain Strategy</string>
</property>
</widget>
</item>
Expand Down
5 changes: 5 additions & 0 deletions ui/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "./ui_mainwindow.h"
#include "mainwindow.h"

#include "fmt/Preset.hpp"
#include "db/ProfileFilter.hpp"
#include "db/ConfigBuilder.hpp"
#include "sub/GroupUpdater.hpp"
Expand Down Expand Up @@ -92,9 +93,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
if (IS_NEKO_BOX) {
software_name = "NekoBox";
software_core_name = "sing-box";
// replace default values
if (NekoRay::dataStore->log_level == "warning") {
NekoRay::dataStore->log_level = "info";
}
if (!Preset::SingBox::DomainStrategy.contains(NekoRay::dataStore->outbound_domain_strategy)) {
NekoRay::dataStore->outbound_domain_strategy = "";
}
}

// top bar
Expand Down

0 comments on commit 180a764

Please sign in to comment.