0.0
No release in over 3 years
Low commit activity in last 3 years
Mark Tor users using rack, for filtering / throttling / etc
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Build Status Gem Version Scrutinizer Code Quality security Code Climate Test Coverage Dependency Status

rack-tor-tag

A rack middleware to tag accesses to your rails application from TOR nodes.

Based on [https://github.com/Gild/rack-tor-block]

Install

Gemfile:

gem 'rack-tor-tag'

config/appplication.rb:

config.middleware.insert_after ActionDispatch::RemoteIp, Rack::TorTag
# or set config params
config.middleware.insert_after ActionDispatch::RemoteIp, Rack::TorTag, :host_ips => %w(1.2.3.4 1.2.3.5), :dnsel => 'my-dnsel-instance.myhost.org', :hostport => '123'

By default, :host_ips will be gotten by DNS lookup on HTTP_HOST, so if you know your IPs it's more efficient to specify. :host_port should probably be left blank, in which case it'll be gotten from SERVER_PORT.

:dnsel is if you're running your own instance of the Tor DNS Exit List software.

Use

Tor users will all have env['action_dispatch.remote_ip'] = '127.0.0.2'. The actual source IP is at env['tor_ip'] — though practically all Tor IPs should probably be treated the same, since there's no easy way to know whether two different Tor exit node IPs represent the same originating user or not.

env['tor'] will be true for Tor users, false for non-Tor users, and nil if the lookup failed.

Todo

[ ] Get the bulk list rather than doing DNS lookups [ ] Cache results [ ] Local-cache dns lookups

Contributing

  • Fork
  • Open an issue
  • Commit, push, Pull Req
  • Check the status of the existing tests / add new tests