Commit dbaaa45a authored by Martin's avatar Martin
Browse files

added filter for proxy forwarding

parent 77a57c43
No related merge requests found
Showing with 8 additions and 1 deletion
+8 -1
......@@ -8,12 +8,19 @@ from collections import OrderedDict
import json
import settings
def get_ip(request):
"""
gets an ip address, based on a request.
Filters for reverse proxies
"""
return request.remote_addr
# taken from http://stackoverflow.com/a/22936947
route = request.access_route + [request.remote_addr]
return next((addr for addr in reversed(route)
if addr not in settings.TRUSTED_PROXIES), request.remote_addr)
def guess_format(request):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment