[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Make clients look at the fast and stable flags in networkst...
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv25624/src/or
Modified Files:
dirserv.c or.h routerlist.c
Log Message:
Make clients look at the fast and stable flags in networkstatus, not at the bandwidth and uptime declared in the router descriptors.
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.280
retrieving revision 1.281
diff -u -d -r1.280 -r1.281
--- dirserv.c 15 Dec 2005 21:17:40 -0000 1.280
+++ dirserv.c 15 Dec 2005 21:30:57 -0000 1.281
@@ -1219,6 +1219,23 @@
the_v2_networkstatus_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL);
}
+/** Return 1 if <b>router</b> is not suitable for these parameters, else 0.
+ * If <b>need_uptime</b> is non-zero, we require a minimum uptime.
+ * If <b>need_capacity</b> is non-zero, we require a minimum advertised
+ * bandwidth.
+ */
+static int
+dirserv_thinks_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_capacity &&
+ router->bandwidthcapacity < ROUTER_REQUIRED_MIN_BANDWIDTH)
+ return 1;
+ return 0;
+}
+
/** For authoritative directories only: replace the contents of
* <b>the_v2_networkstatus</b> with a newly generated network status
* object. */
@@ -1309,8 +1326,8 @@
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
int f_exit = router_is_general_exit(ri);
- int f_stable = !router_is_unreliable(ri, 1, 0);
- int f_fast = !router_is_unreliable(ri, 0, 1);
+ int f_stable = !dirserv_thinks_router_is_unreliable(ri, 1, 0);
+ int f_fast = !dirserv_thinks_router_is_unreliable(ri, 0, 1);
int f_running;
int f_authority = router_digest_is_trusted_dir(
ri->cache_info.identity_digest);
@@ -1324,6 +1341,8 @@
char digest64[BASE64_DIGEST_LEN+1];
if (options->AuthoritativeDir) {
ri->is_running = dirserv_thinks_router_is_reachable(ri, now);
+ ri->is_fast = f_fast;
+ ri->is_stable = f_stable;
}
f_running = ri->is_running;
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.760
retrieving revision 1.761
diff -u -d -r1.760 -r1.761
--- or.h 15 Dec 2005 21:17:40 -0000 1.760
+++ or.h 15 Dec 2005 21:30:57 -0000 1.761
@@ -795,6 +795,8 @@
*/
unsigned int is_named:1; /**< Do we believe the nickname that this OR gives
* us? */
+ unsigned int is_fast:1; /** Do we think this is a fast OR? */
+ unsigned int is_stable:1; /** Do we think this is a stable OR? */
unsigned int xx_is_recognized:1; /**< Temporary: do we think that this
* descriptor's digest is recognized?
*/
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.397
retrieving revision 1.398
diff -u -d -r1.397 -r1.398
--- routerlist.c 15 Dec 2005 21:26:52 -0000 1.397
+++ routerlist.c 15 Dec 2005 21:30:57 -0000 1.398
@@ -716,10 +716,9 @@
int
router_is_unreliable(routerinfo_t *router, int need_uptime, int need_capacity)
{
- if (need_uptime && router->uptime < ROUTER_REQUIRED_MIN_UPTIME)
+ if (need_uptime && !router->is_stable)
return 1;
- if (need_capacity &&
- router->bandwidthcapacity < ROUTER_REQUIRED_MIN_BANDWIDTH)
+ if (need_capacity && !router->is_fast)
return 1;
return 0;
}
@@ -3017,6 +3016,8 @@
/* If we're an authdir, don't believe others. */
router->is_verified = rs->status.is_valid;
router->is_running = rs->status.is_running;
+ router->is_fast = rs->status.is_fast;
+ router->is_stable = rs->is_stable;
}
if (router->is_running && ds) {
ds->n_networkstatus_failures = 0;