Speed up the recursive DHT actions when timeouts occur.
[quix0rs-apt-p2p.git] / TODO
1 Rotate DNS entries for mirrors more reliably.
2
3 Currently the mirrors are accessed by DNS name, which can cause some
4 issues when there are mirror differences and the DNS gets rotated.
5 Instead, the HTTP Downloader should handle DNS lookups itself, store
6 the resulting addresses, and send requests to IP addresses. If there
7 is an error from the mirror (hash check or 404 response), the next IP
8 address in the rotation should be used.
9
10
11 Use GPG signatures as a hash for files.
12
13 A detached GPG signature, such as is found in Release.gpg, can be used
14 as a hash for the file. This hash can be used to verify the file when
15 it is downloaded, and a shortened version can be added to the DHT to
16 look up peers for the file. To get the hash into a binary form from
17 the ascii-armored detached file, use the command
18 'gpg --no-options --no-default-keyring --output - --dearmor -'. The
19 hash should be stored as the reverse of the resulting binary string,
20 as the bytes at the beginning are headers that are the same for most
21 signatures. That way the shortened hash stored in the DHT will have a
22 better chance of being unique and being stored on different peers. To
23 verify a file, first the binary hash must be re-reversed, armored, and
24 written to a temporary file with the command
25 'gpg --no-options --no-default-keyring --output $tempfile --enarmor -'.
26 Then the incoming file can be verified with the command
27 'gpg --no-options --no-default-keyring --keyring /etc/apt/trusted.gpg
28 --verify $tempfile -'.
29
30 All communication with the command-line gpg should be done using pipes
31 and the python module python-gnupginterface. There needs to be a new
32 module for GPG verification and hashing, which will make this easier.
33 In particular, it would need to support hashlib-like functionality
34 such as new(), update(), and digest(). Note that the verification
35 would not involve signing the file again and comparing the signatures,
36 as this is not possible. Instead, the verify() function would have to
37 behave differently for GPG hashes, and check that the verification
38 resulted in a VALIDSIG. CAUTION: the detached signature can have a
39 variable length, though it seems to be usually 65 bytes, 64 bytes has
40 also been observed.
41
42
43 Consider what happens when multiple requests for a file are received.
44
45 When another request comes in for a file already being downloaded,
46 the new request should wait for the old one to finish. This should
47 also be done for multiple requests for peer downloads of files with
48 the same hash.
49
50
51 Packages.diff files need to be considered.
52
53 The Packages.diff/Index files contain hashes of Packages.diff/rred.gz 
54 files, which themselves contain diffs to the Packages files previously 
55 downloaded. Apt will request these files for the testing/unstable 
56 distributions. They need to be dealt with properly by 
57 adding them to the tracking done by the AptPackages module.
58
59
60 Improve the downloaded and uploaded data measurements.
61
62 There are 2 places that this data is measured: for statistics, and for
63 limiting the upload bandwidth. They both have deficiencies as they
64 sometimes miss the headers or the requests sent out. The upload
65 bandwidth calculation only considers the stream in the upload and not
66 the headers sent, and it also doesn't consider the upload bandwidth
67 from requesting downloads from peers (though that may be a good thing).
68 The statistics calculations for downloads include the headers of
69 downloaded files, but not the requests received from peers for upload
70 files. The statistics for uploaded data only includes the files sent
71 and not the headers, and also misses the requests for downloads sent to
72 other peers.
73
74
75 Rehash changed files instead of removing them.
76
77 When the modification time of a file changes but the size does not,
78 the file could be rehased to verify it is the same instead of
79 automatically removing it. The DB would have to be modified to return
80 deferred's for a lot of its functions.
81
82
83 Consider storing deltas of packages.
84
85 Instead of downloading full package files when a previous version of
86 the same package is available, peers could request a delta of the
87 package to the previous version. This would only be done if the delta
88 is significantly (>50%) smaller than the full package, and is not too
89 large (absolutely). A peer that has a new package and an old one would
90 add a list of deltas for the package to the value stored in the DHT.
91 The delta information would specify the old version (by hash), the
92 size of the delta, and the hash of the delta. A peer that has the same
93 old package could then download the delta from the peer by requesting
94 the hash of the delta. Alternatively, very small deltas could be
95 stored directly in the DHT.
96
97
98 Consider tracking security issues with packages.
99
100 Since sharing information with others about what packages you have
101 downloaded (and probably installed) is a possible security
102 vulnerability, it would be advantageous to not share that information
103 for packages that have known security vulnerabilities. This would
104 require some way of obtaining a list of which packages (and versions)
105 are vulnerable, which is not currently available.
106
107
108 Consider adding peer characteristics to the DHT.
109
110 Bad peers could be indicated in the DHT by adding a new value that is
111 the NOT of their ID (so they are guaranteed not to store it) indicating
112 information about the peer. This could be bad votes on the peer, as
113 otherwise a peer could add good info about itself.
114
115
116 Consider adding pieces to the DHT instead of files.
117
118 Instead of adding file hashes to the DHT, only piece hashes could be
119 added. This would allow a peer to upload to other peers while it is
120 still downloading the rest of the file. It is not clear that this is
121 needed, since peer's will not be uploading and downloading ery much of
122 the time.