Improper hash_type use in AptPackages.
Use URL quoting and unquoting for peer downloads.
More and better log messages.
rel = deb822.Release(f, fields = ['MD5Sum', 'SHA1', 'SHA256'])
for hash_type in rel:
for file in rel[hash_type]:
- self.indexrecords[cache_path].setdefault(file['name'], {})[hash_type.upper()] = (file['hash_type'], file['size'])
+ self.indexrecords[cache_path].setdefault(file['name'], {})[hash_type.upper()] = (file[hash_type], file['size'])
f.close()
+from urllib import unquote_plus
+
from twisted.python import log
from twisted.internet import defer
from twisted.web2 import server, http, resource, channel
<p>TODO: eventually some stats will be shown here.</body></html>""")
def locateChild(self, request, segments):
+ log.msg('Got HTTP request for %s from %s' % (request.uri, request.remoteAddr))
name = segments[0]
if name == '~':
if len(segments) != 2:
log.msg('Got a malformed request from %s' % request.remoteAddr)
return None, ()
- hash = segments[1]
+ hash = unquote_plus(segments[1])
files = self.db.lookupHash(hash)
if files:
log.msg('Sharing %s with %s' % (files[0]['path'].path, request.remoteAddr))
from random import choice
from urlparse import urlparse, urlunparse
+from urllib import quote_plus
from twisted.internet import reactor, defer
from twisted.python import log
peer = choice(peers)
log.msg('Downloading from peer %s' % peer)
host, port = splitHostPort('http', peer)
- path = '/~/' + hash
+ path = '/~/' + quote_plus(hash.expected())
else:
log.msg('Downloading (%s) from mirror %s' % (method, mirror))
parsed = urlparse(mirror)
return None
def store_done(self, result, hash):
- log.msg('Added %s to the DHT: %r' % (hash, result))
+ log.msg('Added %s to the DHT: %r' % (hash.hexdigest(), result))
\ No newline at end of file