Skip to content

Instantly share code, notes, and snippets.

@Yuhtin
Last active January 25, 2021 19:53
Show Gist options
  • Save Yuhtin/94b5b621c90e0b2b1bbe3cf9b9cbae81 to your computer and use it in GitHub Desktop.
Save Yuhtin/94b5b621c90e0b2b1bbe3cf9b9cbae81 to your computer and use it in GitHub Desktop.
Resolve DNS
const dns = require('dns');
const axios = require('axios');
const api = axios.create({ baseURL: 'http://ip-api.com' });
const dnsIp = 'netflix.com',
resetColor = '',
bold = '',
backgroundColor = '',
pinkColor = '',
cyanColor = '',
prefix = resetColor + '[' + cyanColor + '+' + resetColor + '] ' + cyanColor + bold + backgroundColor;
dns.lookup(dnsIp, (error, address, arguments) => {
if (error) throw error;
console.log(pinkColor +
'██████╗ ███╗ ██╗███████╗ ██████╗ ███████╗███████╗ ██████╗ ██╗ ██╗ ██╗███████╗██████╗ \n' +
'██╔══██╗████╗ ██║██╔════╝ ██╔══██╗██╔════╝██╔════╝██╔═══██╗██║ ██║ ██║██╔════╝██╔══██╗ \n' +
'██║ ██║██╔██╗ ██║███████╗ ██████╔╝█████╗ ███████╗██║ ██║██║ ██║ ██║█████╗ ██████╔╝ \n' +
'██║ ██║██║╚██╗██║╚════██║ ██╔══██╗██╔══╝ ╚════██║██║ ██║██║ ╚██╗ ██╔╝██╔══╝ ██╔══██╗ \n' +
'██████╔╝██║ ╚████║███████║ ██║ ██║███████╗███████║╚██████╔╝███████╗╚████╔╝ ███████╗██║ ██║ \n' +
'╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝ ╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝')
console.log(cyanColor + '\n'
+ ' Coded by Yuhtin \n'
+ ' Version 1.0-SNAPSHOT \n\n'
+ resetColor);
console.log('[' + cyanColor + '>' + resetColor + ']' + cyanColor + ' Hostname -> ' + resetColor + dnsIp + '\n');
dnsResolve(address);
});
async function dnsResolve(address) {
var map = new Array();
var response = await api.get(`/json/${address}`);
var data = response.data;
map["country"] = data.country,
map["countryCode"] = data.countryCode,
map["region"] = data.region,
map["regionName"] = data.regionName,
map["city"] = data.city,
map["zip"] = data.zip,
map["latitude"] = data.latitude,
map["longitude"] = data.longitude,
map["timezone"] = data.timezone,
map["ipReverse"] = undefined,
dns.reverse(address, (error, hostname) => {
if (error) return;
hostname.forEach(host => { map["ipReverse"] = host; });
});
await new Promise(resolve => setTimeout(resolve, 2000));
for (var key in map) {
const value = map[key];
if (value == undefined) continue;
console.log(prefix + key + ':' + resetColor + ' ' + resetColor + value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment