V(VanguardsLiteEnabled, AUTOBOOL, "auto"),
V(UseMicrodescriptors, AUTOBOOL, "auto"),
OBSOLETE("UseNTorHandshake"),
+ V(UseRelayMessage, AUTOBOOL, "auto"),
VAR("__AlwaysCongestionControl", BOOL, AlwaysCongestionControl, "0"),
VAR("__SbwsExit", BOOL, SbwsExit, "0"),
V_IMMUTABLE(User, STRING, NULL),
* report bandwidth observations from this period? */
int TestingMinTimeToReportBandwidth;
+ /** Autobool: true if we should use the relay message with relays supporting
+ * protocol version Relay=5. Set to -1 indicating that the consensus decide.
+ * Default to 0. */
+ int UseRelayMessage;
+
/**
* Configuration objects for individual modules.
*
src/core/or/protover.c \
src/core/or/reasons.c \
src/core/or/relay.c \
+ src/core/or/relay_msg.c \
src/core/or/scheduler.c \
src/core/or/scheduler_kist.c \
src/core/or/scheduler_vanilla.c \
src/core/or/protover.h \
src/core/or/reasons.h \
src/core/or/relay.h \
+ src/core/or/relay_msg.h \
+ src/core/or/relay_msg_st.h \
src/core/or/relay_crypto_st.h \
src/core/or/scheduler.h \
src/core/or/sendme.h \
#include "core/or/congestion_control_common.h"
#include "core/or/extend_info_st.h"
#include "core/or/protover.h"
+#include "core/or/relay_msg.h"
#include "core/or/versions.h"
#include "lib/tls/tortls.h"
trn_ntorv3_ext_subproto_add_reqs(req, proto_req);
}
/* Build the RelayCell version request. */
- if (ei->supports_relay_cell_proto) {
+ if (relay_msg_is_enabled() && ei->supports_relay_cell_proto) {
trn_ntorv3_ext_subproto_req_t *proto_req =
trn_ntorv3_ext_subproto_req_new();
trn_ntorv3_ext_subproto_req_set_proto_id(proto_req, PRT_RELAY_CELL);
#include "core/or/scheduler.h"
#include "feature/hs/hs_metrics.h"
#include "feature/stats/rephist.h"
+#include "core/or/relay_msg.h"
#include "core/or/cell_st.h"
#include "core/or/cell_queue_st.h"
get_param_max_circuit_cell_queue_size(ns);
max_circuit_cell_queue_size_out =
get_param_max_circuit_cell_queue_size_out(ns);
+
+ /* Inform our relay message library. */
+ relay_msg_consensus_has_changed(ns);
}
/** Add <b>cell</b> to the queue of <b>circ</b> writing to <b>chan</b>
--- /dev/null
+/* Copyright (c) 2023, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file relay_msg.c
+ * \brief XXX: Write a brief introduction to this module.
+ **/
+
+#define RELAY_MSG_PRIVATE
+
+#include "app/config/config.h"
+
+#include "core/or/relay_msg.h"
+
+#include "feature/nodelist/networkstatus.h"
+
+/* Consensus parameters. Updated when we get a new consensus. */
+static bool relay_msg_enabled = false;
+
+/** Return the UseRelayMessage value either from the configuration file or the
+ * consensus if not present. */
+static bool
+get_param_enabled(const networkstatus_t *ns)
+{
+#define RELAY_MSG_PARAM_ENABLED_DEFAULT (0)
+#define RELAY_MSG_PARAM_ENABLED_MIN (0)
+#define RELAY_MSG_PARAM_ENABLED_MAX (1)
+
+ if (get_options()->UseRelayMessage != -1) {
+ return get_options()->UseRelayMessage != 0;
+ }
+
+ return networkstatus_get_param(ns, "UseRelayMessage",
+ RELAY_MSG_PARAM_ENABLED_DEFAULT,
+ RELAY_MSG_PARAM_ENABLED_MIN,
+ RELAY_MSG_PARAM_ENABLED_MAX) != 0;
+}
+
+/** Return true iff the ability to use relay messages is enabled. */
+bool
+relay_msg_is_enabled(void)
+{
+ return relay_msg_enabled;
+}
+
+/** Called just before the consensus is changed with the given networkstatus_t
+ * object. */
+void
+relay_msg_consensus_has_changed(const networkstatus_t *ns)
+{
+ relay_msg_enabled = get_param_enabled(ns);
+}
--- /dev/null
+/* Copyright (c) 2023, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file relay_msg.h
+ * \brief Header file for relay_msg.c.
+ **/
+
+#ifndef TOR_RELAY_MSG_H
+#define TOR_RELAY_MSG_H
+
+#include "core/or/or.h"
+
+bool relay_msg_is_enabled(void);
+
+void relay_msg_consensus_has_changed(const networkstatus_t *ns);
+
+#ifdef RELAY_MSG_PRIVATE
+
+#endif /* RELAY_MSG_PRIVATE */
+
+#endif /* TOR_RELAY_MSG_H */
+