vpn working
This commit is contained in:
parent
d603a1aabb
commit
cbf0720493
@ -4,7 +4,7 @@ const router = express.Router()
|
||||
const { fromTor, fromVpn, checkCountry } = require('./utils')
|
||||
|
||||
// magic
|
||||
const render = template => (req, res) => res.render(template)
|
||||
const render = (template, data) => (req, res) => res.render(template, data)
|
||||
|
||||
router.get('/', render('index'))
|
||||
|
||||
@ -19,9 +19,15 @@ router.get('/metadata', render('metadata'))
|
||||
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 )
|
||||
router.get('/vpn', fromTor, fromVpn, checkCountry, (req, res, next) => {
|
||||
console.log('son qui dentro');
|
||||
if (!req.fromTor && req.fromVpn) {
|
||||
res.render('vpnok', req.geoinfo);
|
||||
} else {
|
||||
res.render('vpnnook', req.geoinfo);
|
||||
}
|
||||
// console.log('sono qui dentro?!?!');
|
||||
// render('torok')
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
@ -36,13 +36,14 @@ const fromVpn = async (req, res, next) => {
|
||||
}
|
||||
|
||||
const checkCountry = (req, res, next) => {
|
||||
const sourceIp = req.headers['x-forwarded-for'] || req.connection.remoteAddress
|
||||
request(`http://ip-api.com/json/${sourceIp}`, (err, res, body) => {
|
||||
if (!err && res.statusCode === 200) {
|
||||
console.log(body);
|
||||
req.geoinfo = JSON.parse(body);
|
||||
console.log(res.geoinfo);
|
||||
console.log(req.geoinfo);
|
||||
}
|
||||
next();
|
||||
next()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,6 @@ extends layout
|
||||
|
||||
block content
|
||||
p.
|
||||
E no, arrivi da una {{country}} / {{city}}
|
||||
E no, arrivi da #{country} - #{city}
|
||||
|
||||
|
||||
|
@ -2,6 +2,6 @@ extends layout
|
||||
|
||||
block content
|
||||
p.
|
||||
Evviva, arrivi da una VPN {{country}} / {{city}}
|
||||
Evviva, arrivi da una VPN in #{country}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user