Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 528 Bytes

log.md

File metadata and controls

23 lines (17 loc) · 528 Bytes

Log all connections from Tor

This method is framework agnostic (it will work with hapi, Express, Koa, Restify, ...):

// `server` is the Node.js http Server

server.on('request', (req) => {
    
    const ipAddr = req.connection.remoteAddress;
        TorTest.isTor(ipAddr, (err, isTor) => {
    
            if (err) { 
                console.error(err);
                return ;
             }
            if (isTor) {
                console.log(`Tor connection from ${ipAddr}`);
            }
        });
});