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
|
2018-08-11 01:08:00 +02:00
|
|
|
const render = (template, data) => (req, res) => res.render(template, data)
|
2018-08-10 00:22:02 +02:00
|
|
|
|
|
|
|
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-11 01:08:00 +02:00
|
|
|
router.get('/vpn', fromTor, fromVpn, checkCountry, (req, res, next) => {
|
|
|
|
if (!req.fromTor && req.fromVpn) {
|
|
|
|
res.render('vpnok', req.geoinfo);
|
|
|
|
} else {
|
|
|
|
res.render('vpnnook', req.geoinfo);
|
|
|
|
}
|
2018-08-10 23:14:56 +02:00
|
|
|
})
|
|
|
|
|
2018-08-11 01:26:31 +02:00
|
|
|
router.get('/password', render('password'))
|
|
|
|
|
2018-08-10 00:22:02 +02:00
|
|
|
module.exports = router
|