Skip to content

Commit

Permalink
Added client IP address to the e-mail that is sent when an internal
Browse files Browse the repository at this point in the history
broken link is detected.  This is to help with filtering out
misbehaving bots.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5043 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
spookylukey committed Apr 20, 2007
1 parent eb107e1 commit 9f180a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion django/middleware/common.py
Expand Up @@ -66,8 +66,10 @@ def process_response(self, request, response):
path = request.get_full_path() path = request.get_full_path()
if referer and not _is_ignorable_404(path) and (is_internal or '?' not in referer): if referer and not _is_ignorable_404(path) and (is_internal or '?' not in referer):
ua = request.META.get('HTTP_USER_AGENT', '<none>') ua = request.META.get('HTTP_USER_AGENT', '<none>')
ip = request.META.get('REMOTE_ADDR', '<none>')
mail_managers("Broken %slink on %s" % ((is_internal and 'INTERNAL ' or ''), domain), mail_managers("Broken %slink on %s" % ((is_internal and 'INTERNAL ' or ''), domain),
"Referrer: %s\nRequested URL: %s\nUser agent: %s\n" % (referer, request.get_full_path(), ua)) "Referrer: %s\nRequested URL: %s\nUser agent: %s\nIP address: %s\n" \
% (referer, request.get_full_path(), ua, ip))
return response return response


# Use ETags, if requested. # Use ETags, if requested.
Expand Down

0 comments on commit 9f180a1

Please sign in to comment.