add tor level

This commit is contained in:
Gogs 2018-07-21 01:14:47 +02:00
parent 8ce2fd5e84
commit eea6575607
7 changed files with 42 additions and 6 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules/

View file

@ -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);

View file

@ -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;

29
routes/tor.js Normal file
View file

@ -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;

View file

@ -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!

4
views/tornook.pug Normal file
View file

@ -0,0 +1,4 @@
extends layout
block content
p No amico, riprova...

4
views/torok.pug Normal file
View file

@ -0,0 +1,4 @@
extends layout
block content
p Ecco, ottimo... purtroppo non e' finita :)