aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2022-11-30 13:48:53 -0500
committerMike Perry <mikeperry-git@torproject.org>2023-04-06 15:57:10 +0000
commita9fc6c937c42d879850ea46366a9fad8ff6d404b (patch)
treefe79c94c41dd005cfdd119f3c7ee439673f74058
parent447775a5e0b2178b44826cf6802a9c5e779a45d1 (diff)
downloadtor-a9fc6c937c42d879850ea46366a9fad8ff6d404b.tar.gz
tor-a9fc6c937c42d879850ea46366a9fad8ff6d404b.zip
protover: Support Relay=5 for Conflux (prop329)
Closes #40721 Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r--src/core/or/or.h3
-rw-r--r--src/core/or/protover.c4
-rw-r--r--src/core/or/protover.h3
-rw-r--r--src/core/or/versions.c7
-rw-r--r--src/feature/nodelist/nodelist.c11
-rw-r--r--src/feature/nodelist/nodelist.h1
6 files changed, 28 insertions, 1 deletions
diff --git a/src/core/or/or.h b/src/core/or/or.h
index c6d9864b53..ece2475613 100644
--- a/src/core/or/or.h
+++ b/src/core/or/or.h
@@ -731,6 +731,9 @@ typedef struct protover_summary_flags_t {
/** True iff this router supports congestion control.
* Requires both FlowCtrl=2 *and* Relay=4 */
unsigned int supports_congestion_control : 1;
+
+ /** True iff this router supports conflux. Requires Relay=5 */
+ unsigned int supports_conflux : 1;
} protover_summary_flags_t;
typedef struct routerinfo_t routerinfo_t;
diff --git a/src/core/or/protover.c b/src/core/or/protover.c
index 4cd6510da7..175bfbdab0 100644
--- a/src/core/or/protover.c
+++ b/src/core/or/protover.c
@@ -55,6 +55,7 @@ static const struct {
{ PRT_PADDING, "Padding"},
{ PRT_CONS, "Cons" },
{ PRT_FLOWCTRL, "FlowCtrl"},
+ { PRT_CONFLUX, "Conflux"},
};
#define N_PROTOCOL_NAMES ARRAY_LENGTH(PROTOCOL_NAMES)
@@ -386,6 +387,7 @@ protocol_list_supports_protocol_or_later(const char *list,
* XXX START OF HAZARDOUS ZONE XXX
*/
/* All protocol version that this relay version supports. */
+#define PR_CONFLUX_V "1"
#define PR_CONS_V "1-2"
#define PR_DESC_V "1-2"
#define PR_DIRCACHE_V "2"
@@ -409,6 +411,7 @@ const char *
protover_get_supported(const protocol_type_t type)
{
switch (type) {
+ case PRT_CONFLUX: return PR_CONFLUX_V;
case PRT_CONS: return PR_CONS_V;
case PRT_DESC: return PR_DESC_V;
case PRT_DIRCACHE: return PR_DIRCACHE_V;
@@ -471,6 +474,7 @@ protover_get_supported_protocols(void)
*/
return
+ "Conflux=" PR_CONFLUX_V " "
"Cons=" PR_CONS_V " "
"Desc=" PR_DESC_V " "
"DirCache=" PR_DIRCACHE_V " "
diff --git a/src/core/or/protover.h b/src/core/or/protover.h
index 8f15c02fb2..9d8eb4dcc5 100644
--- a/src/core/or/protover.h
+++ b/src/core/or/protover.h
@@ -37,6 +37,8 @@ struct smartlist_t;
#define PROTOVER_RELAY_CANONICAL_IPV6 3
/** The protover version number where relays can accept ntorv3 */
#define PROTOVER_RELAY_NTOR_V3 4
+/** The protover that signals conflux support. */
+#define PROTOVER_CONFLUX_V1 1
/** The protover version number that signifies HSv3 intro point support */
#define PROTOVER_HS_INTRO_V3 4
@@ -72,6 +74,7 @@ typedef enum protocol_type_t {
PRT_CONS = 9,
PRT_PADDING = 10,
PRT_FLOWCTRL = 11,
+ PRT_CONFLUX = 12,
} protocol_type_t;
bool protover_list_is_invalid(const char *s);
diff --git a/src/core/or/versions.c b/src/core/or/versions.c
index 9913b3ee31..8f5503691e 100644
--- a/src/core/or/versions.c
+++ b/src/core/or/versions.c
@@ -488,6 +488,13 @@ memoize_protover_summary(protover_summary_flags_t *out,
protocol_list_supports_protocol(protocols, PRT_RELAY,
PROTOVER_RELAY_NTOR_V3);
+ /* Conflux requires congestion control. */
+ out->supports_conflux =
+ protocol_list_supports_protocol(protocols, PRT_FLOWCTRL,
+ PROTOVER_FLOWCTRL_CC) &&
+ protocol_list_supports_protocol(protocols, PRT_CONFLUX,
+ PROTOVER_CONFLUX_V1);
+
protover_summary_flags_t *new_cached = tor_memdup(out, sizeof(*out));
cached = strmap_set(protover_summary_map, protocols, new_cached);
tor_assert(!cached);
diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c
index b895a2c7f8..bbaa51a407 100644
--- a/src/feature/nodelist/nodelist.c
+++ b/src/feature/nodelist/nodelist.c
@@ -1205,7 +1205,7 @@ node_ed25519_id_matches(const node_t *node, const ed25519_public_key_t *id)
/** Dummy object that should be unreturnable. Used to ensure that
* node_get_protover_summary_flags() always returns non-NULL. */
static const protover_summary_flags_t zero_protover_flags = {
- 0,0,0,0,0,0,0,0,0,0,0,0,0
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
/** Return the protover_summary_flags for a given node. */
@@ -1341,6 +1341,15 @@ node_supports_accepting_ipv6_extends(const node_t *node,
}
}
+/** Return true iff the given node supports conflux (Relay=5) */
+bool
+node_supports_conflux(const node_t *node)
+{
+ tor_assert(node);
+
+ return node_get_protover_summary_flags(node)->supports_conflux;
+}
+
/** Return the RSA ID key's SHA1 digest for the provided node. */
const uint8_t *
node_get_rsa_id_digest(const node_t *node)
diff --git a/src/feature/nodelist/nodelist.h b/src/feature/nodelist/nodelist.h
index 5a45490dbb..3d5ad9c0ea 100644
--- a/src/feature/nodelist/nodelist.h
+++ b/src/feature/nodelist/nodelist.h
@@ -84,6 +84,7 @@ bool node_supports_establish_intro_dos_extension(const node_t *node);
bool node_supports_initiating_ipv6_extends(const node_t *node);
bool node_supports_accepting_ipv6_extends(const node_t *node,
bool need_canonical_ipv6_conn);
+bool node_supports_conflux(const node_t *node);
const uint8_t *node_get_rsa_id_digest(const node_t *node);
MOCK_DECL(smartlist_t *,node_get_link_specifier_smartlist,(const node_t *node,