Sha256: cef33267e24febc2d0ed6c11becc9c39c6a87c586da54eeb58a202b25ebd0fc8

Contents?: true

Size: 563 Bytes

Versions: 1

Compression:

Stored size: 563 Bytes

Contents

# inspired by hoptoad_notifier
# http://charlesmaxwood.com/sessions-in-rack-and-rails-metal/
module Honeypot
  # Middleware for Rack applications. Remote hosts will be tied together with remote requests.
  class Rack
    def initialize(app)
      @app = app
    end

    def call(env)
      if session = env['rack.session'] and raw_remote_ip = env['action_dispatch.remote_ip']
        remote_ip = IPAddr.new raw_remote_ip.to_s 
        session['honeypot.last_known_remote_ip'] = remote_ip.to_s if remote_ip.public?
      end
      @app.call env
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
honeypot-0.0.5 lib/honeypot/rack.rb