summaryrefslogtreecommitdiff
path: root/src/or/connection_or.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2009-12-29 23:13:03 -0500
committerRoger Dingledine <arma@torproject.org>2009-12-29 23:13:03 -0500
commit4d71d437726692ee65bdb7c2968a65de6ba3f786 (patch)
treecf481fefb088775a129e7db249c1bcefdf242f02 /src/or/connection_or.c
parentf255272f45a2ae563862a14d3862b81d0ffee72f (diff)
downloadtor-4d71d437726692ee65bdb7c2968a65de6ba3f786.tar.gz
tor-4d71d437726692ee65bdb7c2968a65de6ba3f786.zip
add config options to override.
somebody should add man page entries.
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r--src/or/connection_or.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 13a5953576..1aa0bb35b7 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -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);