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

[or-cvs] [tor/master] Implement node_set_exit_policy_to_reject_all with a flag



Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed, 13 Oct 2010 20:30:40 -0400
Subject: Implement node_set_exit_policy_to_reject_all with a flag
Commit: 44674369c5db15f64c7b5fe53c3b7010abb783d5

Also remove some debugging code.
---
 src/or/main.c     |    3 ++-
 src/or/nodelist.c |    8 +++-----
 src/or/nodelist.h |    7 -------
 src/or/or.h       |    3 +++
 src/or/policies.c |   19 ++++---------------
 5 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/src/or/main.c b/src/or/main.c
index a4d0c90..9d116fb 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1044,7 +1044,7 @@ run_scheduled_events(time_t now)
    */
   consider_hibernation(now);
 
-  /* XXXX NM REMOVE THIS. XXXX NM XXXX NM XXXX NM*/
+#if 0
   {
     static time_t nl_check_time = 0;
     if (nl_check_time <= now) {
@@ -1052,6 +1052,7 @@ run_scheduled_events(time_t now)
       nl_check_time = now + 30;
     }
   }
+#endif
 
   /* 0b. If we've deferred a signewnym, make sure it gets handled
    * eventually. */
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 8145217..d124667 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -605,6 +605,9 @@ node_allows_single_hop_exits(const node_t *node)
 int
 node_exit_policy_rejects_all(const node_t *node)
 {
+  if (node->rejects_all)
+    return 1;
+
   if (node->ri)
     return node->ri->policy_is_reject_star;
   else if (node->md)
@@ -723,8 +726,3 @@ node_get_declared_family(const node_t *node)
   else
     return NULL;
 }
-
-/* KILLTHIS XXXX NM -- it's a dummy to keep UNIMPLEMENTED_NODELIST()
- * working */
-int unimplemented_nodelist_truth = 1;
-
diff --git a/src/or/nodelist.h b/src/or/nodelist.h
index cb78366..23f4a16 100644
--- a/src/or/nodelist.h
+++ b/src/or/nodelist.h
@@ -55,12 +55,5 @@ void node_set_country(node_t *node);
 void nodelist_add_node_family(smartlist_t *nodes, const node_t *node);
 int nodes_in_same_family(const node_t *node1, const node_t *node2);
 
-/* This means: implement this code or function or thing, nick! */
-#define UNIMPLEMENTED_NODELIST()                        \
-  while (unimplemented_nodelist_truth) {                \
-    tor_assert(0);                                      \
-  }
-extern int unimplemented_nodelist_truth;
-
 #endif
 
diff --git a/src/or/or.h b/src/or/or.h
index 96d0d79..eadc3b1 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1768,6 +1768,9 @@ typedef struct node_t {
                                       * to this (unnamed) router by nickname?
                                       */
 
+  /** Local info: we treat this node as if it rejects everything */
+  unsigned int rejects_all:1;
+
   /* Local info: derived. */
 
   /** According to the geoip db what country is this router in? */
diff --git a/src/or/policies.c b/src/or/policies.c
index 2ae66df..f20fe79 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -875,25 +875,11 @@ policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
   return 0;
 }
 
-#if 0
-/** Replace the exit policy of <b>r</b> with reject *:*. */
-void
-policies_set_router_exitpolicy_to_reject_all(routerinfo_t *r)
-{
-  addr_policy_t *item;
-  addr_policy_list_free(r->exit_policy);
-  r->exit_policy = smartlist_create();
-  item = router_parse_addr_policy_item_from_string("reject *:*", -1);
-  smartlist_add(r->exit_policy, item);
-}
-#endif
-
 /** Replace the exit policy of <b>node</b> with reject *:* */
 void
 policies_set_node_exitpolicy_to_reject_all(node_t *node)
 {
-  (void)node;
-  UNIMPLEMENTED_NODELIST();
+  node->rejects_all = 1;
 }
 
 /** Return 1 if there is at least one /8 subnet in <b>policy</b> that
@@ -1488,6 +1474,9 @@ addr_policy_result_t
 compare_tor_addr_to_node_policy(const tor_addr_t *addr, uint16_t port,
                                 const node_t *node)
 {
+  if (node->rejects_all)
+    return ADDR_POLICY_REJECTED;
+
   if (node->ri)
     return compare_tor_addr_to_addr_policy(addr, port, node->ri->exit_policy);
   else if (node->md && node->md) {
-- 
1.7.1