Skip to content

Latest commit

 

History

History
48 lines (31 loc) · 2.42 KB

README.md

File metadata and controls

48 lines (31 loc) · 2.42 KB

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