]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Implement an option to cap bandwidth-to-advertise. Arma: can you improve the manpage...
authorNick Mathewson <nickm@torproject.org>
Tue, 22 Mar 2005 19:01:46 +0000 (19:01 +0000)
committerNick Mathewson <nickm@torproject.org>
Tue, 22 Mar 2005 19:01:46 +0000 (19:01 +0000)
svn:r3813

doc/TODO
doc/tor.1.in
src/or/config.c
src/or/or.h
src/or/router.c

index 4b41c69f7389d676627247f92611bd10f9f8dbc7..0f19b860c60ccdb2a8197eca8dc8d3ac51ba721f 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -25,7 +25,7 @@ R  o pick the whole path when you start the circuit.
      they're rejected.
    - controller should have an event to learn about new addressmappings?
    - how do ulimits work on win32, anyway?
-   - have a separate config option which caps bandwidth-to-advertise.
+   o have a separate config option which caps bandwidth-to-advertise.
 
 For 0.1.0.x:
 
index 24760f9e076b3bf2161934b7b478d3696b627a4c..311a7f0e36551cc1384d1de94590f291e27a0094 100644 (file)
@@ -48,6 +48,10 @@ the specified number of bytes per second. (Default: 780 KB)
 \fBBandwidthBurst \fR\fIN\fR \fBbytes\fR|\fBKB\fR|\fBMB\fR|\fBGB\fR|\fBTB\fP
 Limit the maximum token bucket size (also known as the burst) to the given number of bytes. (Default: 48 MB)
 .TP
+\fBMaxAdvertisedBandwidth \fR\fIN\fR \fBbytes\fR|\fBKB\fR|\fBMB\fR|\fBGB\fR|\fBTB\fP
+If set, we will not advertise more than this amount of bandwidth, no
+matter how much we think we actually have.
+.TP
 \fBDataDirectory \fR\fIDIR\fP
 Store working data in DIR (Default: @LOCALSTATEDIR@/lib/tor)
 .TP
index 09e6183e40ec4f45a982f62e2375e320fdbaea59..3b283b7d6dd9d66fab64aa7574ca7d4ca1fc65c9 100644 (file)
@@ -99,6 +99,7 @@ static config_var_t config_vars[] = {
   VAR("AuthoritativeDirectory",BOOL,   AuthoritativeDir,     "0"),
   VAR("BandwidthRate",       MEMUNIT,  BandwidthRate,        "1 MB"),
   VAR("BandwidthBurst",      MEMUNIT,  BandwidthBurst,       "5 MB"),
+  VAR("MaxAdvertisedBandwidth",MEMUNIT,MaxAdvertisedBandwidth,"128 TB"),
   VAR("ClientOnly",          BOOL,     ClientOnly,           "0"),
   VAR("ContactInfo",         STRING,   ContactInfo,          NULL),
   VAR("ControlPort",         UINT,     ControlPort,          "0"),
index 603aeb31a1b952ecfff553b442a764019aa7c909..19efee27600dfa71ced66ddfb2c80e8e032081a3 100644 (file)
@@ -1019,6 +1019,8 @@ typedef struct {
                            * use in a second? */
   uint64_t BandwidthBurst; /**< How much bandwidth, at maximum, are we willing to
                             * use in a second? */
+  uint64_t MaxAdvertisedBandwidth; /**< How much bandwidth are we willing to
+                                    * tell people we have? */
   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. */
index 6ebce129b1494d8e8d541b6e9697fdff7e48a3dc..4f786a2aad3848a0bb73ee7a34e04d964c12bee5 100644 (file)
@@ -684,6 +684,12 @@ int router_rebuild_descriptor(int force) {
   ri->bandwidthrate = (int)options->BandwidthRate;
   ri->bandwidthburst = (int)options->BandwidthBurst;
   ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess();
+
+  if (options->BandwidthRate > options->MaxAdvertisedBandwidth)
+    ri->bandwidthrate = (int)options->MaxAdvertisedBandwidth;
+  if (ri->bandwidthcapacity > options->MaxAdvertisedBandwidth)
+    ri->bandwidthcapacity = (int)options->MaxAdvertisedBandwidth;
+
   router_add_exit_policy_from_config(ri);
   if (desc_routerinfo) /* inherit values */
     ri->is_verified = desc_routerinfo->is_verified;