mirror of
https://github.com/Lissy93/web-check.git
synced 2026-05-12 21:00:38 -04:00
- Sitemap endpoint now recursively expands sitemap-index files - Fixes #165 - Strips :port from target URLs in get-ip, dns, dns-server, ports, mail-config - Fixes #203 - Configurable trust proxy (TRUST_PROXY env) so app works behind Traefik/nginx - Fixes #157 - Tranco rank now correctly says "top 1 million" (was "100 million") - Fixes #257 - Adds engines.node ">=20" so Vercel picks a supported runtime - Re #212 - Raises Vercel maxDuration from 10s to 60s, cutting most 504 timeouts - Re #251 - Re #287 - Bumps axios 1.4.8 to 1.16, closing 4 high-severity SSRF/DoS CVEs - Re #289 - Fixes mail-config crash where dns module was awaited as if promise-based - Adds reusable structured logging util for the API - Bumps a whole bunch of deps, and resolves lots of open npm CVEs
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
import { promises as dnsPromises } from 'dns';
|
|
import axios from 'axios';
|
|
import middleware from './_common/middleware.js';
|
|
import { parseTarget } from './_common/parse-target.js';
|
|
|
|
const dnsHandler = async (url) => {
|
|
try {
|
|
const { hostname: domain } = parseTarget(url);
|
|
const addresses = await dnsPromises.resolve4(domain);
|
|
const results = await Promise.all(addresses.map(async (address) => {
|
|
const hostname = await dnsPromises.reverse(address).catch(() => null);
|
|
let dohDirectSupports = false;
|
|
try {
|
|
await axios.get(`https://${address}/dns-query`);
|
|
dohDirectSupports = true;
|
|
} catch (error) {
|
|
dohDirectSupports = false;
|
|
}
|
|
return {
|
|
address,
|
|
hostname,
|
|
dohDirectSupports,
|
|
};
|
|
}));
|
|
|
|
return { domain, dns: results };
|
|
} catch (error) {
|
|
throw new Error(`An error occurred while resolving DNS. ${error.message}`); // This will be caught and handled by the commonMiddleware
|
|
}
|
|
};
|
|
|
|
|
|
export const handler = middleware(dnsHandler);
|
|
export default handler;
|
|
|