From: Michael Tremer Date: Sat, 15 Nov 2008 16:10:43 +0000 (+0100) Subject: Only let source code be downloaded by our own robot. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6a170c4ecdd47df1744689e7a2cd0d3416885799;p=ipfire.org.git Only let source code be downloaded by our own robot. I made this change because a lot of silly bots are bursting the bandwidth. --- diff --git a/source/dlhandler.py b/source/dlhandler.py index 14cc5b75..cda2f832 100644 --- a/source/dlhandler.py +++ b/source/dlhandler.py @@ -23,12 +23,22 @@ import os import cgi from git import * +def give_403(): + print "Status: 403 Forbidden" + print "Pragma: no-cache" + print "Cache-control: no-cache" + print "Connection: close" + print + print + os._exit(0) + def give_404(): print "Status: 404 Not found" print "Pragma: no-cache" print "Cache-control: no-cache" print "Connection: close" print + print os._exit(0) def give_302(): @@ -155,13 +165,15 @@ class PatchObject(SourceObject): path = cgi.FieldStorage().getfirst('path') ver = cgi.FieldStorage().getfirst('ver') +if not os.environ["HTTP_USER_AGENT"].startswith("IPFireSourceGrabber"): + give_403() + if not path: give_302() if not ver: ver = "3.x" - # At first, we assume that the requested object is a plain file: try: object = FileObject(path=path, version=ver)