29#define CONFLUX_ENABLED_MIN (0)
30#define CONFLUX_ENABLED_MAX (1)
31#define CONFLUX_ENABLED_DEFAULT (1)
35#define LOW_EXIT_THRESHOLD_MIN (0)
36#define LOW_EXIT_THRESHOLD_MAX (10000)
37#define LOW_EXIT_THRESHOLD_DEFAULT (6000)
40#define MAX_LINKED_SET_MIN (0)
41#define MAX_LINKED_SET_MAX (UINT8_MAX)
42#define MAX_LINKED_SET_DEFAULT (10)
45#define MAX_PREBUILT_SET_MIN (0)
46#define MAX_PREBUILT_SET_MAX (UINT8_MAX)
47#define MAX_PREBUILT_SET_DEFAULT (3)
50#define MAX_UNLINKED_LEG_RETRY_DEFAULT (3)
51#define MAX_UNLINKED_LEG_RETRY_MIN (0)
52#define MAX_UNLINKED_LEG_RETRY_MAX (UINT8_MAX)
55#define NUM_LEGS_SET_MIN (0)
56#define NUM_LEGS_SET_MAX (UINT8_MAX)
57#define NUM_LEGS_SET_DEFAULT (2)
60#define MAX_LEGS_SET_MIN (3)
61#define MAX_LEGS_SET_MAX (UINT8_MAX)
62#define MAX_LEGS_SET_DEFAULT (8)
65#define CFX_SEND_PCT_MIN (0)
66#define CFX_SEND_PCT_MAX (255)
67#define CFX_SEND_PCT_DFLT 100
70#define CFX_DRAIN_PCT_MIN (0)
71#define CFX_DRAIN_PCT_MAX (255)
72#define CFX_DRAIN_PCT_DFLT 0
79static bool conflux_enabled = CONFLUX_ENABLED_DEFAULT;
81static uint8_t max_linked_set = MAX_LINKED_SET_DEFAULT;
83static uint8_t max_prebuilt_set = MAX_PREBUILT_SET_DEFAULT;
86STATIC uint32_t max_unlinked_leg_retry = MAX_UNLINKED_LEG_RETRY_DEFAULT;
88static uint8_t num_legs_set = NUM_LEGS_SET_DEFAULT;
90static uint8_t max_legs_set = MAX_LEGS_SET_DEFAULT;
94static double low_exit_threshold_ratio =
95 LOW_EXIT_THRESHOLD_DEFAULT / (double)LOW_EXIT_THRESHOLD_MAX;
97static uint8_t cfx_drain_pct = CFX_DRAIN_PCT_DFLT;
98static uint8_t cfx_send_pct = CFX_SEND_PCT_DFLT;
102static double exit_conflux_ratio = 0.0;
109 double supported = 0.0;
117 if (!rs->is_exit || rs->is_bad_exit) {
120 if (rs->pv.supports_conflux) {
124 } SMARTLIST_FOREACH_END(rs);
126 if (total_exits > 0) {
128 supported / total_exits;
130 exit_conflux_ratio = 0.0;
133 log_info(
LD_GENERAL,
"Consensus has %.2f %% Exit relays supporting Conflux",
134 exit_conflux_ratio * 100.0);
159 tor_assert(CONST_TO_ORIGIN_CIRCUIT(circ)->cpath);
160 tor_assert(CONST_TO_ORIGIN_CIRCUIT(circ)->cpath->prev);
161 if (!CONST_TO_ORIGIN_CIRCUIT(circ)->cpath->prev->ccontrol)
176 static ratelim_t rlimit = RATELIM_INIT(60 * 60);
179 "This tor is a relay and ConfluxEnabled is set to 0. "
180 "We would ask you to please write to us on "
181 "tor-relays@lists.torproject.org or file a bug explaining "
182 "why you have disabled this option. Without news from you, "
183 "we might end up marking your relay as a BadExit.");
190 return conflux_enabled;
197 return max_linked_set;
207 if (exit_conflux_ratio <= 0.0) {
213 if (exit_conflux_ratio < low_exit_threshold_ratio) {
216 return max_prebuilt_set;
223 return max_unlinked_leg_retry;
244 return cfx_drain_pct;
262 CONFLUX_ENABLED_DEFAULT,
263 CONFLUX_ENABLED_MIN, CONFLUX_ENABLED_MAX);
265 low_exit_threshold_ratio =
267 LOW_EXIT_THRESHOLD_DEFAULT,
268 LOW_EXIT_THRESHOLD_MIN, LOW_EXIT_THRESHOLD_MAX) /
269 (double)LOW_EXIT_THRESHOLD_MAX;
273 MAX_LINKED_SET_DEFAULT,
274 MAX_LINKED_SET_MIN, MAX_LINKED_SET_MAX);
278 MAX_PREBUILT_SET_DEFAULT,
279 MAX_PREBUILT_SET_MIN, MAX_PREBUILT_SET_MAX);
281 max_unlinked_leg_retry =
283 MAX_UNLINKED_LEG_RETRY_DEFAULT,
284 MAX_UNLINKED_LEG_RETRY_MIN,
285 MAX_UNLINKED_LEG_RETRY_MAX);
289 NUM_LEGS_SET_DEFAULT,
290 NUM_LEGS_SET_MIN, NUM_LEGS_SET_MAX);
294 MAX_LEGS_SET_DEFAULT,
295 MAX_LEGS_SET_MIN, MAX_LEGS_SET_MAX);
308 count_exit_with_conflux_support(ns);
Header file for circuitlist.c.
#define CIRCUIT_IS_ORIGIN(c)
const or_options_t * get_options(void)
Header file for config.c.
Header file for conflux_params.c.
uint8_t conflux_params_get_send_pct(void)
uint8_t conflux_params_get_drain_pct(void)
uint8_t conflux_params_get_max_legs_set(void)
uint8_t conflux_params_get_max_prebuilt(void)
uint8_t conflux_params_get_max_unlinked_leg_retry(void)
uint8_t conflux_params_get_num_legs_set(void)
uint8_t conflux_params_get_max_linked_set(void)
void conflux_params_new_consensus(const networkstatus_t *ns)
bool congestion_control_enabled(void)
Public APIs for congestion control.
int32_t networkstatus_get_param(const networkstatus_t *ns, const char *param_name, int32_t default_val, int32_t min_val, int32_t max_val)
Header file for networkstatus.c.
Networkstatus consensus/vote structure.
Master header file for Tor-specific functionality.
Origin circuit structure.
char * rate_limit_log(ratelim_t *lim, time_t now)
int server_mode(const or_options_t *options)
Header file for routermode.c.
Routerstatus (consensus entry) structure.
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
struct congestion_control_t * ccontrol
smartlist_t * routerstatus_list