|
@@ -349,21 +349,17 @@ connection_or_digest_is_known_relay(const char *id_digest)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-/** If we don't necessarily know the router we're connecting to, but we
|
|
|
- * have an addr/port/id_digest, then fill in as much as we can. Start
|
|
|
- * by checking to see if this describes a router we know. */
|
|
|
-static void
|
|
|
-connection_or_init_conn_from_address(or_connection_t *conn,
|
|
|
- const tor_addr_t *addr, uint16_t port,
|
|
|
- const char *id_digest,
|
|
|
- int started_here)
|
|
|
+/** Set the per-conn read and write limits for <b>conn</b>. If it's a known
|
|
|
+ * relay, we will rely on the global read and write buckets, so give it
|
|
|
+ * per-conn limits that are big enough they'll never matter. But if it's
|
|
|
+ * not a known relay, first check if we set PerConnBwRate/Burst, then
|
|
|
+ * check if the consensus sets them, else default to 'big enough'.
|
|
|
+ */
|
|
|
+static void connection_or_set_rate_burst(or_connection_t *conn,
|
|
|
+ or_options_t *options)
|
|
|
{
|
|
|
- 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);
|
|
|
-
|
|
|
- if (connection_or_digest_is_known_relay(id_digest)) {
|
|
|
+ if (connection_or_digest_is_known_relay(conn->identity_digest)) {
|
|
|
/* 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. */
|
|
@@ -383,6 +379,20 @@ connection_or_init_conn_from_address(or_connection_t *conn,
|
|
|
|
|
|
conn->bandwidthrate = rate;
|
|
|
conn->read_bucket = conn->write_bucket = conn->bandwidthburst = burst;
|
|
|
+}
|
|
|
+
|
|
|
+/** If we don't necessarily know the router we're connecting to, but we
|
|
|
+ * have an addr/port/id_digest, then fill in as much as we can. Start
|
|
|
+ * by checking to see if this describes a router we know. */
|
|
|
+static void
|
|
|
+connection_or_init_conn_from_address(or_connection_t *conn,
|
|
|
+ const tor_addr_t *addr, uint16_t port,
|
|
|
+ const char *id_digest,
|
|
|
+ int started_here)
|
|
|
+{
|
|
|
+ routerinfo_t *r = router_get_by_digest(id_digest);
|
|
|
+ connection_or_set_identity_digest(conn, id_digest);
|
|
|
+ connection_or_set_rate_burst(conn, get_options());
|
|
|
|
|
|
conn->_base.port = port;
|
|
|
tor_addr_copy(&conn->_base.addr, addr);
|