]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add torrc option for conflux client UX.
authorMike Perry <mikeperry-git@torproject.org>
Thu, 11 May 2023 17:57:00 +0000 (17:57 +0000)
committerMike Perry <mikeperry-git@torproject.org>
Thu, 11 May 2023 18:05:28 +0000 (18:05 +0000)
doc/man/tor.1.txt
src/app/config/config.c
src/app/config/or_options_st.h
src/core/or/conflux_pool.c

index 2ac6a8471c59aa03a3817d6d1dea21c27dde7cc5..c3bc053142acb3ad6d7f3ccab1ee1277aa0cd374 100644 (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
index 24321b764f3c1bef0ee4f9311de4330418e2fba2..e2de72c855fe6fbaf994cdf179fd8d8654f55bde 100644 (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;
 
index 056aa3b7764788027bae0e1760ccea23b4c05aef..c8680bb49e25a94ac258bd63c2d620f926a3cf63 100644 (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. */
index b02b23f24d3a9efbf4c2e99738709ba7906fd100..c84613503f0ccbb49ec60bf6b85cd5d324142cba 100644 (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++;