Nodejs tool to check if a request comes from Tor
npm install tor-testThis module checks whether a specific ip address is a Tor exit node. In other words tor-test lets you know if a connection
to your Node.js application is coming from the Tor network.
``sh`
$ npm i -S tor-testpackage.json
This will install the module and save it in your as dependency.
`js
const TorTest = require('tor-test');
TorTest.isTor('127.0.0.1', (err, isTor) => {
// isTor is false
});
`
This methods feeds the cache of the module with a list of Tor exit nodes.
It takes 1 parameter:
* callback: a function which signature is function (err) where err is an Error or null.
`js
const TorTest = require('tor-test');
TorTest.fetch((err) => ...)
`
This method is used to check if an IP address is a Tor exit node.
If fetch has not been called before, it will be called at the first call of isTor.addr
It takes 3 arguments:
* : a string representing the IP address to testforce
* : a boolean, optional, if present and set to true, it will force a reload of the cached Tor exit node list.callback
* : a function which signature is function (err, result) where:err
* is an Error or nullresult
* is a boolean. It will equal true is addr` is the address of a Tor exit node
A cookbook is available for this module:
* Log all connections from Tor (framework agnostic)
* Update the exit nodes list daily
* Express: exclude Tor users
* hapi: exclude Tor users