is-domain-alive.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { createDomainAliveChecker, createRegisterableDomainAliveChecker } from 'domain-alive';
  2. import { $$fetch } from './fetch-retry';
  3. const dnsServers = [
  4. '8.8.8.8', '8.8.4.4',
  5. '1.0.0.1', '1.1.1.1',
  6. '162.159.36.1', '162.159.46.1',
  7. 'dns.cloudflare.com', // Cloudflare DoH that uses different IPs: 172.64.41.8,162.159.61.8
  8. 'cloudflare-dns.com', // Cloudflare DoH that uses different IPs: 104.16.249.249,104.16.248.249
  9. 'mozilla.cloudflare-dns.com', // Cloudflare DoH that uses different IPs: 162.159.61.4,172.64.41.4
  10. // one.one.one.one // Cloudflare DoH that uses 1.1.1.1 and 1.0.0.1
  11. // '101.101.101.101', 'dns.twnic.tw' // TWNIC, has DNS pollution, e.g. t66y.com
  12. // 'dns.hinet.net' // HiNet DoH, has DNS pollution, e.g. t66y.com
  13. '185.222.222.222', '45.11.45.11', // DNS.SB
  14. // 'doh.dns.sb', // DNS.SB, Unicast PoPs w/ GeoDNS
  15. 'us-chi.doh.sb', // DNS.SB Chicago PoP
  16. 'us-nyc.doh.sb', // DNS.SB New York City PoP
  17. 'us-sjc.doh.sb', // DNS.SB San Jose PoP
  18. // 'doh.sb', // DNS.SB xTom Anycast IP
  19. // 'dns.sb', // DNS.SB use same xTom Anycast IP as doh.sb
  20. // 'dns10.quad9.net', // Quad9 unfiltered
  21. '9.9.9.10', '149.112.112.10', // Quad9 unfiltered
  22. 'doh.sandbox.opendns.com', // OpenDNS sandbox (unfiltered)
  23. 'unfiltered.adguard-dns.com', // AdGuard unfiltered
  24. // 'v.recipes', // Proxy Cloudflare, too many HTTP 503
  25. // '76.76.2.0', // ControlD unfiltered, path not /dns-query
  26. // '76.76.10.0', // ControlD unfiltered, path not /dns-query
  27. // 'dns.bebasid.com', // BebasID, path not /dns-query but /unfiltered
  28. // '193.110.81.0', // dns0.eu
  29. // '185.253.5.0', // dns0.eu
  30. // 'zero.dns0.eu',
  31. 'dns.nextdns.io',
  32. 'anycast.dns.nextdns.io',
  33. 'wikimedia-dns.org',
  34. // 'ordns.he.net',
  35. // 'dns.mullvad.net', empty HTTP body a lot
  36. 'basic.rethinkdns.com',
  37. 'dns.surfsharkdns.com',
  38. // 'private.canadianshield.cira.ca', enforce HTTP/2
  39. // 'unfiltered.joindns4.eu', // too many ECONNRESET on GitHub Actions
  40. 'public.dns.iij.jp',
  41. // 'common.dot.dns.yandex.net', // too many ECONNRESET on GitHub Actions
  42. 'safeservedns.com' // NameCheap DNS, supports DoT, DoH, UDP53
  43. // 'ada.openbld.net',
  44. // 'dns.rabbitdns.org'
  45. ].map(dns => 'https://' + dns + '/dns-query');
  46. const resultCache = new Map();
  47. const registerableDomainResultCache = new Map();
  48. export async function getMethods() {
  49. const customWhoisServersMapping = await (await ($$fetch('https://cdn.jsdelivr.net/npm/whois-servers-list@latest/list.json'))).json() as any;
  50. const isRegisterableDomainAlive = createRegisterableDomainAliveChecker({
  51. dns: {
  52. dnsServers,
  53. maxAttempts: 6
  54. },
  55. registerableDomainResultCache,
  56. whois: {
  57. customWhoisServersMapping
  58. }
  59. });
  60. const isDomainAlive = createDomainAliveChecker({
  61. dns: {
  62. dnsServers,
  63. maxAttempts: 6
  64. },
  65. registerableDomainResultCache,
  66. resultCache,
  67. whois: {
  68. customWhoisServersMapping
  69. }
  70. });
  71. return { isRegisterableDomainAlive, isDomainAlive };
  72. };