is-domain-alive.ts 2.6 KB

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