Use custom resolver for DNSBL lookups

parent e135421e
......@@ -340,4 +340,15 @@ enum DataReturnFormat {
Jsonp = "jsonp",
}
export { DataReturnFormat };
\ No newline at end of file
export { DataReturnFormat };
/**
* Resolvers to use for DNSBL lookup
*
* Related: https://github.com/silverwind/dnsbl/issues/9
*/
const dnsblConfiguration = {
servers: ["10.250.11.51"],
};
export { dnsblConfiguration };
import { NextFunction, Request, Response, Router } from "express";
import isIp from "is-ip";
import { promises } from "dns";
import { promises as dnsPromises } from "dns";
import axios from "axios";
import compressIp from "../functions/compressIp";
import dnsbl from "dnsbl";
import { dnsblConfiguration } from "../app";
const router: Router = Router();
......@@ -24,7 +25,7 @@ router.get("/:ip", (req: Request, res: Response, next: NextFunction) => {
res.redirect(301, `/ip/${compressedIp}`);
} else {
Promise.all([
promises.reverse(ipAddress).catch(catcher),
dnsPromises.reverse(ipAddress).catch(catcher),
axios.get(`https://api.telcodb.net/v1/bgpann?format=json&q=${ipAddress}`).catch(catcher),
])
.then(async result => {
......@@ -70,8 +71,8 @@ router.get("/:ip", (req: Request, res: Response, next: NextFunction) => {
full: false,
};
bogon.traditional = await dnsbl.lookup(ipAddress, 'bogons.cymru.com');
bogon.full = await dnsbl.lookup(ipAddress, `v${ipVersion}.fullbogons.cymru.com`);
bogon.traditional = await dnsbl.lookup(ipAddress, 'bogons.cymru.com', dnsblConfiguration);
bogon.full = await dnsbl.lookup(ipAddress, `v${ipVersion}.fullbogons.cymru.com`, dnsblConfiguration);
/**
* Tor relay data
......@@ -88,8 +89,8 @@ router.get("/:ip", (req: Request, res: Response, next: NextFunction) => {
fingerprint: undefined,
}
torRelay.isRelay = await dnsbl.lookup(ipAddress, 'tor.dan.me.uk');
torRelay.isExit = await dnsbl.lookup(ipAddress, 'torexit.dan.me.uk');
torRelay.isRelay = await dnsbl.lookup(ipAddress, 'tor.dan.me.uk', dnsblConfiguration);
torRelay.isExit = await dnsbl.lookup(ipAddress, 'torexit.dan.me.uk', dnsblConfiguration);
res.render("ip/show.twig", {
// "title": `${ipAddress} - ${reverse} - ${country} - ${isp} - IP address geolocation`,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment