From 7c6757f4176efc6626b62021ab1c96322b2856a6 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 30 Aug 2013 10:38:45 +0200 Subject: [PATCH] use HTTP_X_FORWARDED_FOR as ip of set --- pandora/user/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora/user/models.py b/pandora/user/models.py index a0a7b7b6..ea809830 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -106,7 +106,10 @@ class SessionData(models.Model): data, created = cls.objects.get_or_create(session_key=session_key) if request.user.is_authenticated(): data.user = request.user - data.ip = request.META['REMOTE_ADDR'] + if 'HTTP_X_FORWARDED_FOR' in request.META: + data.ip = request.META['HTTP_X_FORWARDED_FOR'] + else: + data.ip = request.META['REMOTE_ADDR'] if data.ip.startswith('::ffff:'): data.ip = data.ip[len('::ffff:'):] data.useragent = request.META['HTTP_USER_AGENT']