Module: Rack::NeverLocal::RemoveLocalHost
- Defined in:
- lib/rack/neverlocal/remove_local_host.rb
Class Method Summary collapse
Class Method Details
.detect_localhost(env) ⇒ Object
15 16 17 |
# File 'lib/rack/neverlocal/remove_local_host.rb', line 15 def detect_localhost(env) ['::1','127.0.0.1'].include? env['REMOTE_ADDR'] end |
.from(env) ⇒ Object
6 7 8 9 |
# File 'lib/rack/neverlocal/remove_local_host.rb', line 6 def from(env) detect_localhost(env) and (transform_from('HTTP_X_REAL_IP',env) or transform_from('HTTP_X_CLUSTER_CLIENT_IP',env)) env end |
.transform_from(key, env) ⇒ Object
11 12 13 |
# File 'lib/rack/neverlocal/remove_local_host.rb', line 11 def transform_from(key,env) env[key] and env['REMOTE_ADDR'] = env[key] end |