Show More
@@ -37,13 +37,18 def _get_ip_addr(environ): | |||||
37 | proxy_key2 = 'HTTP_X_FORWARDED_FOR' |
|
37 | proxy_key2 = 'HTTP_X_FORWARDED_FOR' | |
38 | def_key = 'REMOTE_ADDR' |
|
38 | def_key = 'REMOTE_ADDR' | |
39 |
|
39 | |||
40 |
ip = environ.get(proxy_key |
|
40 | ip = environ.get(proxy_key) | |
41 | if ip: |
|
41 | if ip: | |
42 | return ip |
|
42 | return ip | |
43 |
|
43 | |||
44 | ip = environ.get(proxy_key) |
|
44 | ip = environ.get(proxy_key2) | |
45 |
|
||||
46 | if ip: |
|
45 | if ip: | |
|
46 | # HTTP_X_FORWARDED_FOR can have mutliple ips inside | |||
|
47 | # the left-most being the original client, and each successive proxy | |||
|
48 | # that passed the request adding the IP address where it received the | |||
|
49 | # request from. | |||
|
50 | if ',' in ip: | |||
|
51 | ip = ip.split(',')[0].strip() | |||
47 | return ip |
|
52 | return ip | |
48 |
|
53 | |||
49 | ip = environ.get(def_key, '0.0.0.0') |
|
54 | ip = environ.get(def_key, '0.0.0.0') |
General Comments 0
You need to be logged in to leave comments.
Login now