Allow the setting of khashmir ID's suffix.
[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 estimation of the total number of nodes
61
62 The current total nodes estimation is based on the number of buckets.
63 A better way is to look at the average inter-node spacing for the K
64 closest nodes after a find_node/value completes. Be sure to measure
65 the inter-node spacing in log2 space to dampen any ill effects. This
66 can be used in the formula:
67         nodes = 2^160 / 2^(average of log2 spacing)
68 The average should also be saved using an exponentially weighted
69 moving average (of the log2 distance) over separate find_node/value
70 actions to get a better calculation over time.
71
72
73 Improve the downloaded and uploaded data measurements.
74
75 There are 2 places that this data is measured: for statistics, and for
76 limiting the upload bandwidth. They both have deficiencies as they
77 sometimes miss the headers or the requests sent out. The upload
78 bandwidth calculation only considers the stream in the upload and not
79 the headers sent, and it also doesn't consider the upload bandwidth
80 from requesting downloads from peers (though that may be a good thing).
81 The statistics calculations for downloads include the headers of
82 downloaded files, but not the requests received from peers for upload
83 files. The statistics for uploaded data only includes the files sent
84 and not the headers, and also misses the requests for downloads sent to
85 other peers.
86
87
88 Rehash changed files instead of removing them.
89
90 When the modification time of a file changes but the size does not,
91 the file could be rehased to verify it is the same instead of
92 automatically removing it. The DB would have to be modified to return
93 deferred's for a lot of its functions.
94
95
96 Consider storing deltas of packages.
97
98 Instead of downloading full package files when a previous version of
99 the same package is available, peers could request a delta of the
100 package to the previous version. This would only be done if the delta
101 is significantly (>50%) smaller than the full package, and is not too
102 large (absolutely). A peer that has a new package and an old one would
103 add a list of deltas for the package to the value stored in the DHT.
104 The delta information would specify the old version (by hash), the
105 size of the delta, and the hash of the delta. A peer that has the same
106 old package could then download the delta from the peer by requesting
107 the hash of the delta. Alternatively, very small deltas could be
108 stored directly in the DHT.
109
110
111 Consider tracking security issues with packages.
112
113 Since sharing information with others about what packages you have
114 downloaded (and probably installed) is a possible security
115 vulnerability, it would be advantageous to not share that information
116 for packages that have known security vulnerabilities. This would
117 require some way of obtaining a list of which packages (and versions)
118 are vulnerable, which is not currently available.
119
120
121 Consider adding peer characteristics to the DHT.
122
123 Bad peers could be indicated in the DHT by adding a new value that is
124 the NOT of their ID (so they are guaranteed not to store it) indicating
125 information about the peer. This could be bad votes on the peer, as
126 otherwise a peer could add good info about itself.
127
128
129 Consider adding pieces to the DHT instead of files.
130
131 Instead of adding file hashes to the DHT, only piece hashes could be
132 added. This would allow a peer to upload to other peers while it is
133 still downloading the rest of the file. It is not clear that this is
134 needed, since peer's will not be uploading and downloading ery much of
135 the time.