aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-08-08 21:58:48 +0000
committerNick Mathewson <nickm@torproject.org>2005-08-08 21:58:48 +0000
commit249b72f53e59beaefbc7b71ac0051c8afc110573 (patch)
tree83809229418cb686ef349f56371f26396988495e /src/or/routerparse.c
parent3ac34ae3293ceb0f2b8c49c41b450f4923353871 (diff)
downloadtor-249b72f53e59beaefbc7b71ac0051c8afc110573.tar
tor-249b72f53e59beaefbc7b71ac0051c8afc110573.tar.gz
Replace (Fascist)Firewall* with a new ReachableAddresses option that understands address policies.
svn:r4751
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 856b14eee..7d58aad68 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1028,10 +1028,12 @@ router_parse_entry_from_string(const char *s, const char *end)
return router;
}
-/** Parse the exit policy in the string <b>s</b> and return it.
+/** Parse the exit policy in the string <b>s</b> and return it. If
+ * assume_action is nonnegative, then insert its action (ADDR_POLICY_ACCEPT or
+ * ADDR_POLICY_REJECT) for items that specify no action.
*/
addr_policy_t *
-router_parse_addr_policy_from_string(const char *s)
+router_parse_addr_policy_from_string(const char *s, int assume_action)
{
directory_token_t *tok = NULL;
const char *cp;
@@ -1047,6 +1049,15 @@ router_parse_addr_policy_from_string(const char *s)
}
tmp[len]='\n';
tmp[len+1]='\0';
+ while (TOR_ISSPACE(*cp))
+ ++cp;
+ if ((*cp == '*' || TOR_ISDIGIT(*cp)) && assume_action >= 0) {
+ char *new_str = tor_malloc(len+10);
+ tor_snprintf(new_str, len+10, "%s %s\n",
+ assume_action == ADDR_POLICY_ACCEPT?"accept":"reject", cp);
+ tor_free(tmp);
+ cp = tmp = new_str;
+ }
tok = get_next_token(&cp, RTR_ONLY);
if (tok->tp == _ERR) {
log_fn(LOG_WARN, "Error reading exit policy: %s", tok->error);
@@ -1073,7 +1084,7 @@ int
router_add_exit_policy_from_string(routerinfo_t *router, const char *s)
{
addr_policy_t *newe, *tmpe;
- newe = router_parse_addr_policy_from_string(s);
+ newe = router_parse_addr_policy_from_string(s, -1);
if (!newe)
return -1;
for (tmpe = router->exit_policy; tmpe; tmpe=tmpe->next)
@@ -1156,7 +1167,7 @@ assert_addr_policy_ok(addr_policy_t *t)
tor_assert(t->policy_type == ADDR_POLICY_REJECT ||
t->policy_type == ADDR_POLICY_ACCEPT);
tor_assert(t->prt_min <= t->prt_max);
- t2 = router_parse_addr_policy_from_string(t->string);
+ t2 = router_parse_addr_policy_from_string(t->string, -1);
tor_assert(t2);
tor_assert(t2->policy_type == t->policy_type);
tor_assert(t2->addr == t->addr);