Handle ports in X Forwarded For (#4539)

humitos/vcs/show-links
David Fischer 2018-08-18 14:16:09 -07:00 committed by Anthony
parent 43c07a9b1c
commit 70181a3799
1 changed files with 1 additions and 1 deletions

View File

@ -26,7 +26,7 @@ def get_client_ip(request):
# Get the original IP address (eg. "X-Forwarded-For: client, proxy1, proxy2") # Get the original IP address (eg. "X-Forwarded-For: client, proxy1, proxy2")
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR', '').split(',')[0] x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR', '').split(',')[0]
if x_forwarded_for: if x_forwarded_for:
ip_address = x_forwarded_for ip_address = x_forwarded_for.rsplit(':')[0]
return ip_address return ip_address