28 lines
740 B
JavaScript
28 lines
740 B
JavaScript
const express = require('express')
|
|
const router = express.Router()
|
|
|
|
const { fromTor, fromVpn, checkCountry } = require('./utils')
|
|
|
|
// magic
|
|
const render = template => (req, res) => res.render(template)
|
|
|
|
router.get('/', render('index'))
|
|
|
|
// level I (tor -> read metadata)
|
|
router.get('/subito', fromTor,
|
|
(req, res) => res.render(req.fromTor ? 'torok' : 'tornook') )
|
|
|
|
// level II (read metadata -> mail)
|
|
router.get('/metadata', render('metadata'))
|
|
|
|
// level IV (mail -> vpn)
|
|
router.get('/mail', render('mail'))
|
|
|
|
// level V (vpn -> read mail)
|
|
router.get('/vpn', fromTor, fromVpn, checkCountry, (req, res) => {
|
|
if (!req.fromTor && req.fromVpn) render('vpnok', req.geoinfo )
|
|
else render('vpnnook', req.geoinfo )
|
|
})
|
|
|
|
module.exports = router
|