tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit b4991f6bb6bc090ba1d3e5f9a80e4069b1068e71
parent 192873d6a244f8a4237892f1bae635c67625c695
Author: Nick Mathewson <nickm@torproject.org>
Date:   Mon,  2 Jun 2025 10:36:18 -0400

Use protovers to detect cgo support.

Diffstat:
Msrc/core/or/or.h | 3+++
Msrc/core/or/protover.h | 8++++++++
Msrc/core/or/versions.c | 9+++++++++
Msrc/feature/nodelist/nodelist.c | 2+-
4 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/core/or/or.h b/src/core/or/or.h @@ -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; diff --git a/src/core/or/protover.h b/src/core/or/protover.h @@ -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` diff --git a/src/core/or/versions.c b/src/core/or/versions.c @@ -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); diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c @@ -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. */