Class: Rack::Cloudflare::Middleware::AccessControl
- Inherits:
-
Object
- Object
- Rack::Cloudflare::Middleware::AccessControl
- Defined in:
- lib/rack/cloudflare/middleware/access_control.rb
Class Attribute Summary collapse
-
.blocked_message ⇒ Object
Returns the value of attribute blocked_message.
-
.blocked_response ⇒ Object
Returns the value of attribute blocked_response.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ AccessControl
constructor
A new instance of AccessControl.
Constructor Details
#initialize(app) ⇒ AccessControl
Returns a new instance of AccessControl.
16 17 18 |
# File 'lib/rack/cloudflare/middleware/access_control.rb', line 16 def initialize(app) @app = app end |
Class Attribute Details
.blocked_message ⇒ Object
Returns the value of attribute blocked_message.
8 9 10 |
# File 'lib/rack/cloudflare/middleware/access_control.rb', line 8 def @blocked_message end |
.blocked_response ⇒ Object
Returns the value of attribute blocked_response.
8 9 10 |
# File 'lib/rack/cloudflare/middleware/access_control.rb', line 8 def blocked_response @blocked_response end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rack/cloudflare/middleware/access_control.rb', line 20 def call(env) headers = Headers.new(env) if headers.trusted? Cloudflare.info "[#{self.class.name}] Trusted Network (REMOTE_ADDR): #{headers.target_headers}" @app.call(env) else Cloudflare.warn "[#{self.class.name}] Untrusted Network (REMOTE_ADDR): #{headers.target_headers}" AccessControl.blocked_response.call(env) end end |