use HTTP_X_FORWARDED_FOR as ip of set
This commit is contained in:
parent
8ceae868b1
commit
7c6757f417
1 changed files with 4 additions and 1 deletions
|
@ -106,6 +106,9 @@ class SessionData(models.Model):
|
|||
data, created = cls.objects.get_or_create(session_key=session_key)
|
||||
if request.user.is_authenticated():
|
||||
data.user = request.user
|
||||
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:'):]
|
||||
|
|
Loading…
Reference in a new issue