]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use protovers to detect cgo support.
authorNick Mathewson <nickm@torproject.org>
Mon, 2 Jun 2025 14:36:18 +0000 (10:36 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 10 Jun 2025 23:06:47 +0000 (19:06 -0400)
src/core/or/or.h
src/core/or/protover.h
src/core/or/versions.c
src/feature/nodelist/nodelist.c

index 19836736ce77b9cd8e6011f410abf993cad06d00..1f06574ecfe2b3269eb9f264d1229fa84da54708 100644 (file)
@@ -831,6 +831,9 @@ typedef struct protover_summary_flags_t {
 
   /** True iff this router supports conflux. */
   unsigned int supports_conflux : 1;
+
+  /** True iff this router supports CGO. */
+  unsigned int supports_cgo : 1;
 } protover_summary_flags_t;
 
 typedef struct routerinfo_t routerinfo_t;
index 9d8eb4dcc5fd15e5a55d4ca3b5a6baab84dbf083..53e126ea34b88c920d81d4cda1ab18ba3a922195 100644 (file)
@@ -58,6 +58,14 @@ struct smartlist_t;
 /** The protover that signals support for congestion control */
 #define PROTOVER_FLOWCTRL_CC 2
 
+/** The protover required for negotiating protovers as part of the circuit
+ * extension handshake. */
+#define PROTOVER_RELAY_NEGOTIATE_SUBPROTO 5
+
+/** The protover required for negotiating protovers as part of the circuit
+ * extension handshake. */
+#define PROTOVER_RELAY_CRYPT_CGO 6
+
 /** List of recognized subprotocols. */
 /// C_RUST_COUPLED: src/rust/protover/ffi.rs `translate_to_rust`
 /// C_RUST_COUPLED: src/rust/protover/protover.rs `Proto`
index 8f5503691e758ca38c68e7da237fd9a6fd615cf2..782cdf4142882c27a4773d1d02cf2aea31fad199 100644 (file)
@@ -495,6 +495,15 @@ memoize_protover_summary(protover_summary_flags_t *out,
     protocol_list_supports_protocol(protocols, PRT_CONFLUX,
                                     PROTOVER_CONFLUX_V1);
 
+  /* CGO requires congestion control and subproto negotiation. */
+  out->supports_cgo =
+    protocol_list_supports_protocol(protocols, PRT_FLOWCTRL,
+                                    PROTOVER_FLOWCTRL_CC) &&
+    protocol_list_supports_protocol(protocols, PRT_RELAY,
+                                    PROTOVER_RELAY_NEGOTIATE_SUBPROTO) &&
+    protocol_list_supports_protocol(protocols, PRT_RELAY,
+                                    PROTOVER_RELAY_CRYPT_CGO);
+
   protover_summary_flags_t *new_cached = tor_memdup(out, sizeof(*out));
   cached = strmap_set(protover_summary_map, protocols, new_cached);
   tor_assert(!cached);
index 250f4fc782bf2c1306b4a9dd3726f60c10424856..105368b728c925d9d6d47c563f5a3e5540d97d53 100644 (file)
@@ -1239,7 +1239,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,0,0
 };
 
 /** Return the protover_summary_flags for a given node. */