somratpro commited on
Commit
4b00189
·
1 Parent(s): fe4dc91

fix: update DoH provider to cloudflare-dns.com and improve error logging/bypass logic

Browse files
Files changed (1) hide show
  1. dns-fix.js +5 -2
dns-fix.js CHANGED
@@ -25,7 +25,7 @@ function dohResolve(hostname, callback) {
25
  return callback(null, cached.ip);
26
  }
27
 
28
- const url = `https://1.1.1.1/dns-query?name=${encodeURIComponent(hostname)}&type=A`;
29
  const req = https.get(
30
  url,
31
  { headers: { Accept: "application/dns-json" }, timeout: 15000 },
@@ -78,7 +78,8 @@ dns.lookup = function patchedLookup(hostname, options, callback) {
78
  hostname === "127.0.0.1" ||
79
  hostname === "::1" ||
80
  /^\d+\.\d+\.\d+\.\d+$/.test(hostname) ||
81
- /^::/.test(hostname)
 
82
  ) {
83
  return origLookup.call(dns, hostname, options, callback);
84
  }
@@ -92,6 +93,8 @@ dns.lookup = function patchedLookup(hostname, options, callback) {
92
  return callback(null, ip, 4);
93
  }
94
 
 
 
95
  // 2) Fall back to system DNS if DoH fails
96
  origLookup.call(dns, hostname, options, callback);
97
  });
 
25
  return callback(null, cached.ip);
26
  }
27
 
28
+ const url = `https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(hostname)}&type=A`;
29
  const req = https.get(
30
  url,
31
  { headers: { Accept: "application/dns-json" }, timeout: 15000 },
 
78
  hostname === "127.0.0.1" ||
79
  hostname === "::1" ||
80
  /^\d+\.\d+\.\d+\.\d+$/.test(hostname) ||
81
+ /^::/.test(hostname) ||
82
+ hostname === "cloudflare-dns.com"
83
  ) {
84
  return origLookup.call(dns, hostname, options, callback);
85
  }
 
93
  return callback(null, ip, 4);
94
  }
95
 
96
+ console.error(`[DNS-FIX] DoH failed for ${hostname}:`, dohErr ? dohErr.message : "no IP returned");
97
+
98
  // 2) Fall back to system DNS if DoH fails
99
  origLookup.call(dns, hostname, options, callback);
100
  });