Use system resolvers for DNSBL, minor improvements on /ip/

parent ac0d5e40
......@@ -346,13 +346,18 @@ enum DataReturnFormat {
export { DataReturnFormat };
import dns from "dns";
/**
* Resolvers to use for DNSBL lookup
* Use system resolvers for DNSBL
*
* Related: https://github.com/silverwind/dnsbl/issues/9
*/
const dnsblConfiguration = {
servers: ["10.250.11.51"],
servers: dns.getServers(),
};
export { dnsblConfiguration };
const dnsblConfigurationWithTxt = {...dnsblConfiguration, includeTxt: true};
export { dnsblConfiguration, dnsblConfigurationWithTxt };
......@@ -4,7 +4,7 @@ import { promises as dnsPromises } from "dns";
import axios from "axios";
import compressIp from "../functions/compressIp";
import dnsbl from "dnsbl";
import { dnsblConfiguration } from "../app";
import { dnsblConfiguration, dnsblConfigurationWithTxt } from "../app";
import removeBrackets from "../view-functions/removeBrackets";
const router: Router = Router();
......@@ -59,21 +59,31 @@ router.get("/:ip", (req: Request, res: Response, next: NextFunction) => {
description += `is an IPv${ipVersion} address.`;
// description += ` owned by ${ispName} and located in ${placeName} (see map)`;
interface DnsblIncludeTxt {
listed: Boolean,
txt: string[],
}
const defaultDnsblTxt = {
listed: false,
txt: [],
}
/**
* Bogons
*/
interface BogonData {
traditional: Boolean,
full: Boolean,
full: DnsblIncludeTxt,
}
let bogon: BogonData = {
traditional: false,
full: false,
full: defaultDnsblTxt,
};
bogon.traditional = await dnsbl.lookup(ipAddress, 'bogons.cymru.com', dnsblConfiguration);
bogon.full = await dnsbl.lookup(ipAddress, `v${ipVersion}.fullbogons.cymru.com`, dnsblConfiguration);
bogon.full = await dnsbl.lookup(ipAddress, `v${ipVersion}.fullbogons.cymru.com`, dnsblConfigurationWithTxt);
/**
* Tor relay data
......@@ -81,17 +91,21 @@ router.get("/:ip", (req: Request, res: Response, next: NextFunction) => {
interface TorRelayData {
isRelay: Boolean,
isExit: Boolean,
fingerprint: string | undefined,
fingerprints: string | undefined,
}
let torRelay: TorRelayData = {
isRelay: false,
isExit: false,
fingerprint: undefined,
fingerprints: undefined,
}
torRelay.isRelay = await dnsbl.lookup(ipAddress, 'tor.dan.me.uk', dnsblConfiguration);
torRelay.isExit = await dnsbl.lookup(ipAddress, 'torexit.dan.me.uk', dnsblConfiguration);
torRelay.isExit = await dnsbl.lookup(ipAddress, 'torexit.dan.me.uk', dnsblConfiguration);
if(torRelay.isRelay) {
// torRelay.fingerprints = await getRelayFingerprints(ipAddress);
}
res.render("ip/show.twig", {
// "title": `${ipAddress} - ${reverse} - ${country} - ${isp} - IP address geolocation`,
......
......@@ -40,6 +40,10 @@
</th>
<td>
{{ bogon.traditional }}
{# {{ bogon.traditional.listed }}
{% if bogon.traditional.txt %}
(<a href="/net/{{ bogon.traditional.txt }}">{{ bogon.traditional.txt }}</a>)
{% endif %} #}
</td>
</tr>
......@@ -48,7 +52,10 @@
<a href="https://www.team-cymru.com/bogon-reference.html">Fullbogon</a>
</th>
<td>
{{ bogon.full }}
{{ bogon.full.listed }}
{% if bogon.full.txt %}
(<a href="/net/{{ bogon.full.txt }}">{{ bogon.full.txt }}</a>)
{% endif %}
</td>
</tr>
......@@ -63,6 +70,9 @@
{% else %}
Non-exit
{% endif %}
{# {% for relay in torRelay.isRelay.txt %}
{{ relay.toString() | split("/F:")[0] }}--END<br />
{% endfor %} #}
{% else %}
false
{% endif %}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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