[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r10969: Actually, we missed a rule about what routers to prefer: fir (in tor/trunk: . doc/spec src/or)



Author: nickm
Date: 2007-07-29 01:32:03 -0400 (Sun, 29 Jul 2007)
New Revision: 10969

Modified:
   tor/trunk/
   tor/trunk/doc/spec/dir-spec-v2.txt
   tor/trunk/doc/spec/dir-spec.txt
   tor/trunk/src/or/dirserv.c
Log:
 r13982@catbus:  nickm | 2007-07-29 01:31:53 -0400
 Actually, we missed a rule about what routers to prefer: first prefer authority to non-authority, *then* running, *then* bandwidth.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13982] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/doc/spec/dir-spec-v2.txt
===================================================================
--- tor/trunk/doc/spec/dir-spec-v2.txt	2007-07-29 05:20:31 UTC (rev 10968)
+++ tor/trunk/doc/spec/dir-spec-v2.txt	2007-07-29 05:32:03 UTC (rev 10969)
@@ -482,11 +482,11 @@
    Directory server administrators may label some servers or IPs as
    blacklisted, and elect not to include them in their network-status lists.
 
-   Authorities SHOULD 'disable' any servers in excess of 3 on any single
-   IP.  When there are more than 3 to choose from, authorities should first
-   prefer Running to non-Running, and then prefer high-bandwidth to
-   low-bandwidth.  To 'disable' a server, the authority *should* advertise
-   it without the Running or Valid flag.
+   Authorities SHOULD 'disable' any servers in excess of 3 on any single IP.
+   When there are more than 3 to choose from, authorities should first prefer
+   authorities to non-authorities, then prefer Running to non-Running, and
+   then prefer high-bandwidth to low-bandwidth.  To 'disable' a server, the
+   authority *should* advertise it without the Running or Valid flag.
 
    Thus, the network-status list includes all non-blacklisted,
    non-expired, non-superseded descriptors.

Modified: tor/trunk/doc/spec/dir-spec.txt
===================================================================
--- tor/trunk/doc/spec/dir-spec.txt	2007-07-29 05:20:31 UTC (rev 10968)
+++ tor/trunk/doc/spec/dir-spec.txt	2007-07-29 05:32:03 UTC (rev 10969)
@@ -968,11 +968,11 @@
    Directory server administrators may label some servers or IPs as
    blacklisted, and elect not to include them in their network-status lists.
 
-   Authorities SHOULD 'disable' any servers in excess of 3 on any single
-   IP.  When there are more than 3 to choose from, authorities should first
-   prefer Running to non-Running, and then prefer high-bandwidth to
-   low-bandwidth.  To 'disable' a server, the authority *should* advertise
-   it without the Running or Valid flag.
+   Authorities SHOULD 'disable' any servers in excess of 3 on any single IP.
+   When there are more than 3 to choose from, authorities should first prefer
+   authorities to non-authorities, then prefer Running to non-Running, and
+   then prefer high-bandwidth to low-bandwidth.  To 'disable' a server, the
+   authority *should* advertise it without the Running or Valid flag.
 
    Thus, the network-status vote includes all non-blacklisted,
    non-expired, non-superseded descriptors.

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2007-07-29 05:20:31 UTC (rev 10968)
+++ tor/trunk/src/or/dirserv.c	2007-07-29 05:32:03 UTC (rev 10969)
@@ -1727,16 +1727,30 @@
 _compare_routerinfo_by_ip_and_bw(const void **a, const void **b)
 {
   routerinfo_t *first = *(routerinfo_t **)a, *second = *(routerinfo_t **)b;
+  int first_is_auth, second_is_auth;
+
   /* we return -1 if first should appear before second... that is,
    * if first is a better router. */
   if (first->addr < second->addr)
     return -1;
   else if (first->addr > second->addr)
     return 1;
+
+  first_is_auth =
+    router_digest_is_trusted_dir(first->cache_info.identity_digest);
+  second_is_auth =
+    router_digest_is_trusted_dir(second->cache_info.identity_digest);
+
+  if (first_is_auth && !second_is_auth)
+    return -1;
+  else if (!first_is_auth && second_is_auth)
+    return 1;
+
   else if (first->is_running && !second->is_running)
     return -1;
   else if (!first->is_running && second->is_running)
     return 1;
+
   else if (first->bandwidthrate > second->bandwidthrate)
     return -1;
   else if (first->bandwidthrate < second->bandwidthrate)