]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
If EntryNodes and ExcludeNodes overlap, obey ExcludeNodes.
authorRoger Dingledine <arma@torproject.org>
Sat, 17 Oct 2009 22:54:20 +0000 (18:54 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 27 Apr 2011 03:53:49 +0000 (23:53 -0400)
src/or/circuitbuild.c
src/or/config.c
src/or/or.h
src/or/routerlist.c
src/or/routerlist.h

index 2d4d5c032a281941eee12776117f6a8542b749e0..ebbda211db977b9c98e46fdf54d702dc97070251 100644 (file)
@@ -2938,6 +2938,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
            description,exit->nickname,
            rs==options->ExcludeNodes?"":" or ExcludeExitNodes",
            (int)purpose);
+    /* XXX022-1090 "using anyway" is freaking people out -RD */
     circuit_log_path(LOG_WARN, domain, circ);
   }
 
@@ -3979,7 +3980,8 @@ entry_guards_prepend_from_config(or_options_t *options)
    *  Perhaps we should do this calculation once whenever the list of routers
    *  changes or the entrynodes setting changes.
    */
-  routerset_get_all_routers(entry_routers, options->EntryNodes, 0);
+  routerset_get_all_routers(entry_routers, options->EntryNodes,
+                            options->ExcludeNodes, 0);
   SMARTLIST_FOREACH(entry_routers, routerinfo_t *, ri,
                     smartlist_add(entry_fps,ri->cache_info.identity_digest));
   SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e, {
@@ -4155,7 +4157,7 @@ choose_random_entry(cpath_build_state_t *state)
       goto retry;
     }
     if (!r && entry_list_is_constrained(options) && consider_exit_family) {
-      /* still no? if we're using bridges or have strictentrynodes
+      /* still no? if we're using bridges or have StrictNodes
        * set, and our chosen exit is in the same family as all our
        * bridges/entry guards, then be flexible about families. */
       consider_exit_family = 0;
index 9675c73c998e5af18701c87735285dd8e25f3ee4..bd904dcf0b249b514daa9741fff14b254ab1fd4b 100644 (file)
@@ -1412,7 +1412,8 @@ options_act(or_options_t *old_options)
   /* Check if we need to parse and add the EntryNodes config option. */
   if (options->EntryNodes &&
       (!old_options ||
-      (!routerset_equal(old_options->EntryNodes,options->EntryNodes))))
+       !routerset_equal(old_options->EntryNodes,options->EntryNodes) ||
+       !routerset_equal(old_options->ExcludeNodes,options->ExcludeNodes)))
     entry_nodes_should_be_added();
 
   /* Since our options changed, we might need to regenerate and upload our
index 06e6d7fc8fc49277b592a27ba44f909c7b01602a..50a1223f3c87ad20c18fc51af5bd0d50b3cd6b78 100644 (file)
@@ -2387,7 +2387,7 @@ typedef struct {
                                  * ORs not to consider as exits. */
 
   /** Union of ExcludeNodes and ExcludeExitNodes */
-  struct routerset_t *_ExcludeExitNodesUnion;
+  routerset_t *_ExcludeExitNodesUnion;
 
   int DisableAllSwap; /**< Boolean: Attempt to call mlockall() on our
                        * process for all current and future memory. */
@@ -3487,7 +3487,7 @@ typedef struct trusted_dir_server_t {
 
 #define ROUTER_MAX_DECLARED_BANDWIDTH INT32_MAX
 
-/* Flags for pick_directory_server and pick_trusteddirserver. */
+/* Flags for pick_directory_server() and pick_trusteddirserver(). */
 /** Flag to indicate that we should not automatically be willing to use
  * ourself to answer a directory request.
  * Passed to router_pick_directory_server (et al).*/
index c02654feef240bb278728910888673fd05073fe2..5d9ab8cbaca629b2a6f60bc1e987c5c05dc3d0f9 100644 (file)
@@ -5516,10 +5516,11 @@ routerset_contains_routerstatus(const routerset_t *set, routerstatus_t *rs)
 }
 
 /** Add every known routerinfo_t that is a member of <b>routerset</b> to
- * <b>out</b>.  If <b>running_only</b>, only add the running ones. */
+ * <b>out</b>, but never add any that are part of <b>excludeset</b>.
+ * If <b>running_only</b>, only add the running ones. */
 void
 routerset_get_all_routers(smartlist_t *out, const routerset_t *routerset,
-                          int running_only)
+                          const routerset_t *excludeset, int running_only)
 {
   tor_assert(out);
   if (!routerset || !routerset->list)
@@ -5529,12 +5530,13 @@ routerset_get_all_routers(smartlist_t *out, const routerset_t *routerset,
   if (routerset_is_list(routerset)) {
 
     /* No routers are specified by type; all are given by name or digest.
-     * we can do a lookup in O(len(list)). */
+     * we can do a lookup in O(len(routerset)). */
     SMARTLIST_FOREACH(routerset->list, const char *, name, {
         routerinfo_t *router = router_get_by_nickname(name, 1);
         if (router) {
           if (!running_only || router->is_running)
-            smartlist_add(out, router);
+            if (!routerset_contains_router(excludeset, router))
+              smartlist_add(out, router);
         }
     });
   } else {
@@ -5544,7 +5546,8 @@ routerset_get_all_routers(smartlist_t *out, const routerset_t *routerset,
     SMARTLIST_FOREACH(rl->routers, routerinfo_t *, router, {
         if (running_only && !router->is_running)
           continue;
-        if (routerset_contains_router(routerset, router))
+        if (routerset_contains_router(routerset, router) &&
+            !routerset_contains_router(excludeset, router))
           smartlist_add(out, router);
     });
   }
index ca428114ed93414cad29b852e7418af2da20bff3..cd0eb956b5f12c2a1ea3579d20b2ffb1c8c35854 100644 (file)
@@ -173,6 +173,7 @@ int routerset_contains_routerstatus(const routerset_t *set,
 int routerset_contains_extendinfo(const routerset_t *set,
                                   const extend_info_t *ei);
 void routerset_get_all_routers(smartlist_t *out, const routerset_t *routerset,
+                               const routerset_t *excludeset,
                                int running_only);
 void routersets_get_disjunction(smartlist_t *target, const smartlist_t *source,
                                 const routerset_t *include,