Skip to content

Instantly share code, notes, and snippets.

@hubgit
Last active July 26, 2018 13:06
Show Gist options
  • Save hubgit/8b1fcf335e7edd23b05b1a3c21b65075 to your computer and use it in GitHub Desktop.
Save hubgit/8b1fcf335e7edd23b05b1a3c21b65075 to your computer and use it in GitHub Desktop.
const dns = require('dns')
const tlds = require('tlds')
dns.setServers([
'80.82.77.83',
//'8.8.8.8',
])
const getAddresses = tld => new Promise((resolve, reject) => {
const domain = 'sci-hub.' + tld
dns.resolve(domain, (err, addresses) => {
if (err) {
reject(err)
} else {
console.log(domain, addresses)
resolve(domain)
}
})
})
const promises = tlds.map(getAddresses)
Promise.all(promises.map(p => p.catch(() => undefined))).then(results => {
console.log(results.filter(i => i))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment