I have attached a diff against zope.twisted.web2.log that puts additional ip address(es) in access.log.

With this patch, the ip address section in the log may become a list of addresses delimited with '>'. It uses the 'x-forwarded-for' headers, so the info may not be trustable, but it is much more informative than '192.168.1.1' for every address if you run z3 behind a proxy like pound.

Please pardon if the patch is not-quite-right. I did not read the directions.

-Jim Washington

*** log.py	Sat Jan 28 19:20:33 2006
--- /usr/lib/zope-3.2.0/lib/python/twisted/web2/log.py	Sat Jan 28 20:46:34 2006
***************
*** 148,158 ****
              request.method,
              request.uri,
              '.'.join([str(x) for x in request.clientproto]))
!         
          self.logMessage(
              '%s - %s [%s] "%s" %s %d "%s" "%s"' %(
!                 request.chanRequest.getRemoteHost().host,
                  # XXX: Where to get user from?
                  "-",
                  self.logDateString(
                      response.headers.getHeader('date', 0)),
--- 148,165 ----
              request.method,
              request.uri,
              '.'.join([str(x) for x in request.clientproto]))
!         proxyAddresses = request.headers.getRawHeaders('x-forwarded-for',None)
!         singleHost = request.chanRequest.getRemoteHost().host
!         if proxyAddresses:
!             proxyAddresses.append(singleHost)
!             logAddress =  '>'.join(proxyAddresses)
!         else:
!             logAddress = singleHost
          self.logMessage(
              '%s - %s [%s] "%s" %s %d "%s" "%s"' %(
!                 #request.chanRequest.getRemoteHost().host,
                  # XXX: Where to get user from?
+                 logAddress,
                  "-",
                  self.logDateString(
                      response.headers.getHeader('date', 0)),
_______________________________________________
Zope3-dev mailing list
[email protected]
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to