X-Git-Url: https://git.mxchange.org/?p=quix0rs-apt-p2p.git;a=blobdiff_plain;f=apt_p2p%2FHTTPServer.py;h=1d1af488fdabddb289bb4cc9e8bfd430078b624e;hp=b5dec02c36e1a8f1c7f428571f7a2e74c5a80d11;hb=c1a8891e0bfb81e9fc64d271f8e4de059c699921;hpb=2f3c17ab7b51cbad0abf11fa66f6cafcb5a41c5e diff --git a/apt_p2p/HTTPServer.py b/apt_p2p/HTTPServer.py index b5dec02..1d1af48 100644 --- a/apt_p2p/HTTPServer.py +++ b/apt_p2p/HTTPServer.py @@ -264,20 +264,27 @@ class TopLevel(resource.Resource): else: log.msg('Hash could not be found in database: %r' % hash) - # Only local requests (apt) get past this point - if request.remoteAddr.host != "127.0.0.1": - log.msg('Blocked illegal access to %s from %s' % (request.uri, request.remoteAddr)) - return None, () - - # Block access to index .diff files (for now) - if 'Packages.diff' in segments or 'Sources.diff' in segments: - return None, () - if len(name) > 1: # It's a request from apt + + # Only local requests (apt) get past this point + if request.remoteAddr.host != "127.0.0.1": + log.msg('Blocked illegal access to %s from %s' % (request.uri, request.remoteAddr)) + return None, () + + # Block access to index .diff files (for now) + if 'Packages.diff' in segments or 'Sources.diff' in segments or name == 'favicon.ico': + return None, () + return FileDownloader(self.directory.path, self.manager), segments[0:] else: # Will render the statistics page + + # Only local requests for stats are allowed + if not config.getboolean('DEFAULT', 'REMOTE_STATS') and request.remoteAddr.host != "127.0.0.1": + log.msg('Blocked illegal access to %s from %s' % (request.uri, request.remoteAddr)) + return None, () + return self, () log.msg('Got a malformed request for "%s" from %s' % (request.uri, request.remoteAddr))