fix: nekobox domain rule translate

This commit is contained in:
arm64v8a
2023-01-08 17:14:15 +09:00
parent 75ea572a0b
commit 10d7d9437a

View File

@@ -193,27 +193,7 @@ namespace NekoRay {
{"tag", "block"}, {"tag", "block"},
}; };
// block for tun // DNS Routing
if (!status->forTest) {
status->routingRules += QJsonObject{
{"type", "field"},
{
"ip",
QJsonArray{
"224.0.0.0/3",
"169.254.0.0/16",
},
},
{"outboundTag", "block"},
};
status->routingRules += QJsonObject{
{"type", "field"},
{"port", "135-139"},
{"outboundTag", "block"},
};
}
// DNS Routing (tun2socks 用到,防污染)
if (dataStore->dns_routing && !status->forTest) { if (dataStore->dns_routing && !status->forTest) {
QJsonObject dnsOut; QJsonObject dnsOut;
dnsOut["protocol"] = "dns"; dnsOut["protocol"] = "dns";
@@ -234,11 +214,6 @@ namespace NekoRay {
{"inboundTag", QJsonArray{"socks-in", "http-in"}}, {"inboundTag", QJsonArray{"socks-in", "http-in"}},
{"outboundTag", "dns-out"}, {"outboundTag", "dns-out"},
}; };
// status->routingRules += QJsonObject{
// {"type", "field"},
// {"inboundTag", QJsonArray{"dns-in"}},
// {"outboundTag", "dns-out"},
// };
} }
// custom inbound // custom inbound
@@ -700,8 +675,8 @@ namespace NekoRay {
// //
QJsonArray domain_keyword; QJsonArray domain_keyword;
QJsonArray domain_subdomain; QJsonArray domain_subdomain;
QJsonArray domain_regexp;
QJsonArray domain_full; QJsonArray domain_full;
QJsonArray domain_suffix;
QJsonArray geosite; QJsonArray geosite;
for (auto item: list) { for (auto item: list) {
if (isIP) { if (isIP) {
@@ -711,14 +686,19 @@ namespace NekoRay {
ip_cidr += item; ip_cidr += item;
} }
} else { } else {
// https://www.v2fly.org/config/dns.html#dnsobject
if (item.startsWith("geosite:")) { if (item.startsWith("geosite:")) {
geosite += item.replace("geosite:", ""); geosite += item.replace("geosite:", "");
} else if (item.startsWith("full:")) { } else if (item.startsWith("full:")) {
domain_full += item.replace("full:", ""); domain_full += item.replace("full:", "");
} else if (item.startsWith("domain:")) { } else if (item.startsWith("domain:")) {
domain_suffix += item.replace("domain:", ""); domain_subdomain += item.replace("domain:", "");
} else if (item.startsWith("regexp:")) {
domain_regexp += item.replace("regexp:", "");
} else if (item.startsWith("keyword:")) {
domain_keyword += item.replace("keyword:", "");
} else { } else {
domain_keyword += item; domain_full += item;
} }
} }
} }
@@ -727,12 +707,13 @@ namespace NekoRay {
rule["ip_cidr"] = ip_cidr; rule["ip_cidr"] = ip_cidr;
rule["geoip"] = geoip; rule["geoip"] = geoip;
} else { } else {
if (domain_keyword.isEmpty() && domain_subdomain.isEmpty() && domain_full.isEmpty() && geosite.isEmpty()) { if (domain_keyword.isEmpty() && domain_subdomain.isEmpty() && domain_regexp.isEmpty() && domain_full.isEmpty() && geosite.isEmpty()) {
return rule; return rule;
} }
rule["domain"] = domain_full; rule["domain"] = domain_full;
rule["domain_suffix"] = domain_suffix; rule["domain_suffix"] = domain_subdomain; // v2ray Subdomain => sing-box suffix
rule["domain_keyword"] = domain_keyword; rule["domain_keyword"] = domain_keyword;
rule["domain_regex"] = domain_regexp;
rule["geosite"] = geosite; rule["geosite"] = geosite;
} }
return rule; return rule;