is-domain-alive.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. // one.one.one.one // Cloudflare DoH that uses 1.1.1.1 and 1.0.0.1
  10. // '101.101.101.101', // TWNIC, has DNS pollution, e.g. t66y.com
  11. '185.222.222.222', '45.11.45.11', // DNS.SB
  12. 'doh.dns.sb', // DNS.SB, Unicast PoPs w/ GeoDNS
  13. // 'doh.sb', // DNS.SB xTom Anycast IP
  14. // 'dns.sb', // DNS.SB use same xTom Anycast IP as doh.sb
  15. 'dns10.quad9.net', // Quad9 unfiltered
  16. 'doh.sandbox.opendns.com', // OpenDNS sandbox (unfiltered)
  17. 'unfiltered.adguard-dns.com',
  18. // 'v.recipes', // Proxy Cloudflare, too many HTTP 503
  19. // '76.76.2.0', // ControlD unfiltered, path not /dns-query
  20. // '76.76.10.0', // ControlD unfiltered, path not /dns-query
  21. // 'dns.bebasid.com', // BebasID, path not /dns-query but /unfiltered
  22. // '193.110.81.0', // dns0.eu
  23. // '185.253.5.0', // dns0.eu
  24. // 'zero.dns0.eu',
  25. 'dns.nextdns.io',
  26. 'anycast.dns.nextdns.io',
  27. 'wikimedia-dns.org',
  28. // 'ordns.he.net',
  29. // 'dns.mullvad.net', empty HTTP body a lot
  30. 'basic.rethinkdns.com',
  31. 'dns.surfsharkdns.com',
  32. 'private.canadianshield.cira.ca',
  33. // 'unfiltered.joindns4.eu', // too many ECONNRESET on GitHub Actions
  34. 'public.dns.iij.jp',
  35. // 'common.dot.dns.yandex.net', // too many ECONNRESET on GitHub Actions
  36. 'safeservedns.com' // NameCheap DNS, supports DoT, DoH, UDP53
  37. // 'ada.openbld.net',
  38. // 'dns.rabbitdns.org'
  39. ].map(dns => 'https://' + dns + '/dns-query');
  40. const resultCache = new Map();
  41. const registerableDomainResultCache = new Map();
  42. export async function getMethods() {
  43. const customWhoisServersMapping = await (await ($$fetch('https://cdn.jsdelivr.net/npm/whois-servers-list@latest/list.json'))).json() as any;
  44. const isRegisterableDomainAlive = createRegisterableDomainAliveChecker({
  45. dns: {
  46. dnsServers,
  47. maxAttempts: 6
  48. },
  49. registerableDomainResultCache,
  50. whois: {
  51. customWhoisServersMapping
  52. }
  53. });
  54. const isDomainAlive = createDomainAliveChecker({
  55. dns: {
  56. dnsServers,
  57. maxAttempts: 6
  58. },
  59. registerableDomainResultCache,
  60. resultCache,
  61. whois: {
  62. customWhoisServersMapping
  63. }
  64. });
  65. return { isRegisterableDomainAlive, isDomainAlive };
  66. };