diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/bin/www b/bin/www index 40e4f78..724eb03 100755 --- a/bin/www +++ b/bin/www @@ -12,7 +12,7 @@ var http = require('http'); * Get port from environment and store in Express. */ -var port = normalizePort(process.env.PORT || '3000'); +var port = normalizePort(process.env.PORT || '8000'); app.set('port', port); /** @@ -25,7 +25,7 @@ var server = http.createServer(app); * Listen on provided port, on all network interfaces. */ -server.listen(port); +server.listen(port, '0.0.0.0'); server.on('error', onError); server.on('listening', onListening); diff --git a/routes/index.js b/routes/index.js index 97ccd16..2aeb732 100644 --- a/routes/index.js +++ b/routes/index.js @@ -3,8 +3,6 @@ var router = express.Router(); /* GET home page. */ router.get('/', (req, res) => res.render('index')); -router.get('/tor', (req, res) => { - -}); +router.use('/tor', require('./tor')); module.exports = router; diff --git a/routes/tor.js b/routes/tor.js new file mode 100644 index 0000000..134bbbb --- /dev/null +++ b/routes/tor.js @@ -0,0 +1,29 @@ +var express = require('express'); +var router = express.Router(); +const dns = require('dns').promises; + +function isExitNode (ip) { + ip = ip.split('.').reverse().join('.'); + const domain = ip + '.8080.235.126.68.51.ip-port.exitlist.torproject.org' + console.log(domain); + return dns.lookup(domain, {}).then(ret => { + if (ret.address === '127.0.0.2') return true; + return false; + }).catch( e => false ) +} + + +router.get('/', (req, res) => { + const source_ip = req.connection.remoteAddress; + console.log(' son qui, ', req.url); + isExitNode(source_ip).then( isExit => { + if (isExit) { + res.render('torok'); + } else { + res.render('tornook'); + } + }); +}); + + +module.exports = router; diff --git a/views/index.pug b/views/index.pug index 538cbb0..03962b5 100644 --- a/views/index.pug +++ b/views/index.pug @@ -3,4 +3,4 @@ extends layout block content p Dai, bisogna che ti sbrighi, ti stanno tracciando... devi visitare questo sito anonimamente: - a(href="http://51.68.126.235:3000/tor") daje! + a(href="http://51.68.126.235:8000/tor") daje! diff --git a/views/tornook.pug b/views/tornook.pug new file mode 100644 index 0000000..6e1eb1a --- /dev/null +++ b/views/tornook.pug @@ -0,0 +1,4 @@ +extends layout + +block content + p No amico, riprova... diff --git a/views/torok.pug b/views/torok.pug new file mode 100644 index 0000000..47812a5 --- /dev/null +++ b/views/torok.pug @@ -0,0 +1,4 @@ +extends layout + +block content + p Ecco, ottimo... purtroppo non e' finita :)