summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Hellegouarch <sh@defuze.org>2011-02-23 16:49:55 +0000
committerSylvain Hellegouarch <sh@defuze.org>2011-02-23 16:49:55 +0000
commit8da82ac44db5fc3c8efd2f25c1c8fec72e86510c (patch)
treee802dfc0c1fe7c713fa56ae3a9f1646e03839994
parent59795a443f94cbcd817601a1271840fc4944acef (diff)
downloadcherrypy-git-8da82ac44db5fc3c8efd2f25c1c8fec72e86510c.tar.gz
Updating the remote client's info after tools.proxy had a chance to run, so that the remote IP is the real one.
-rw-r--r--cherrypy/lib/cpstats.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/cherrypy/lib/cpstats.py b/cherrypy/lib/cpstats.py
index 06d53ff8..8001e383 100644
--- a/cherrypy/lib/cpstats.py
+++ b/cherrypy/lib/cpstats.py
@@ -295,6 +295,9 @@ class StatsTool(cherrypy.Tool):
if appstats.get('Enabled', False):
cherrypy.Tool._setup(self)
self.record_start()
+ cherrypy.request.hooks.attach('before_request_body',
+ self.record_resource,
+ priority=35)
def record_start(self):
"""Record the beginning of a request."""
@@ -317,6 +320,11 @@ class StatsTool(cherrypy.Tool):
'Response Status': None,
'Start Time': time.time(),
}
+
+ def record_resource(self, debug=False):
+ w = appstats['Requests'][threading._get_ident()]
+ r = cherrypy.serving.request.remote
+ w['Client'] = '%s:%s' % (r.ip, r.port)
def record_stop(self, uriset=None, slow_queries=1.0, slow_queries_count=100,
debug=False, **kwargs):