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