changeset 3494:ef21dadcaa7c

handle all cases with proxy IP addresses, not only for X_FORWARDED_FOR
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 07 Mar 2013 12:20:03 +0100
parents 994dfdd0c920
children f674bc937d8a
files rhodecode/lib/base.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/base.py	Wed Mar 06 15:04:09 2013 +0100
+++ b/rhodecode/lib/base.py	Thu Mar 07 12:20:03 2013 +0100
@@ -43,15 +43,17 @@
 
     ip = environ.get(proxy_key2)
     if ip:
-        # HTTP_X_FORWARDED_FOR can have mutliple ips inside
-        # the left-most being the original client, and each successive proxy
-        # that passed the request adding the IP address where it received the
-        # request from.
-        if ',' in ip:
-            ip = ip.split(',')[0].strip()
         return ip
 
     ip = environ.get(def_key, '0.0.0.0')
+
+    # HEADERS can have mutliple ips inside
+    # the left-most being the original client, and each successive proxy
+    # that passed the request adding the IP address where it received the
+    # request from.
+    if ',' in ip:
+        ip = ip.split(',')[0].strip()
+
     return ip