index.js 882 B

12345678910111213141516171819202122232425262728293031323334
  1. const express = require('express')
  2. const router = express.Router()
  3. const { fromTor, fromVpn, checkCountry } = require('./utils')
  4. // magic
  5. const render = (template, data) => (req, res) => res.render(template, data)
  6. router.get('/', render('index'))
  7. // level I (tor -> read metadata)
  8. router.get('/subito', fromTor,
  9. (req, res) => res.render(req.fromTor ? 'torok' : 'tornook') )
  10. // level II (read metadata -> mail)
  11. router.get('/metadata', render('metadata'))
  12. // level IV (mail -> vpn)
  13. router.get('/mail', render('mail'))
  14. router.get('/password', render('password'))
  15. router.get('/fingerprint', render('fingerprint'))
  16. // level V (vpn -> read mail)
  17. router.get('/vpn', fromTor, fromVpn, checkCountry, (req, res, next) => {
  18. if (!req.fromTor && req.fromVpn) {
  19. res.render('vpnok', req.geoinfo);
  20. } else {
  21. res.render('vpnnook', req.geoinfo);
  22. }
  23. })
  24. module.exports = router