Skip to content

Instantly share code, notes, and snippets.

@mariohmol
Created June 26, 2019 21:20
Show Gist options
  • Save mariohmol/b8a523401277fb91c9a16c6ca1f456b1 to your computer and use it in GitHub Desktop.
Save mariohmol/b8a523401277fb91c9a16c6ca1f456b1 to your computer and use it in GitHub Desktop.
node whois example
var whois = require('node-whois')
var sys = require('sys')
var exec = require('child_process').exec;
require('dotenv').config();
const dns = require('dns');
const apiKey = process.env.nodeWhoisApiKey || "123456";
let protection=0;
const maxProtection=200;
var express = require('express')
var app = express()
app.get('/', function (req, res) {
if(req.query.apikey!=apiKey) return res.sendStatus(403);
protection++;
if(protection>maxProtection) return res.sendStatus(404);
let domain = req.query.domain;
let count=0;
let returned = {};
whois.lookup(domain, function(err, data) {
returned.whois = data;
dns.lookup(domain, { family: 4 }, (error, ip, family) => {
if (error) {
return res.sendStatus(404);
}
returned.ip=ip;
return res.json(returned);
});
});
});
app.listen(3001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment