0.0
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
Rack middleware for detecting Tor exits
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Rack::DetectTor

Rack middleware for detecting Tor exits.

Rack::DetectTor determines whether a user is connecting via a Tor exit relay. It adds an environment variable tor_exit_user to the request.env object with a value of true or false.

Usage

Add the gem to your Gemfile:

gem 'rack-detect-tor'

and add it to your middleware stack. In config.ru:

require 'rack-detect-tor'

use Rack::DetectTor, 'external_ip' => [ip],
                     'external_port' => [port],
                     'update_frequency' => 3600

It is recommended to provide external_ip and external_port (see below). update_frequency is how often Rack::DetectTor will update its list of Tor exits. It defaults to one hour (3600 seconds).

Note on external_ip and external_port

You are not required to provide these. However:

It's important to provide the external_ip and external_port values, corresponding with the external IP and port of your web server. Many Tor relays are configured not to allow connections on port 80/443/etc. If you don't provide or are unable to provide the external IP of your web server, the value added to request.env['tor_exit_user'] will tell you only that the IP corresponds with A Tor exit, not necessarily one that is configured to relay connections to your website.

License

MIT license. See LICENSE.

Author

Warren Guy warren@guy.net.au

https://warrenguy.me