Changeset - 64371c42e2f1
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2013-03-07 12:20:03
marcin@python-works.com
handle all cases with proxy IP addresses, not only for X_FORWARDED_FOR
1 file changed with 8 insertions and 6 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/base.py
Show inline comments
 
@@ -43,15 +43,17 @@ def _get_ip_addr(environ):
 

	
 
    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
 

	
 

	
0 comments (0 inline, 0 general)