Skip to content

Commit

Permalink
Revised Warp DNS.
Browse files Browse the repository at this point in the history
  • Loading branch information
bia-pain-bache committed Oct 17, 2024
1 parent c4474df commit eeb0772
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
17 changes: 7 additions & 10 deletions _worker.js

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

27 changes: 15 additions & 12 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3289,19 +3289,21 @@ async function buildXrayDNS (proxySettings, outboundAddrs, domainToStaticIPs, is
const outboundDomains = outboundAddrs.filter(address => isDomain(address));
const isOutboundRule = outboundDomains.length > 0;
const outboundRules = outboundDomains.map(domain => `full:${domain}`);
const finalRemoteDNS = isWarp ? '1.1.1.1' : isWorkerLess ? 'https://cloudflare-dns.com/dns-query' : remoteDNS;
const staticIPs = domainToStaticIPs ? await resolveDNS(domainToStaticIPs) : undefined;

const finalRemoteDNS = isWarp
? ['1.1.1.1', '1.0.0.1', '2606:4700:4700::1111', '2606:4700:4700::1001']
: isWorkerLess
? ['https://cloudflare-dns.com/dns-query']
: [remoteDNS];

let dnsObject = {
hosts: {
"domain:googleapis.cn": ["googleapis.com"]
},
servers: [
finalRemoteDNS
],
servers: finalRemoteDNS,
tag: "dns",
};


const staticIPs = domainToStaticIPs ? await resolveDNS(domainToStaticIPs) : undefined;
if (staticIPs) dnsObject.hosts[domainToStaticIPs] = [...staticIPs.ipv4, ...staticIPs.ipv6];
if (resolvedRemoteDNS.server && !isWorkerLess && !isWarp) dnsObject.hosts[resolvedRemoteDNS.server] = resolvedRemoteDNS.staticIPs;
if (isWorkerLess) {
Expand Down Expand Up @@ -3766,9 +3768,10 @@ function buildXrayConfig (proxySettings, remark, isFragment, isBalancer, isChain
fragmentPackets
} = proxySettings;

const isFakeDNS = (vlessTrojanFakeDNS && !isWarp) || (warpFakeDNS && isWarp);
let config = structuredClone(xrayConfigTemp);
config.remarks = remark;
if (vlessTrojanFakeDNS || warpFakeDNS) {
if (isFakeDNS) {
config.inbounds[0].sniffing.destOverride.push("fakedns");
config.inbounds[1].sniffing.destOverride.push("fakedns");
} else {
Expand Down Expand Up @@ -4003,7 +4006,9 @@ async function buildClashDNS (proxySettings, isWarp) {
bypassRussia
} = proxySettings;

const finalRemoteDNS = isWarp ? '1.1.1.1' : remoteDNS;
const finalRemoteDNS = isWarp
? ['1.1.1.1', '1.0.0.1', '2606:4700:4700::1111', '2606:4700:4700::1001']
: [remoteDNS];
let clashLocalDNS = localDNS === 'localhost' ? 'system' : localDNS;
const isFakeDNS = (vlessTrojanFakeDNS && !isWarp) || (warpFakeDNS && isWarp);

Expand All @@ -4012,9 +4017,7 @@ async function buildClashDNS (proxySettings, isWarp) {
"listen": "0.0.0.0:1053",
"ipv6": true,
"respect-rules": true,
"nameserver": [
finalRemoteDNS
],
"nameserver": finalRemoteDNS,
"proxy-server-nameserver": [clashLocalDNS]
};

Expand Down

0 comments on commit eeb0772

Please sign in to comment.