aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerlist.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2005-01-12 04:58:23 +0000
committerRoger Dingledine <arma@torproject.org>2005-01-12 04:58:23 +0000
commit84c81e07838f5966f7a949df9b8f7d5bbb72d62e (patch)
tree9c3f159d592f1a9615fb2608cd23e6921dd54d4f /src/or/routerlist.c
parent51f47d746e602b4043b054acb733e9e389361c30 (diff)
downloadtor-84c81e07838f5966f7a949df9b8f7d5bbb72d62e.tar
tor-84c81e07838f5966f7a949df9b8f7d5bbb72d62e.tar.gz
Annotate circuits w/ whether they aim to contain high uptime nodes and/or
high capacity nodes. When building circuits, choose appropriate nodes. New config option LongLivedPorts to indicate application streams that will want high uptime circuits. When attaching a stream to a circuit, pay attention to its requirements. This means that every single node in an intro rend circuit, not just the last one, will have a minimum uptime. Boost the min uptime from an hour to 24 hours. svn:r3339
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r--src/or/routerlist.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index c25eeaab0..b78828bc4 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -166,7 +166,6 @@ router_pick_directory_server_impl(int requireothers, int fascistfirewall,
int i;
routerinfo_t *router;
smartlist_t *sl;
- char buf[16];
if (!routerlist)
return NULL;
@@ -183,8 +182,7 @@ router_pick_directory_server_impl(int requireothers, int fascistfirewall,
if (requireothers && router_is_me(router))
continue;
if (fascistfirewall) {
- tor_snprintf(buf,sizeof(buf),"%d",router->dir_port);
- if (!smartlist_string_isin(get_options()->FirewallPorts, buf))
+ if (!smartlist_string_num_isin(get_options()->FirewallPorts, router->dir_port))
continue;
}
/* before 0.0.9rc5-cvs, only trusted dirservers served status info. */
@@ -205,7 +203,6 @@ router_pick_trusteddirserver_impl(int requireother, int fascistfirewall)
{
smartlist_t *sl;
routerinfo_t *me;
- char buf[16];
trusted_dir_server_t *ds;
sl = smartlist_create();
me = router_get_my_routerinfo();
@@ -223,8 +220,7 @@ router_pick_trusteddirserver_impl(int requireother, int fascistfirewall)
!memcmp(me->identity_digest, d->digest, DIGEST_LEN))
continue;
if (fascistfirewall) {
- tor_snprintf(buf,sizeof(buf),"%d",d->dir_port);
- if (!smartlist_string_isin(get_options()->FirewallPorts, buf))
+ if (!smartlist_string_num_isin(get_options()->FirewallPorts, d->dir_port))
continue;
}
smartlist_add(sl, d);
@@ -360,7 +356,7 @@ router_nickname_is_in_list(routerinfo_t *router, const char *list)
*/
static void
router_add_running_routers_to_smartlist(smartlist_t *sl, int allow_unverified,
- int preferuptime, int preferbandwidth)
+ int need_uptime, int need_capacity)
{
routerinfo_t *router;
int i;
@@ -373,7 +369,7 @@ router_add_running_routers_to_smartlist(smartlist_t *sl, int allow_unverified,
if (router->is_running &&
(router->is_verified ||
(allow_unverified &&
- !router_is_unreliable_router(router, preferuptime, preferbandwidth)))) {
+ !router_is_unreliable(router, need_uptime, need_capacity)))) {
/* If it's running, and either it's verified or we're ok picking
* unverified routers and this one is suitable.
*/
@@ -399,11 +395,11 @@ routerlist_find_my_routerinfo(void) {
}
int
-router_is_unreliable_router(routerinfo_t *router, int need_uptime, int need_bw)
+router_is_unreliable(routerinfo_t *router, int need_uptime, int need_capacity)
{
if (need_uptime && router->uptime < ROUTER_REQUIRED_MIN_UPTIME)
return 1;
- if (need_bw && router->bandwidthcapacity < ROUTER_REQUIRED_MIN_BANDWIDTH)
+ if (need_capacity && router->bandwidthcapacity < ROUTER_REQUIRED_MIN_BANDWIDTH)
return 1;
return 0;
}
@@ -416,7 +412,7 @@ routerlist_sl_remove_unreliable_routers(smartlist_t *sl)
for (i = 0; i < smartlist_len(sl); ++i) {
router = smartlist_get(sl, i);
- if (router_is_unreliable_router(router, 1, 0)) {
+ if (router_is_unreliable(router, 1, 0)) {
log(LOG_DEBUG, "Router '%s' has insufficient uptime; deleting.",
router->nickname);
smartlist_del(sl, i--);
@@ -480,7 +476,7 @@ routerlist_sl_choose_by_bandwidth(smartlist_t *sl)
routerinfo_t *router_choose_random_node(const char *preferred,
const char *excluded,
smartlist_t *excludedsmartlist,
- int preferuptime, int preferbandwidth,
+ int need_uptime, int need_capacity,
int allow_unverified, int strict)
{
smartlist_t *sl, *excludednodes;
@@ -495,9 +491,9 @@ routerinfo_t *router_choose_random_node(const char *preferred,
smartlist_subtract(sl,excludednodes);
if (excludedsmartlist)
smartlist_subtract(sl,excludedsmartlist);
- if (preferuptime)
+ if (need_uptime)
routerlist_sl_remove_unreliable_routers(sl);
- if (preferbandwidth)
+ if (need_capacity)
choice = routerlist_sl_choose_by_bandwidth(sl);
else
choice = smartlist_choose(sl);
@@ -505,13 +501,13 @@ routerinfo_t *router_choose_random_node(const char *preferred,
if (!choice && !strict) {
sl = smartlist_create();
router_add_running_routers_to_smartlist(sl, allow_unverified,
- preferuptime, preferbandwidth);
+ need_uptime, need_capacity);
smartlist_subtract(sl,excludednodes);
if (excludedsmartlist)
smartlist_subtract(sl,excludedsmartlist);
- if (preferuptime)
+ if (need_uptime)
routerlist_sl_remove_unreliable_routers(sl);
- if (preferbandwidth)
+ if (need_capacity)
choice = routerlist_sl_choose_by_bandwidth(sl);
else
choice = smartlist_choose(sl);
@@ -1007,16 +1003,19 @@ int router_compare_addr_to_addr_policy(uint32_t addr, uint16_t port,
return maybe_reject ? ADDR_POLICY_UNKNOWN : ADDR_POLICY_ACCEPTED;
}
-/** Return 1 if all running routers will reject addr:port, return 0 if
- * any might accept it. */
-int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port) {
+/** Return 1 if all running sufficiently-stable routers will reject
+ * addr:port, return 0 if any might accept it. */
+int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port,
+ int need_uptime) {
int i;
routerinfo_t *router;
if (!routerlist) return 1;
for (i=0;i<smartlist_len(routerlist->routers);i++) {
router = smartlist_get(routerlist->routers, i);
- if (router->is_running && router_compare_addr_to_addr_policy(
+ if (router->is_running &&
+ !router_is_unreliable(router, need_uptime, 0) &&
+ router_compare_addr_to_addr_policy(
addr, port, router->exit_policy) != ADDR_POLICY_REJECTED)
return 0; /* this one could be ok. good enough. */
}