class FileUploaderStream(stream.FileStream):
"""Modified to make it suitable for streaming to peers.
- Streams the file is small chunks to make it easier to throttle the
+ Streams the file in small chunks to make it easier to throttle the
streaming to peers.
@ivar CHUNK_SIZE: the size of chunks of data to send at a time
return None, ()
# Find the file in the database
- hash = unquote_plus(segments[1])
+ # Have to unquote_plus the uri, because the segments are unquoted by twisted
+ hash = unquote_plus(request.uri[3:])
files = self.db.lookupHash(hash)
if files:
# If it is a file, return it
log.msg('Sending torrent string %s to %s' % (b2a_hex(hash), request.remoteAddr))
return static.Data(bencode({'t': files[0]['pieces']}), 'application/x-bencoded'), ()
else:
- log.msg('Hash could not be found in database: %s' % hash)
+ 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
return FileDownloader(self.directory.path, self.manager), segments[0:]
return [{'pieces': 'abcdefghij0123456789\xca\xec\xb8\x0c\x00\xe7\x07\xf8~])\x8f\x9d\xe5_B\xff\x1a\xc4!'}]
return [{'path': FilePath(os.path.expanduser('~/school/optout'))}]
- t = TopLevel(FilePath(os.path.expanduser('~')), DB(), None)
+ t = TopLevel(FilePath(os.path.expanduser('~')), DB(), None, 0)
factory = t.getHTTPFactory()
# Standard twisted application Boilerplate