##// END OF EJS Templates
add IP into base logging, and change a little IP extraction login, if some header is passed as empty
marcink -
r2486:6f537e3d beta
parent child Browse files
Show More
@@ -35,9 +35,17 b' def _get_ip_addr(environ):'
35 proxy_key2 = 'HTTP_X_FORWARDED_FOR'
35 proxy_key2 = 'HTTP_X_FORWARDED_FOR'
36 def_key = 'REMOTE_ADDR'
36 def_key = 'REMOTE_ADDR'
37
37
38 return environ.get(proxy_key2,
38 ip = environ.get(proxy_key2)
39 environ.get(proxy_key, environ.get(def_key, '0.0.0.0'))
39 if ip:
40 )
40 return ip
41
42 ip = environ.get(proxy_key)
43
44 if ip:
45 return ip
46
47 ip = environ.get(def_key, '0.0.0.0')
48 return ip
41
49
42
50
43 class BasicAuth(AuthBasicAuthenticator):
51 class BasicAuth(AuthBasicAuthenticator):
@@ -178,12 +186,13 b' class BaseController(WSGIController):'
178 self.rhodecode_user.set_authenticated(
186 self.rhodecode_user.set_authenticated(
179 cookie_store.get('is_authenticated')
187 cookie_store.get('is_authenticated')
180 )
188 )
181 log.info('User: %s accessed %s' % (
189 log.info('IP: %s User: %s accessed %s' % (
182 auth_user, safe_unicode(environ.get('PATH_INFO')))
190 self.ip_addr, auth_user, safe_unicode(environ.get('PATH_INFO')))
183 )
191 )
184 return WSGIController.__call__(self, environ, start_response)
192 return WSGIController.__call__(self, environ, start_response)
185 finally:
193 finally:
186 log.info('Request to %s time: %.3fs' % (
194 log.info('IP: %s Request to %s time: %.3fs' % (
195 _get_ip_addr(environ),
187 safe_unicode(environ.get('PATH_INFO')), time.time() - start)
196 safe_unicode(environ.get('PATH_INFO')), time.time() - start)
188 )
197 )
189 meta.Session.remove()
198 meta.Session.remove()
General Comments 0
You need to be logged in to leave comments. Login now