[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r9219: Another cleanup: expand_exit_policy_aliases was totally redu (in tor/trunk: . src/or)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r9219: Another cleanup: expand_exit_policy_aliases was totally redu (in tor/trunk: . src/or)
- From: nickm@xxxxxxxx
- Date: Fri, 29 Dec 2006 15:50:28 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Fri, 29 Dec 2006 15:50:39 -0500
- Reply-to: or-talk@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: nickm
Date: 2006-12-29 15:50:24 -0500 (Fri, 29 Dec 2006)
New Revision: 9219
Modified:
tor/trunk/
tor/trunk/src/or/policies.c
tor/trunk/src/or/routerparse.c
Log:
r11761@Kushana: nickm | 2006-12-29 15:45:56 -0500
Another cleanup: expand_exit_policy_aliases was totally redundant with respect to router_parse_[private_]addr_policy_private.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r11761] on c95137ef-5f19-0410-b913-86e773d04f59
Modified: tor/trunk/src/or/policies.c
===================================================================
--- tor/trunk/src/or/policies.c 2006-12-29 20:50:13 UTC (rev 9218)
+++ tor/trunk/src/or/policies.c 2006-12-29 20:50:24 UTC (rev 9219)
@@ -12,8 +12,6 @@
#include "or.h"
-static int expand_exit_policy_aliases(smartlist_t *entries, int assume_action);
-
static addr_policy_t *socks_policy = NULL;
static addr_policy_t *dir_policy = NULL;
static addr_policy_t *authdir_reject_policy = NULL;
@@ -52,10 +50,6 @@
for (; cfg; cfg = cfg->next) {
smartlist_split_string(entries, cfg->value, ",",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
- if (expand_exit_policy_aliases(entries,assume_action)<0) {
- r = -1;
- continue;
- }
SMARTLIST_FOREACH(entries, const char *, ent,
{
log_debug(LD_CONFIG,"Adding new entry '%s'",ent);
@@ -450,65 +444,6 @@
parse_addr_policy(&tmp, policy, -1);
}
-static int
-expand_exit_policy_aliases(smartlist_t *entries, int assume_action)
-{
- static const char *prefixes[] = {
- "0.0.0.0/8", "169.254.0.0/16",
- "127.0.0.0/8", "192.168.0.0/16", "10.0.0.0/8", "172.16.0.0/12",NULL };
- int i;
- char *pre=NULL, *post=NULL;
- int expanded_any = 0;
- pre = smartlist_join_strings(entries,",",0,NULL);
- for (i = 0; i < smartlist_len(entries); ++i) {
- char *v = smartlist_get(entries, i);
- const char *cp, *ports;
- const char *action;
- int prefix_idx;
- if (!strcasecmpstart(v, "accept")) {
- action = "accept ";
- cp = v+strlen("accept");
- } else if (!strcasecmpstart(v, "reject")) {
- action = "reject ";
- cp = v+strlen("reject");
- } else if (assume_action >= 0) {
- action = "";
- cp = v;
- } else {
- log_warn(LD_CONFIG,"Policy '%s' didn't start with accept or reject.", v);
- tor_free(pre);
- return -1;
- }
- cp = eat_whitespace(cp);
- if (strcmpstart(cp, "private"))
- continue; /* No need to expand. */
- cp += strlen("private");
- cp = eat_whitespace(cp);
- if (*cp && *cp != ':')
- continue; /* It wasn't "private" after all. */
- ports = cp;
- /* Okay. We're going to replace entries[i] with a bunch of new entries,
- * in order. */
- smartlist_del_keeporder(entries, i);
- for (prefix_idx = 0; prefixes[prefix_idx]; ++prefix_idx) {
- size_t replacement_len = 16+strlen(prefixes[prefix_idx])+strlen(ports);
- char *replacement = tor_malloc(replacement_len);
- tor_snprintf(replacement, replacement_len, "%s%s%s",
- action, prefixes[prefix_idx], ports);
- smartlist_insert(entries, i++, replacement);
- }
- tor_free(v);
- expanded_any = 1;
- --i;
- }
- post = smartlist_join_strings(entries,",",0,NULL);
- if (expanded_any)
- log_info(LD_CONFIG, "Expanded '%s' to '%s'", pre, post);
- tor_free(pre);
- tor_free(post);
- return expanded_any;
-}
-
/** Detect and excise "dead code" from the policy *<b>dest</b>. */
static void
exit_policy_remove_redundancies(addr_policy_t **dest)
@@ -598,7 +533,6 @@
* policy afterwards. If <b>rejectprivate</b> is true, prepend
* "reject private:*" to the policy. Return -1 if we can't parse cfg,
* else return 0.
- *
*/
int
policies_parse_exit_policy(config_line_t *cfg, addr_policy_t **dest,
Modified: tor/trunk/src/or/routerparse.c
===================================================================
--- tor/trunk/src/or/routerparse.c 2006-12-29 20:50:13 UTC (rev 9218)
+++ tor/trunk/src/or/routerparse.c 2006-12-29 20:50:24 UTC (rev 9219)
@@ -155,8 +155,8 @@
/* static function prototypes */
static int router_add_exit_policy(routerinfo_t *router,directory_token_t *tok);
static addr_policy_t *router_parse_addr_policy(directory_token_t *tok);
-static addr_policy_t *router_parse_private_addr_policy_private(
- directory_token_t *tok);
+static addr_policy_t *router_parse_addr_policy_private(directory_token_t *tok);
+
static int router_get_hash_impl(const char *s, char *digest,
const char *start_str, const char *end_str);
static void token_free(directory_token_t *tok);
@@ -1380,7 +1380,7 @@
arg = tok->args[0];
if (!strcmpstart(arg,"private"))
- return router_parse_private_addr_policy_private(tok);
+ return router_parse_addr_policy_private(tok);
newe = tor_malloc_zero(sizeof(addr_policy_t));
@@ -1408,9 +1408,8 @@
* router descriptors until earlier versions are obsolete.
*/
static addr_policy_t *
-router_parse_private_addr_policy_private(directory_token_t *tok)
+router_parse_addr_policy_private(directory_token_t *tok)
{
- /* XXXX012 duplicated from config.c */
static const char *private_nets[] = {
"0.0.0.0/8", "169.254.0.0/16",
"127.0.0.0/8", "192.168.0.0/16", "10.0.0.0/8", "172.16.0.0/12",NULL };