List of TLDs

parent 2456a76f
......@@ -36,6 +36,7 @@
"ip-cidr": "^2.0.6",
"is-asn": "^1.0.1",
"is-cidr": "^3.1.0",
"is-domain-name": "^1.0.1",
"is-ip": "^3.1.0",
"jquery": "^3.4.1",
"lusca": "^1.6.1",
......
......@@ -29,6 +29,7 @@ import {
IxController,
NetController,
ExploreController,
TldController,
} from "./controllers";
twig.extendFunction("getenv", (name: string) => {
......@@ -188,6 +189,9 @@ app.use("/ix/", IxController);
// DNS names
app.use("/dns/", DnsController);
// TLDs
app.use("/tld/", TldController);
const badgeData = [
/* ASN data badges */
{
......
import { NextFunction, Request, Response, Router } from "express";
import domainNameRegex from "domain-name-regex";
import isDomainName from "is-domain-name";
import axios from "axios";
import getIpInfo from "../functions/getIpInfo";
import isIp from "is-ip";
......@@ -16,7 +17,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(domainNameRegex.test(req.params.domain)) {
} else if(domainNameRegex.test(req.params.domain) || isDomainName(req.params.domain)) {
axios.get(`https://api.telcodb.net/v1/resolve?format=json&q=${req.params.domain}`)
.then((response) => {
Promise.all([
......
......@@ -8,3 +8,4 @@ export * from "./country.controller";
export * from "./ix.controller";
export * from "./net.controller";
export * from "./explore.controller";
export * from "./tld.controller";
import { NextFunction, Request, Response, Router } from "express";
import axios from "axios";
import isDomainName from "is-domain-name";
const router: Router = Router();
/**
* List
*/
router.get("/", (req: Request, res: Response, next: NextFunction) => {
axios.get("https://gitlab.lelux.fi/TelcoDB/tld-json/raw/master/data/tld-list.json")
.then(x => x.data)
.then(data => {
res.render("tld/list.twig", {
"canonical_url": "/tld/",
"title": "List of TLDs",
"description": "List of Top Level Domains, assigned by ICANN",
"domains": data,
});
})
});
router.get("/:tld", (req: Request, res: Response, next: NextFunction) => {
const tld = req.params.tld;
if(isDomainName(tld)) {
axios.get(`https://api.telcodb.net/v1/resolve?format=json&q=${tld}`)
.then(x => x.data)
.then(data => data.ns)
.then(nameservers => {
if(nameservers === undefined) {
next();
return;
}
res.render("tld/show.twig", {
"canonical_url": `/tld/${tld}`,
"title": `Information about .${tld}`,
"tld": tld,
"nameservers": nameservers,
});
})
.catch(next);
} else {
next();
}
})
export const TldController: Router = router;
......@@ -16,6 +16,7 @@
<div class="dropdown-menu">
<a class="dropdown-item" href="/explore/asn">ASN List</a>
{# <a class="dropdown-item" href="/explore/ip">Browse IPs</a> #}
<a class="dropdown-item" href="/tld/">Top Level Domains</a>
</div>
</li>
<li class="nav-item dropdown">
......
......@@ -5,15 +5,29 @@
<p>TelcoDB is a website for Internet research.</p>
<a name="data-sources"></a><h3>Data sources</h3>
<a name="data-sources"></a><h2>Data sources</h2>
<p>We use the following data sources:
<h3>ASN data</h3>
<ul>
<li><a href="https://asrank.caida.org/">CAIDA ASRank</a></li>
<li><a href="https://peeringdb.com/">PeeringDB</a></li>
<li><a href="https://www.team-cymru.com/IP-ASN-mapping.html">Cymru IP-to-ASN mapping</a></li>
</ul></p>
</ul>
<h3>Domain name data</h3>
<ul>
<li><a href="https://publicsuffix.org/list/">Public Suffix List</a></li>
<li><a href="/docs/dns-hsts-preloading/">Chromium HSTS preload list</a></li>
</ul>
<h3>Tor Relay data</h3>
<ul>
<li><a href="https://www.dan.me.uk/dnsbl">Tor Relay List by dan.me.uk</a></li>
</ul>
</p>
<a name="contact"></a><h3>Contact</h3>
......
{% extends 'layouts/default.twig' %}
{% block body %}
<h1>{{ title }}</h1>
<p>The list of domains is provided by the <a href="https://publicsuffix.org/list/">Public Suffix List</a>.</p>
<ul>
{% for domain in domains %}
{% if '.' in domain %}
{# <li><a href="/tld/{{ domain}}">{{ domain }}</a></li></li> #}
{% else %}
<li>
<a href="/tld/{{ domain }}">
{{ domain }}
</a>
{% if domain|length == 2 %}
({{ countryCode(domain) }})
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'layouts/default.twig' %}
{% block body %}
<h1>{{ title }}</h1>
<h2>Nameservers</h2>
<ul class="pl-3">
{% for server in nameservers %}
<li><a href="/dns/{{ server }}">{{ server }}</a></li>
{% endfor %}
</ul>
<p>More detailed DNS data can be found from <a href="/dns/{{ tld }}">here</a>.</p>
{% endblock %}
\ No newline at end of file
......@@ -2113,6 +2113,11 @@ 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