aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-03-22 19:01:46 +0000
committerNick Mathewson <nickm@torproject.org>2005-03-22 19:01:46 +0000
commitec81f870181940909507fd5356fa5ecc11c7440e (patch)
tree81e3f8c5afc9d6622e3813c328a4eb34a7edaa00 /src
parent2d662bf773fd9b73c2698f9ddb2e473df180a8e9 (diff)
downloadtor-ec81f870181940909507fd5356fa5ecc11c7440e.tar.gz
tor-ec81f870181940909507fd5356fa5ecc11c7440e.zip
Implement an option to cap bandwidth-to-advertise. Arma: can you improve the manpage entry by explaining why you would want to do this?
svn:r3813
Diffstat (limited to 'src')
-rw-r--r--src/or/config.c1
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/router.c6
3 files changed, 9 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 09e6183e40..3b283b7d6d 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -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"),
diff --git a/src/or/or.h b/src/or/or.h
index 603aeb31a1..19efee2760 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -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. */
diff --git a/src/or/router.c b/src/or/router.c
index 6ebce129b1..4f786a2aad 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -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;