[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add code to infer protocol versions for old Tor versions.
commit c6a2204e23db9ba462b1e8601897b3cadf6a0a03
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Thu Aug 25 11:18:05 2016 -0400
Add code to infer protocol versions for old Tor versions.
---
src/or/protover.c | 33 +++++++++++++++++++++++++++++++--
src/or/protover.h | 5 +++++
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/or/protover.c b/src/or/protover.c
index 2bde02c..7314d61 100644
--- a/src/or/protover.c
+++ b/src/or/protover.c
@@ -1,9 +1,9 @@
#define PROTOVER_PRIVATE
+#include "or.h"
#include "protover.h"
-#include "compat.h"
-#include "torlog.h"
+#include "routerparse.h"
static const smartlist_t *get_supported_protocol_list(void);
static int protocol_list_contains(const smartlist_t *protos,
@@ -617,6 +617,35 @@ protocol_list_contains(const smartlist_t *protos,
return 0;
}
+/** Return a string describing the protocols supported by tor version
+ * <b>version</b>, or an empty string if we cannot tell.
+ *
+ * Note that this is only used to infer protocols for Tor versions that
+ * can't declare their own.
+ **/
+const char *
+protover_compute_for_old_tor(const char *version)
+{
+ if (tor_version_as_new_as(version,
+ FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS)) {
+ return "";
+ } else if (tor_version_as_new_as(version, "0.2.7.5")) {
+ /* 0.2.7-stable added Desc=2, Microdesc=2, Cons=2, which indicate
+ * ed25519 support. We'll call them present only in "stable" 027,
+ * though. */
+ return "Cons=1-2 Desc=1-2 DirCache=1 HSDir=1 HSMid=1 Link=1-4 LinkAuth=1 "
+ "Microdesc=1-2 Relay=1-2";
+ } else if (tor_version_as_new_as(version, "0.2.4.19")) {
+ /* No currently supported Tor server versions are older than this, or
+ * lack these protocols. */
+ return "Cons=1 Desc=1 DirCache=1 HSDir=1 HSMid=1 Link=1-4 LinkAuth=1 "
+ "Microdesc=1 Relay=1-2";
+ } else {
+ /* Cannot infer protocols. */
+ return "";
+ }
+}
+
void
protover_free_all(void)
{
diff --git a/src/or/protover.h b/src/or/protover.h
index f809a8d..d378627 100644
--- a/src/or/protover.h
+++ b/src/or/protover.h
@@ -4,6 +4,9 @@
#include "container.h"
+/* This is a guess. */
+#define FIRST_TOR_VERSION_TO_ADVERTISE_PROTOCOLS "0.2.9.3-alpha"
+
typedef enum protocol_type_t {
PRT_LINK,
PRT_LINKAUTH,
@@ -29,6 +32,8 @@ const char *get_supported_protocols(void);
char * compute_protover_vote(const smartlist_t *list_of_proto_strings,
int threshold);
+const char *protover_compute_for_old_tor(const char *version);
+
void protover_free_all(void);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits