Last active
May 17, 2021 18:55
-
-
Save ldx/ab5d1a2cc6e0154a014bb486210cd051 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const dns = require('dns'); | |
const args = process.argv.slice(2) | |
const hostname = args[0] | |
fs.readFile('/etc/resolv.conf', (err, data) => { | |
if (err) { | |
console.dir(err); | |
} else { | |
console.log('resolv.conf:\n%s', data); | |
} | |
}); | |
dns.resolveAny(hostname, (err, addresses) => { | |
if (err) { | |
console.error(err); | |
} else { | |
addresses.forEach((value) => { | |
console.log('resolve %s: %s', hostname, value); | |
}) | |
} | |
}) | |
dns.lookup(hostname, {family: 4}, (err, addr, family) => { | |
if (err) { | |
console.error(err); | |
process.exit(1); | |
} | |
console.log('lookup %s: %s AF %d', hostname, addr, family); | |
process.exit(0); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment