use request.remote_ip to get the client address

This method has the proxy smarts to check x-forwarded-for and client-ip,
and some level of ip spoofing protection.

Change-Id: I19d7768cdbc1d25deceed4a157467d7eb83b4cc8
Reviewed-on: https://gerrit.instructure.com/4516
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Brian Palmer 2011-06-30 17:31:36 -06:00
parent d1cc53be3c
commit f0f9e2c160
1 changed files with 5 additions and 3 deletions

View File

@ -124,10 +124,12 @@ class ErrorReport < ActiveRecord::Base
end
def self.useful_http_env_stuff_from_request(request)
request.env.slice( *["HTTP_ACCEPT", "HTTP_ACCEPT_ENCODING", "HTTP_COOKIE", "HTTP_HOST", "HTTP_REFERER",
"HTTP_USER_AGENT", "PATH_INFO", "QUERY_STRING", "REMOTE_ADDR", "REMOTE_HOST",
"REQUEST_METHOD", "REQUEST_PATH", "REQUEST_URI", "SERVER_NAME", "SERVER_PORT",
stuff = request.env.slice( *["HTTP_ACCEPT", "HTTP_ACCEPT_ENCODING", "HTTP_COOKIE", "HTTP_HOST", "HTTP_REFERER",
"HTTP_USER_AGENT", "PATH_INFO", "QUERY_STRING", "REMOTE_HOST",
"REQUEST_METHOD", "REQUEST_PATH", "REQUEST_URI", "SERVER_NAME", "SERVER_PORT",
"SERVER_PROTOCOL", "action_controller.request.path_parameters"] )
stuff['REMOTE_ADDR'] = request.remote_ip # ActionController::Request#remote_ip has proxy smarts
stuff
end
on_send_to_external do |error_report|