Fix domains starting with underscores (such as _spf.google.com)

parent 42258e9a
import { NextFunction, Request, Response, Router } from "express";
import isDomainName from "is-domain-name";
import domainNameRegex from "domain-name-regex";
import axios from "axios";
import getIpInfo from "../functions/getIpInfo";
import isIp from "is-ip";
......@@ -16,7 +16,7 @@ function catcher(x) {
router.get("/:domain", (req: Request, res: Response, next: NextFunction) => {
if(isIp(req.params.domain)) {
res.redirect(301, `/ip/${req.params.domain}`);
} else if(isDomainName(req.params.domain)) {
} else if(domainNameRegex.test(req.params.domain)) {
axios.get(`https://api.telcodb.net/v1/resolve?format=json&q=${req.params.domain}`)
.then((response) => {
Promise.all([
......
import { NextFunction, Request, Response, Router } from "express";
import isIp from "is-ip";
import isDomainName from "is-domain-name";
import domainNameRegex from "domain-name-regex";
import isAsn from "is-asn";
import isCidr from "is-cidr";
......@@ -19,7 +19,7 @@ router.get("/", (req: Request, res: Response, next: NextFunction) => {
res.redirect(`/${query}`);
} else if(isCidr(query)) {
res.redirect(`/net/${query}`);
} else if(isDomainName(query)) {
} else if(domainNameRegex.test(query)) {
res.redirect(`/dns/${query}`);
} else {
res.send("Query: " + query);
......
import { NextFunction, Request, Response, Router } from "express";
import isDomainName from "is-domain-name";
import domainNameRegex from "domain-name-regex";
import axios from "axios";
import isIp from "is-ip";
......@@ -18,7 +18,7 @@ router.get("/dnsleak", (req: Request, res: Response, next: NextFunction) => {
router.get("/dns", (req: Request, res: Response, next: NextFunction) => {
const domain = req.query.q;
if(domain && isDomainName(domain)) {
if(domain && domainNameRegex.test(domain)) {
res.redirect(`/dns/${domain}`)
} else {
const message = domain ? "Invalid domain": null;
......@@ -117,7 +117,7 @@ router.get("/traceroute", (req: Request, res: Response, next: NextFunction) => {
router.get("/certinfo", (req: Request, res: Response, next: NextFunction) => {
const domain = req.query.domain;
if(domain && isDomainName(domain)) {
if(domain && domainNameRegex.test(domain)) {
axios.get(`https://api.telcodb.net/v1/certinfo?format=raw&q=${domain}`)
.then((response) => {
res.render("tools/certinfo.twig", {
......
......@@ -1519,6 +1519,11 @@ diff@^4.0.1:
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.1.tgz#0c667cb467ebbb5cea7f14f135cc2dba7780a8ff"
integrity sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==
domain-name-regex@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/domain-name-regex/-/domain-name-regex-2.0.0.tgz#c3004aedd24d4f2a0b230d89ed010e2e7aec1535"
integrity sha512-GuXngTKjlld+e2o+Ku1cKRKY9NfLzN5djyxtA7Jw3+NUZB1KTQn1N8DtNOkO2F5D5jhyYypjd9WBE1LKzhVHmg==
dot-prop@^4.1.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57"
......@@ -2108,11 +2113,6 @@ is-descriptor@^1.0.0, is-descriptor@^1.0.2:
is-data-descriptor "^1.0.0"
kind-of "^6.0.2"
is-domain-name@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-domain-name/-/is-domain-name-1.0.1.tgz#f6eb33b14a497541dca58335137d4466e0c20da1"
integrity sha1-9uszsUpJdUHcpYM1E31EZuDCDaE=
is-extendable@^0.1.0, is-extendable@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
......
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