Show More
@@ -116,6 +116,17 b' class BaseVCSController(object):' | |||||
116 |
|
116 | |||
117 | return True |
|
117 | return True | |
118 |
|
118 | |||
|
119 | def _get_ip_addr(self, environ): | |||
|
120 | proxy_key = 'HTTP_X_REAL_IP' | |||
|
121 | proxy_key2 = 'HTTP_X_FORWARDED_FOR' | |||
|
122 | def_key = 'REMOTE_ADDR' | |||
|
123 | ||||
|
124 | return environ.get(proxy_key2, | |||
|
125 | environ.get(proxy_key, | |||
|
126 | environ.get(def_key, '0.0.0.0') | |||
|
127 | ) | |||
|
128 | ) | |||
|
129 | ||||
119 | def __call__(self, environ, start_response): |
|
130 | def __call__(self, environ, start_response): | |
120 | start = time.time() |
|
131 | start = time.time() | |
121 | try: |
|
132 | try: |
@@ -99,9 +99,7 b' class SimpleGit(BaseVCSController):' | |||||
99 | if not is_git(environ): |
|
99 | if not is_git(environ): | |
100 | return self.application(environ, start_response) |
|
100 | return self.application(environ, start_response) | |
101 |
|
101 | |||
102 | proxy_key = 'HTTP_X_REAL_IP' |
|
102 | ipaddr = self._get_ip_addr(environ) | |
103 | def_key = 'REMOTE_ADDR' |
|
|||
104 | ipaddr = environ.get(proxy_key, environ.get(def_key, '0.0.0.0')) |
|
|||
105 | username = None |
|
103 | username = None | |
106 | # skip passing error to error controller |
|
104 | # skip passing error to error controller | |
107 | environ['pylons.status_code_redirect'] = True |
|
105 | environ['pylons.status_code_redirect'] = True |
@@ -69,9 +69,7 b' class SimpleHg(BaseVCSController):' | |||||
69 | if not is_mercurial(environ): |
|
69 | if not is_mercurial(environ): | |
70 | return self.application(environ, start_response) |
|
70 | return self.application(environ, start_response) | |
71 |
|
71 | |||
72 | proxy_key = 'HTTP_X_REAL_IP' |
|
72 | ipaddr = self._get_ip_addr(environ) | |
73 | def_key = 'REMOTE_ADDR' |
|
|||
74 | ipaddr = environ.get(proxy_key, environ.get(def_key, '0.0.0.0')) |
|
|||
75 |
|
73 | |||
76 | # skip passing error to error controller |
|
74 | # skip passing error to error controller | |
77 | environ['pylons.status_code_redirect'] = True |
|
75 | environ['pylons.status_code_redirect'] = True |
General Comments 0
You need to be logged in to leave comments.
Login now