Mercurial > public > src > rhodecode
diff pylons_app/lib/middleware/simplehg.py @ 351:a9a6c74ad2a6
added ip loggin into mercurial middleware
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 01 Jul 2010 20:10:22 +0200 |
parents | 4c9a295d80a4 |
children | 6c23e72437e3 |
line wrap: on
line diff
--- a/pylons_app/lib/middleware/simplehg.py Thu Jul 01 20:02:06 2010 +0200 +++ b/pylons_app/lib/middleware/simplehg.py Thu Jul 01 20:10:22 2010 +0200 @@ -98,7 +98,10 @@ return HTTPForbidden()(environ, start_response) #log action - self.__log_user_action(user, action, repo_name) + proxy_key = 'HTTP_X_REAL_IP' + def_key = 'REMOTE_ADDR' + ipaddr = environ.get(proxy_key, environ.get(def_key, '0.0.0.0')) + self.__log_user_action(user, action, repo_name, ipaddr) #=================================================================== # MERCURIAL REQUEST HANDLING @@ -162,7 +165,7 @@ if mapping.has_key(cmd): return mapping[cmd] - def __log_user_action(self, user, action, repo): + def __log_user_action(self, user, action, repo, ipaddr): sa = meta.Session try: user_log = UserLog() @@ -170,6 +173,7 @@ user_log.action = action user_log.repository = repo.replace('/', '') user_log.action_date = datetime.now() + user_log.user_ip = ipaddr sa.add(user_log) sa.commit() log.info('Adding user %s, action %s on %s',