Skip to content

Commit

Permalink
Revised Xray Fake DNS.
Browse files Browse the repository at this point in the history
  • Loading branch information
bia-pain-bache committed Oct 24, 2024
1 parent edbbc7c commit f850039
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
17 changes: 4 additions & 13 deletions _worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 7 additions & 14 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3202,7 +3202,7 @@ async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, is
{ rule: bypassRussia, domain: "geosite:category-ru", ip: "geoip:ru" }
];

const hostsRules = [
const blockRules = [
{ rule: blockAds, host: "geosite:category-ads-all", address: ["127.0.0.1"] },
{ rule: blockAds, host: "geosite:category-ads-ir", address: ["127.0.0.1"] },
{ rule: blockPorn, host: "geosite:category-porn", address: ["127.0.0.1"] }
Expand All @@ -3223,7 +3223,7 @@ async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, is
: [remoteDNS];

const dnsHost = {};
isBlock && hostsRules.forEach( ({ rule, host, address}) => {
isBlock && blockRules.forEach( ({ rule, host, address}) => {
if (rule) dnsHost[host] = address;
});

Expand Down Expand Up @@ -3271,18 +3271,11 @@ async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, is
dnsObject.servers.push(localDNSServer);
}

if (isFakeDNS) {
if ((isBypass || isOutboundRule) && !isWorkerLess) {
dnsObject.servers.unshift({
address: "fakedns",
domains: [
...localDNSServer.domains,
...outboundRules
]
});
} else {
dnsObject.servers.unshift("fakedns");
}
if (isFakeDNS) {
const fakeDNSServer = isBypass && !isWorkerLess
? { address: "fakedns", domains: localDNSServer.domains }
: "fakedns";
dnsObject.servers.unshift(fakeDNSServer);
}

return dnsObject;
Expand Down

0 comments on commit f850039

Please sign in to comment.