fugadalcontrollo/routes/index.js

28 lines
680 B
JavaScript
Raw Normal View History

2018-08-10 00:22:02 +02:00
const express = require('express')
const router = express.Router()
2018-07-21 00:55:00 +02:00
2018-08-10 23:14:56 +02:00
const { fromTor, fromVpn } = require('./utils')
2018-07-21 00:55:00 +02:00
2018-08-10 00:22:02 +02:00
// magic
const render = template => (req, res) => res.render(template)
router.get('/', render('index'))
2018-08-10 23:14:56 +02:00
// level I (tor -> read metadata)
2018-08-10 00:22:02 +02:00
router.get('/subito', fromTor,
2018-08-10 23:14:56 +02:00
(req, res) => res.render(req.fromTor ? 'torok' : 'tornook') )
2018-08-10 00:22:02 +02:00
2018-08-10 23:14:56 +02:00
// level II (read metadata -> mail)
2018-08-10 00:22:02 +02:00
router.get('/metadata', render('metadata'))
2018-08-10 23:14:56 +02:00
// level IV (mail -> vpn)
router.get('/mail', render('mail'))
// level V (vpn -> read mail)
router.get('/vpn', fromTor, fromVpn, (req, res) => {
if (!req.isTor && req.isVpn) render('vpnok')
else render('vpnnook')
})
2018-08-10 00:22:02 +02:00
module.exports = router