]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Parse IPv6 policy summaries from router descriptors and microdescs
authorNick Mathewson <nickm@torproject.org>
Thu, 25 Oct 2012 01:59:55 +0000 (21:59 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 15 Nov 2012 04:16:22 +0000 (23:16 -0500)
src/or/microdesc.c
src/or/or.h
src/or/routerlist.c
src/or/routerparse.c

index 42a35f0676c26081fb4fd772add323f2e7cccd8d..e274313e5ad723bc069996e767064276600f0e1c 100644 (file)
@@ -583,6 +583,7 @@ microdesc_free(microdesc_t *md)
     smartlist_free(md->family);
   }
   short_policy_free(md->exit_policy);
+  short_policy_free(md->ipv6_exit_policy);
 
   tor_free(md);
 }
index 42bf0a8ea7fd891967d6d89852b9e6338beeffc2..05d27b15089bcbd2258c3cec108ed586cb5c7801 100644 (file)
@@ -1878,7 +1878,10 @@ typedef struct {
   /** How many bytes/s is this router known to handle? */
   uint32_t bandwidthcapacity;
   smartlist_t *exit_policy; /**< What streams will this OR permit
-                             * to exit?  NULL for 'reject *:*'. */
+                             * to exit on IPv4?  NULL for 'reject *:*'. */
+  /** What streams will this OR permit to exit on IPv6?
+   * NULL for 'reject *:*' */
+  struct short_policy_t *ipv6_exit_policy;
   long uptime; /**< How many seconds the router claims to have been up */
   smartlist_t *declared_family; /**< Nicknames of router which this router
                                  * claims are its family. */
@@ -2084,8 +2087,11 @@ typedef struct microdesc_t {
   uint16_t ipv6_orport;
   /** As routerinfo_t.family */
   smartlist_t *family;
-  /** Exit policy summary */
+  /** IPv4 exit policy summary */
   short_policy_t *exit_policy;
+  /** IPv6 exit policy summary */
+  short_policy_t *ipv6_exit_policy;
+
 } microdesc_t;
 
 /** A node_t represents a Tor router.
index 1cefef989186a1385f885a7da932e3838759ccaa..1735837871e5fa46956d73b3690c7b4a17b3bd0d 100644 (file)
@@ -2402,6 +2402,7 @@ routerinfo_free(routerinfo_t *router)
     smartlist_free(router->declared_family);
   }
   addr_policy_list_free(router->exit_policy);
+  short_policy_free(router->ipv6_exit_policy);
 
   memset(router, 77, sizeof(routerinfo_t));
 
index 7c1dd887ce0b2fd4e64bc5c150ed0b96325964e4..5607479d6c255ce0e729fad99bc39fc04393f1a2 100644 (file)
@@ -66,6 +66,7 @@ typedef enum {
   K_SERVER_VERSIONS,
   K_OR_ADDRESS,
   K_P,
+  K_P6,
   K_R,
   K_A,
   K_S,
@@ -77,6 +78,7 @@ typedef enum {
   K_CACHES_EXTRA_INFO,
   K_HIDDEN_SERVICE_DIR,
   K_ALLOW_SINGLE_HOP_EXITS,
+  K_IPV6_POLICY,
 
   K_DIRREQ_END,
   K_DIRREQ_V2_IPS,
@@ -271,6 +273,7 @@ static token_rule_t routerdesc_token_table[] = {
   T0N("reject6",             K_REJECT6,             ARGS,    NO_OBJ ),
   T0N("accept6",             K_ACCEPT6,             ARGS,    NO_OBJ ),
   T1_START( "router",        K_ROUTER,              GE(5),   NO_OBJ ),
+  T01("ipv6-policy",         K_IPV6_POLICY,         CONCAT_ARGS, NO_OBJ),
   T1( "signing-key",         K_SIGNING_KEY,         NO_ARGS, NEED_KEY_1024 ),
   T1( "onion-key",           K_ONION_KEY,           NO_ARGS, NEED_KEY_1024 ),
   T1_END( "router-signature",    K_ROUTER_SIGNATURE,    NO_ARGS, NEED_OBJ ),
@@ -527,6 +530,7 @@ static token_rule_t microdesc_token_table[] = {
   T0N("a",                     K_A,                GE(1),       NO_OBJ ),
   T01("family",                K_FAMILY,           ARGS,        NO_OBJ ),
   T01("p",                     K_P,                CONCAT_ARGS, NO_OBJ ),
+  T01("p6",                    K_P6,               CONCAT_ARGS, NO_OBJ ),
   A01("@last-listed",          A_LAST_LISTED,      CONCAT_ARGS, NO_OBJ ),
   END_OF_TABLE
 };
@@ -1573,6 +1577,14 @@ router_parse_entry_from_string(const char *s, const char *end,
   if (policy_is_reject_star(router->exit_policy))
     router->policy_is_reject_star = 1;
 
+  if ((tok = find_opt_by_keyword(tokens, K_IPV6_POLICY)) && tok->n_args) {
+    router->ipv6_exit_policy = parse_short_policy(tok->args[0]);
+    if (! router->ipv6_exit_policy) {
+      log_warn(LD_DIR , "Error in ipv6-policy %s", escaped(tok->args[0]));
+      goto err;
+    }
+  }
+
   if ((tok = find_opt_by_keyword(tokens, K_FAMILY)) && tok->n_args) {
     int i;
     router->declared_family = smartlist_new();
@@ -4484,6 +4496,9 @@ microdescs_parse_from_string(const char *s, const char *eos,
     if ((tok = find_opt_by_keyword(tokens, K_P))) {
       md->exit_policy = parse_short_policy(tok->args[0]);
     }
+    if ((tok = find_opt_by_keyword(tokens, K_P6))) {
+      md->ipv6_exit_policy = parse_short_policy(tok->args[0]);
+    }
 
     crypto_digest256(md->digest, md->body, md->bodylen, DIGEST_SHA256);