is-domain-alive.ts 2.3 KB

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