aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/versions.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-10-01 10:48:55 -0500
committerNick Mathewson <nickm@torproject.org>2018-10-01 10:48:55 -0500
commit95e2eb9083d2cd9c79c3f4151850c86cbeaf4cc4 (patch)
tree0699324d5ff8b408cc9ea174547b3d4ba901632e /src/core/or/versions.c
parent4201203845fa563a7f7410609267b96f2c319720 (diff)
downloadtor-95e2eb9083d2cd9c79c3f4151850c86cbeaf4cc4.tar.gz
tor-95e2eb9083d2cd9c79c3f4151850c86cbeaf4cc4.zip
Move summarize_protover_flags to versions.c
Diffstat (limited to 'src/core/or/versions.c')
-rw-r--r--src/core/or/versions.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/core/or/versions.c b/src/core/or/versions.c
index 2d24862981..06274996a7 100644
--- a/src/core/or/versions.c
+++ b/src/core/or/versions.c
@@ -10,6 +10,7 @@
*/
#include "core/or/or.h"
+#include "core/or/protover.h"
#include "core/or/versions.h"
#include "lib/crypt_ops/crypto_util.h"
@@ -375,3 +376,47 @@ sort_version_list(smartlist_t *versions, int remove_duplicates)
if (remove_duplicates)
smartlist_uniq(versions, compare_tor_version_str_ptr_, tor_free_);
}
+
+/** Summarize the protocols listed in <b>protocols</b> into <b>out</b>,
+ * falling back or correcting them based on <b>version</b> as appropriate.
+ */
+void
+summarize_protover_flags(protover_summary_flags_t *out,
+ const char *protocols,
+ const char *version)
+{
+ tor_assert(out);
+ memset(out, 0, sizeof(*out));
+ if (protocols) {
+ out->protocols_known = 1;
+ out->supports_extend2_cells =
+ protocol_list_supports_protocol(protocols, PRT_RELAY, 2);
+ out->supports_ed25519_link_handshake_compat =
+ protocol_list_supports_protocol(protocols, PRT_LINKAUTH, 3);
+ out->supports_ed25519_link_handshake_any =
+ protocol_list_supports_protocol_or_later(protocols, PRT_LINKAUTH, 3);
+ out->supports_ed25519_hs_intro =
+ protocol_list_supports_protocol(protocols, PRT_HSINTRO, 4);
+ out->supports_v3_hsdir =
+ protocol_list_supports_protocol(protocols, PRT_HSDIR,
+ PROTOVER_HSDIR_V3);
+ out->supports_v3_rendezvous_point =
+ protocol_list_supports_protocol(protocols, PRT_HSREND,
+ PROTOVER_HS_RENDEZVOUS_POINT_V3);
+ }
+ if (version && !strcmpstart(version, "Tor ")) {
+ if (!out->protocols_known) {
+ /* The version is a "Tor" version, and where there is no
+ * list of protocol versions that we should be looking at instead. */
+
+ out->supports_extend2_cells =
+ tor_version_as_new_as(version, "0.2.4.8-alpha");
+ out->protocols_known = 1;
+ } else {
+ /* Bug #22447 forces us to filter on this version. */
+ if (!tor_version_as_new_as(version, "0.3.0.8")) {
+ out->supports_v3_hsdir = 0;
+ }
+ }
+ }
+}