Add torrc option for conflux client UX.

This commit is contained in:
Mike Perry 2023-05-11 17:57:00 +00:00
parent 0c11577987
commit 79dab29a05
4 changed files with 50 additions and 3 deletions

View File

@ -354,6 +354,13 @@ forward slash (/) in the configuration file and on the command line.
supported at the moment. Default value is set to "auto" meaning the
consensus is used to decide unless set. (Default: auto)
[[ConfluxClientUX]] **ConfluxClientUX** **throughput**|**latency**|**throughput_lowmem**|**latency_lowmem**::
This option configures the user experience that the client requests from
the exit, for data that the exit sends to the client. The default is
"throughput", which maximizes throughput. "Latency" will tell the exit to
only use the circuit with lower latency for all data. The lowmem versions
minimize queue usage memory at the client. (Default: "throughput")
[[ConnLimit]] **ConnLimit** __NUM__::
The minimum number of file descriptors that must be available to the Tor
process before it will start. Tor will ask the OS for as many file

View File

@ -77,6 +77,7 @@
#include "core/or/circuitmux_ewma.h"
#include "core/or/circuitstats.h"
#include "core/or/connection_edge.h"
#include "trunnel/conflux.h"
#include "core/or/dos.h"
#include "core/or/policies.h"
#include "core/or/relay.h"
@ -380,6 +381,8 @@ static const config_var_t option_vars_[] = {
V(ClientUseIPv6, BOOL, "0"),
V(ClientUseIPv4, BOOL, "1"),
V(ConfluxEnabled, AUTOBOOL, "auto"),
VAR("ConfluxClientUX", STRING, ConfluxClientUX_option,
"throughput"),
V(ConnLimit, POSINT, "1000"),
V(ConnDirectionStatistics, BOOL, "0"),
V(ConstrainedSockets, BOOL, "0"),
@ -3545,6 +3548,21 @@ options_validate_cb(const void *old_options_, void *options_, char **msg)
return -1;
}
options->ConfluxClientUX = CONFLUX_UX_HIGH_THROUGHPUT;
if (options->ConfluxClientUX_option) {
if (!strcmp(options->ConfluxClientUX_option, "latency"))
options->ConfluxClientUX = CONFLUX_UX_MIN_LATENCY;
else if (!strcmp(options->ConfluxClientUX_option, "throughput"))
options->ConfluxClientUX = CONFLUX_UX_HIGH_THROUGHPUT;
else if (!strcmp(options->ConfluxClientUX_option, "latency_lowmem"))
options->ConfluxClientUX = CONFLUX_UX_LOW_MEM_LATENCY;
else if (!strcmp(options->ConfluxClientUX_option, "throughput_lowmem"))
options->ConfluxClientUX = CONFLUX_UX_LOW_MEM_THROUGHPUT;
else
REJECT("ConfluxClientUX must be 'latency', 'throughput, "
"'latency_lowmem', or 'throughput_lowmem'");
}
if (options_validate_publish_server(old_options, options, msg) < 0)
return -1;

View File

@ -727,6 +727,10 @@ struct or_options_t {
* circuits which excludes onion service traffic. */
int ConfluxEnabled;
/** Has the UX integer value that the client will request from the exit. */
char *ConfluxClientUX_option;
int ConfluxClientUX;
/** The length of time that we think a consensus should be fresh. */
int V3AuthVotingInterval;
/** The length of time we think it will take to distribute votes. */

View File

@ -36,6 +36,7 @@
#include "feature/nodelist/nodelist.h"
#include "feature/client/bridges.h"
#include "app/config/config.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
@ -1022,6 +1023,24 @@ get_exit_for_nonce(const uint8_t *nonce)
return exit;
}
/**
* Return the currently configured client UX.
*/
static uint8_t
get_client_ux(void)
{
#ifdef TOR_UNIT_TESTS
return DEFAULT_CLIENT_UX;
#else
const or_options_t *opt = get_options();
tor_assert(opt);
(void)DEFAULT_CLIENT_UX;
/* Return the UX */
return opt->ConfluxClientUX;
#endif
}
/** Return true iff the given conflux object is allowed to launch a new leg. If
* the cfx object is NULL, then it is always allowed to launch a new leg. */
static bool
@ -1111,12 +1130,11 @@ conflux_launch_leg(const uint8_t *nonce)
// arti-relay could (if resumption seems worthwhile; it may not be worth the
// memory storage there, either).
/* We have a circuit, create the new leg and attach it to the set.
* TODO-329-TUNING: Should we make a torrc option to request min latency? */
/* We have a circuit, create the new leg and attach it to the set. */
leg_t *leg = leg_new(TO_CIRCUIT(circ),
conflux_cell_new_link(nonce,
last_seq_sent, last_seq_recv,
DEFAULT_CLIENT_UX));
get_client_ux()));
/* Increase the retry count for this conflux object as in this nonce. */
unlinked->cfx->num_leg_launch++;