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,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']
|
||||
|
|
Loading…
Reference in a new issue