]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
slight tweak on circuit_conforms_to_options
authorRoger Dingledine <arma@torproject.org>
Fri, 11 Mar 2011 08:22:53 +0000 (03:22 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 27 Apr 2011 03:54:04 +0000 (23:54 -0400)
this function really needs to get a total rewrite (or die)

For now, use #if 0 to disable it.

src/or/circuituse.c
src/or/circuituse.h

index cdf49e3983a1a1e7a68dfa5646a24304435be148..7b20f7f173c90bd75b6902f138eaf1870b1773ea 100644 (file)
@@ -242,33 +242,34 @@ circuit_get_best(edge_connection_t *conn, int must_be_open, uint8_t purpose,
   return best ? TO_ORIGIN_CIRCUIT(best) : NULL;
 }
 
+#if 0
 /** Check whether, according to the policies in <b>options</b>, the
  * circuit <b>circ</b> makes sense. */
-/* XXXX currently only checks Exclude{Exit}Nodes. It should check more. */
+/* XXXX currently only checks Exclude{Exit}Nodes; it should check more.
+ * Also, it doesn't have the right definition of an exit circuit. Also,
+ * it's never called. */
 int
 circuit_conforms_to_options(const origin_circuit_t *circ,
                             const or_options_t *options)
 {
   const crypt_path_t *cpath, *cpath_next = NULL;
 
-  for (cpath = circ->cpath; cpath && cpath_next != circ->cpath;
-       cpath = cpath_next) {
+  /* first check if it includes any excluded nodes */
+  for (cpath = circ->cpath; cpath_next != circ->cpath; cpath = cpath_next) {
     cpath_next = cpath->next;
-
     if (routerset_contains_extendinfo(options->ExcludeNodes,
                                       cpath->extend_info))
       return 0;
+  }
 
-    if (cpath->next == circ->cpath) {
-      /* This is apparently the exit node. */
+  /* then consider the final hop */
+  if (routerset_contains_extendinfo(options->ExcludeExitNodes,
+                                    circ->cpath->prev->extend_info))
+    return 0;
 
-      if (routerset_contains_extendinfo(options->ExcludeExitNodes,
-                                        cpath->extend_info))
-        return 0;
-    }
-  }
   return 1;
 }
+#endif
 
 /** Close all circuits that start at us, aren't open, and were born
  * at least CircuitBuildTimeout seconds ago.
index a121099aca805ae5369442ece316513a9a03c9f7..9f393ab37851b376b8dca6f7a4e41f289de29e99 100644 (file)
@@ -16,8 +16,10 @@ void circuit_expire_building(void);
 void circuit_remove_handled_ports(smartlist_t *needed_ports);
 int circuit_stream_is_being_handled(edge_connection_t *conn, uint16_t port,
                                     int min);
+#if 0
 int circuit_conforms_to_options(const origin_circuit_t *circ,
                                 const or_options_t *options);
+#endif
 void circuit_build_needed_circs(time_t now);
 void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn);