##// END OF EJS Templates
fixed multiple IP addresses in each of extracted IP....
marcink -
r3669:b66fd6de beta
parent child Browse files
Show More
@@ -32,6 +32,22 b' from rhodecode.model.meta import Session'
32 log = logging.getLogger(__name__)
32 log = logging.getLogger(__name__)
33
33
34
34
35 def _filter_proxy(ip):
36 """
37 HEADERS can have mutliple ips inside the left-most being the original
38 client, and each successive proxy that passed the request adding the IP
39 address where it received the request from.
40
41 :param ip:
42 """
43 if ',' in ip:
44 _ips = ip.split(',')
45 _first_ip = _ips[0].strip()
46 log.debug('Got multiple IPs %s, using %s' % (','.join(_ips), _first_ip))
47 return _first_ip
48 return ip
49
50
35 def _get_ip_addr(environ):
51 def _get_ip_addr(environ):
36 proxy_key = 'HTTP_X_REAL_IP'
52 proxy_key = 'HTTP_X_REAL_IP'
37 proxy_key2 = 'HTTP_X_FORWARDED_FOR'
53 proxy_key2 = 'HTTP_X_FORWARDED_FOR'
@@ -39,22 +55,14 b' def _get_ip_addr(environ):'
39
55
40 ip = environ.get(proxy_key)
56 ip = environ.get(proxy_key)
41 if ip:
57 if ip:
42 return ip
58 return _filter_proxy(ip)
43
59
44 ip = environ.get(proxy_key2)
60 ip = environ.get(proxy_key2)
45 if ip:
61 if ip:
46 return ip
62 return _filter_proxy(ip)
47
63
48 ip = environ.get(def_key, '0.0.0.0')
64 ip = environ.get(def_key, '0.0.0.0')
49
65 return _filter_proxy(ip)
50 # HEADERS can have mutliple ips inside
51 # the left-most being the original client, and each successive proxy
52 # that passed the request adding the IP address where it received the
53 # request from.
54 if ',' in ip:
55 ip = ip.split(',')[0].strip()
56
57 return ip
58
66
59
67
60 def _get_access_path(environ):
68 def _get_access_path(environ):
General Comments 0
You need to be logged in to leave comments. Login now