[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Implement an option to cap bandwidth-to-advertise. Arma: ca...



Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv22026/src/or

Modified Files:
	config.c or.h router.c 
Log Message:
Implement an option to cap bandwidth-to-advertise. Arma: can you improve the manpage entry by explaining why you would want to do this?

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.325
retrieving revision 1.326
diff -u -d -r1.325 -r1.326
--- config.c	17 Mar 2005 12:38:35 -0000	1.325
+++ config.c	22 Mar 2005 19:01:46 -0000	1.326
@@ -99,6 +99,7 @@
   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: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.566
retrieving revision 1.567
diff -u -d -r1.566 -r1.567
--- or.h	22 Mar 2005 18:43:24 -0000	1.566
+++ or.h	22 Mar 2005 19:01:46 -0000	1.567
@@ -1019,6 +1019,8 @@
                            * 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: router.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -d -r1.157 -r1.158
--- router.c	22 Mar 2005 06:08:28 -0000	1.157
+++ router.c	22 Mar 2005 19:01:46 -0000	1.158
@@ -684,6 +684,12 @@
   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;