| 40 | | The extension described in this document also solves a long-standing issue |
| 41 | | with the protocol defined in BEP-5, and does so without endangering |
| 42 | | compatibility. When a get_peers request is sent with an explicit request |
| 43 | | for an address family, the presence of contact information in the reply is |
| 44 | | no longer governed by the presence of a "values" key; this avoids the |
| 45 | | well-known problem of contact information being masked by peer information. |
| | 40 | The extension described in this document also solves a long-standing |
| | 41 | issue with the protocol defined in BEP-5. The presence of contact |
| | 42 | information in the reply is no longer governed by the presence of |
| | 43 | a "values" key; this avoids the well-known problem of contact |
| | 44 | information being masked by peer information. While this is an |
| | 45 | incompatible change, it is believed to be properly handled by all |
| | 46 | deployed implementations. |
| | 112 | Changes to existing parameters |
| | 113 | ------------------------------ |
| | 114 | |
| | 115 | values |
| | 116 | '''''' |
| | 117 | |
| | 118 | In a reply sent over IPv4, the "values" parameter contains a list of |
| | 119 | strings, each of which contains compact format IPv4 contact |
| | 120 | information for a single peer. |
| | 121 | |
| | 122 | In a reply sent over IPv6, "values' contains a list of strings, each |
| | 123 | of which contains compact format IPv6 contact information for a single |
| | 124 | peer. |
| | 125 | |
| | 126 | Implementations of this specification must be able to properly parse |
| | 127 | hybrid "values" lists -- lists containing an arbitrary mixture of |
| | 128 | 6-octet IPv4 values and 18-octet IPv6 values. However, |
| | 129 | implementations should not send such hybrid lists, and must not send |
| | 130 | hybrid lists in a reply to an IPv4 request that doesn't contain |
| | 131 | a "want" parameter. |
| | 132 | |
| | 133 | **Rationale**: a request sent over IPv4 with no "want" parameter |
| | 134 | could originate from a node that implements plain BEP-5, and which |
| | 135 | might therefore be unable to parse a hybrid list. |
| | 136 | |
| | 137 | |
| 154 | | A node sending a find_nodes or get_peers request should include a "want" |
| 155 | | parameter containing one or both of the characters "4" or "6". A node |
| 156 | | replying to a find_nodes or get_peers request must include a "nodes" |
| 157 | | parameter if the request's "want" parameter included a "4", and a "nodes6" |
| 158 | | parameter if the request's "want" parameter included a "6". |
| 159 | | |
| 160 | | In the absence of a "want" parameter, the behaviour of the replying node is |
| 161 | | more involved. For a reply to a find_nodes request, the node should |
| 162 | | include "nodes" if the request was sent over IPv4, and include "nodes6" if |
| 163 | | the request was sent over IPv6. |
| 164 | | |
| 165 | | For a get_peers request with no "want" parameter, value should only be |
| 166 | | included if there is no "values" or "values6" parameter. If no "values" or |
| 167 | | "values6" parameter is being sent, the presence of "nodes" or "nodes6" is |
| 168 | | governed by the network-layer protocol of the request, as above. |
| 169 | | |
| 170 | | **Rationale**: it has been suggested that the reply to a get_peers |
| 171 | | request should always include a "nodes" or "nodes6" parameter, |
| 172 | | independently of the presence of a "values" or "values6" parameter. |
| 173 | | While this is clearly a better semantics, it is not backward-compatible, |
| 174 | | and it is not known whether it breaks any deployed implementations. |
| 175 | | |
| 176 | | When a node receives a get_peers request and it has contact information for |
| 177 | | the matching address family and info-hash, it should include either |
| 178 | | a "values" parameter (if the request was sent over IPv4) or a "values6" |
| 179 | | parameter in the reply. |
| 180 | | |
| 181 | | A reply sent over IPv4 must not contain a "values6" parameter, and a reply |
| 182 | | sent over IPv6 must not contain a "values" parameter. In other words, the |
| 183 | | "want" parameter only governs the presence of the "nodes" and "nodes6" |
| 184 | | parameters. |
| | 178 | A node sending a find_nodes or get_peers request should include |
| | 179 | a "want" parameter containing one or both of the characters "4" or |
| | 180 | "6". A node replying to a find_nodes or get_peers request should |
| | 181 | include a "nodes" parameter if and only if the request's "want" |
| | 182 | parameter included a "4", and should include a "nodes6" parameter if |
| | 183 | and only if the request's "want" parameter included a "6". |
| | 184 | |
| | 185 | In the absence of a "want" parameter, the reply should include "nodes" |
| | 186 | if the request was sent over IPv4, and should include "nodes6" if the |
| | 187 | request was sent over IPv6. |
| | 188 | |
| | 189 | **Rationale**: this is an incompatible change to the protocol |
| | 190 | defined in BEP-5 [#BEP-5]_, which specifies that "nodes" and |
| | 191 | "values" are mutually exclusive. However, this change makes the DHT |
| | 192 | more reliable, and has been deployed by most implementations for |
| | 193 | over a year with no negative effects. |
| | 194 | |
| | 195 | When a node receives a get_peers request and it has contact |
| | 196 | information for the matching address family and info-hash, it should |
| | 197 | additionally include a "values" parameter containing a list of 6-octet |
| | 198 | strings if the request was sent over IPv4, and a list of 18-octet |
| | 199 | strings if the request was sent over IPv6. |
| | 200 | |
| | 201 | A reply sent over IPv4 should not contain 18-octet IPv6 contact |
| | 202 | information, and a reply sent over IPv6 should not contain 6-octet |
| | 203 | IPv4 contact information. In other words, the "want" parameter only |
| | 204 | governs the presence of the "nodes" and "nodes6" parameters, not the |
| | 205 | interpretation of "values". |
| | 206 | |
| | 207 | **Rationale**: if the requesting node is a single-stack node, it has |
| | 208 | no interest in values of the other address family. If the |
| | 209 | requesting node is a double-stack node, then it must perform the two |
| | 210 | announces in parallel; providing both sets of data in both sets of |
| | 211 | replies merely increases the amount of traffic without giving any |
| | 212 | extra information. |