]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r13982@catbus: nickm | 2007-07-29 01:31:53 -0400
authorNick Mathewson <nickm@torproject.org>
Sun, 29 Jul 2007 05:32:03 +0000 (05:32 +0000)
committerNick Mathewson <nickm@torproject.org>
Sun, 29 Jul 2007 05:32:03 +0000 (05:32 +0000)
 Actually, we missed a rule about what routers to prefer: first prefer authority to non-authority, *then* running, *then* bandwidth.

svn:r10969

doc/spec/dir-spec-v2.txt
doc/spec/dir-spec.txt
src/or/dirserv.c

index 553e565cc55192335f8d896ca9dc3aac74770453..7f71f8f071a2dc6c1a3cf665e866e9f1c5a37893 100644 (file)
@@ -482,11 +482,11 @@ $Id$
    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.
index 1900fe3716ec290bd1156a45a06a54174862da08..a7b2e5d803ed504f1cf1ad65b3903be3623f10a0 100644 (file)
@@ -968,11 +968,11 @@ $Id$
    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.
index 0a7a5f01af62743794e0d47e382bff03f4a339f5..bf818d01eb2632094611450e78efa0b6049dc6b3 100644 (file)
@@ -1727,16 +1727,30 @@ static int
 _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)