Changeset - ef21dadcaa7c
[Not reviewed]
default
0 1 0
Marcin Kuzminski - 13 years ago 2013-03-07 12:20:03
marcin@python-works.com
Grafted from: 64371c42e2f1
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
 
@@ -40,21 +40,23 @@ def _get_ip_addr(environ):
 
    ip = environ.get(proxy_key)
 
    if ip:
 
        return ip
 

	
 
    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
 

	
 

	
 
def _get_access_path(environ):
 
    path = environ.get('PATH_INFO')
 
    org_req = environ.get('pylons.original_request')
0 comments (0 inline, 0 general)