Class: Rack::TorBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/tor_block.rb

Constant Summary collapse

DEFAULT_REDIRECT =

We’re sorry from Google

'https://sorry.google.com'

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ TorBlock



9
10
11
# File 'lib/rack/tor_block.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/rack/tor_block.rb', line 13

def call(env)
  req = Rack::Request.new(env)
  return [302, {'Content-Type' => 'text', 'Location' => DEFAULT_REDIRECT}, [] ] if Rack::IP.new(env['action_dispatch.remote_ip'] || req.ip).is_tor?
    
  #Normal processing
  @app.call(env)
end