WIP Tor relay page

parent 8cc09498
......@@ -60,8 +60,8 @@ router.get("/asn/:pageNumber([0-9][0-9]?[0-9]?)", (req: Request, res: Response,
request("https://api.asrank.caida.org/v2/graphql/", query)
.then(data => {
console.log(data.asns.pageInfo);
console.log(data.asns.edges[0]);
// console.log(data.asns.pageInfo);
// console.log(data.asns.edges[0]);
const pageCount = roundUp(parseInt(data.asns.totalCount) / pageSize, 0);
......
......@@ -19,4 +19,29 @@ router.get("/", (req: Request, res: Response, next: NextFunction) => {
.catch(next);
});
/**
* Data about a specific Tor relay
*/
router.get("/:fingerprint/", (req: Request, res: Response, next: NextFunction) => {
const fingerprint = req.params.fingerprint;
Promise.all([
Axios.get(`https://onionoo.torproject.org/details?lookup=${fingerprint}`)
.then(x => x.data)
.then(data => data["relays"][0])
])
.then(x => {
const relayData = x[0];
res.render("tor-relay/show.twig", {
"canonical_url": `/tor-relay/${fingerprint}`,
"title": `Tor relay - ${relayData["nickname"]}`,
"description": `${relayData["nickname"]} is a Tor relay hosted on ${relayData["as"]} ${relayData["as_name"]}.`,
"data": relayData,
"json_data": JSON.stringify(relayData, null, 2),
});
})
.catch(next);
});
export const TorController: Router = router;
{% extends 'layouts/default.twig' %}
{% block body %}
<h1>{{ title|e }}</h1>
<pre><code>{{ json_data }}</code></pre>
{% endblock %}
\ No newline at end of file
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