is-domain-alive.ts 2.5 KB

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