fugadalcontrollo/routes/index.js

28 lines
740 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:53:41 +02:00
const { fromTor, fromVpn, checkCountry } = 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)
2018-08-10 23:53:41 +02:00
router.get('/vpn', fromTor, fromVpn, checkCountry, (req, res) => {
if (!req.fromTor && req.fromVpn) render('vpnok', req.geoinfo )
else render('vpnnook', req.geoinfo )
2018-08-10 23:14:56 +02:00
})
2018-08-10 00:22:02 +02:00
module.exports = router