]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
add config options to override.
authorRoger Dingledine <arma@torproject.org>
Wed, 30 Dec 2009 04:13:03 +0000 (23:13 -0500)
committerRoger Dingledine <arma@torproject.org>
Wed, 30 Dec 2009 04:13:03 +0000 (23:13 -0500)
somebody should add man page entries.

src/or/config.c
src/or/connection_or.c
src/or/or.h

index ff0611eff446bb3d317fb2cab66690fbc9c60f9b..6e2e29c4f471e0e2b71c1f248e7f5672a3450be2 100644 (file)
@@ -284,6 +284,8 @@ static config_var_t _option_vars[] = {
   V(ORPort,                      UINT,     "0"),
   V(OutboundBindAddress,         STRING,   NULL),
   OBSOLETE("PathlenCoinWeight"),
+  V(PerConnBWBurst,              MEMUNIT,  "0"),
+  V(PerConnBWRate,               MEMUNIT,  "0"),
   V(PidFile,                     STRING,   NULL),
   V(TestingTorNetwork,           BOOL,     "0"),
   V(PreferTunneledDirConns,      BOOL,     "1"),
index 13a595357658ff55db7757958eac26906260279c..1aa0bb35b77c5fbc3a86e24a599647fc3625508c 100644 (file)
@@ -343,6 +343,7 @@ connection_or_init_conn_from_address(or_connection_t *conn,
                                      int started_here)
 {
   or_options_t *options = get_options();
+  int rate, burst; /* per-connection rate limiting params */
   routerinfo_t *r = router_get_by_digest(id_digest);
   connection_or_set_identity_digest(conn, id_digest);
 
@@ -350,19 +351,23 @@ connection_or_init_conn_from_address(or_connection_t *conn,
     /* It's in the consensus, or we have a descriptor for it meaning it
      * was probably in a recent consensus. It's a recognized relay:
      * give it full bandwidth. */
-    conn->bandwidthrate = (int)options->BandwidthRate;
-    conn->read_bucket = conn->bandwidthburst = (int)options->BandwidthBurst;
-    conn->write_bucket = conn->bandwidthburst = (int)options->BandwidthBurst;
-  } else { /* Not a recognized relay. Squeeze it down based on the
-            * suggested bandwidth parameters in the consensus. */
-    conn->bandwidthrate =
-      (int)networkstatus_get_param(NULL, "bwconnrate",
-                                   (int)options->BandwidthRate);
-    conn->read_bucket = conn->write_bucket = conn->bandwidthburst =
-      (int)networkstatus_get_param(NULL, "bwconnburst",
-                                   (int)options->BandwidthBurst);
+    rate = (int)options->BandwidthRate;
+    burst = (int)options->BandwidthBurst;
+  } else {
+    /* Not a recognized relay. Squeeze it down based on the suggested
+     * bandwidth parameters in the consensus, but allow local config
+     * options to override. */
+    rate = options->PerConnBWRate ? (int)options->PerConnBWRate :
+        (int)networkstatus_get_param(NULL, "bwconnrate",
+                                     (int)options->BandwidthRate);
+    burst = options->PerConnBWBurst ? (int)options->PerConnBWBurst :
+        (int)networkstatus_get_param(NULL, "bwconnburst",
+                                     (int)options->BandwidthBurst);
   }
 
+  conn->bandwidthrate = rate;
+  conn->read_bucket = conn->write_bucket = conn->bandwidthburst = burst;
+
   conn->_base.port = port;
   tor_addr_copy(&conn->_base.addr, addr);
   tor_addr_copy(&conn->real_addr, addr);
index cd9b905dc5f25affbfb1b00ae84e76eaa97e39f5..091d819f792704ac76c6015c93425d7364a274f0 100644 (file)
@@ -2513,6 +2513,8 @@ typedef struct {
                                  * willing to use for all relayed conns? */
   uint64_t RelayBandwidthBurst; /**< How much bandwidth, at maximum, will we
                                  * use in a second for all relayed conns? */
+  uint64_t PerConnBWRate; /**< Long-term bw on a single TLS conn, if set. */
+  uint64_t PerConnBWBurst; /**< Allowed burst on a single TLS conn, if set. */
   int NumCpus; /**< How many CPUs should we try to use? */
   int RunTesting; /**< If true, create testing circuits to measure how well the
                    * other ORs are running. */