aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-10-07 22:09:09 +0000
committerNick Mathewson <nickm@torproject.org>2003-10-07 22:09:09 +0000
commit499bbe72d45758e879a176203e25fcceec22e9d2 (patch)
tree0d120554d167fa47adcdf7724b47a56c6cf64408 /src/or
parente6847c44204876cf5cf2b2116af920bbd165b0f1 (diff)
downloadtor-499bbe72d45758e879a176203e25fcceec22e9d2.tar
tor-499bbe72d45758e879a176203e25fcceec22e9d2.tar.gz
Add a "router_add_exit_policy_from_string" function.
svn:r553
Diffstat (limited to 'src/or')
-rw-r--r--src/or/routers.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/or/routers.c b/src/or/routers.c
index 48aff1934..29a78f410 100644
--- a/src/or/routers.c
+++ b/src/or/routers.c
@@ -946,6 +946,29 @@ static void router_free_exit_policy(routerinfo_t *router) {
}
}
+int router_add_exit_policy_from_string(routerinfo_t *router,
+ char *s)
+{
+ directory_token_t tok;
+ char *tmp, *cp;
+ int r;
+
+ tmp = cp = tor_strdup(s);
+ if (router_get_next_token(&cp, &tok)) {
+ log_fn(LOG_WARNING, "Error reading exit policy: %s", tok.val.error);
+ free(tmp);
+ return -1;
+ }
+ if (tok.tp != K_ACCEPT && tok.tp != K_REJECT) {
+ log_fn(LOG_WARNING, "Expected 'accept' or 'reject'.");
+ free(tmp);
+ return -1;
+ }
+ r = router_add_exit_policy(router, &tok);
+ free(tmp);
+ return r;
+}
+
static int router_add_exit_policy(routerinfo_t *router,
directory_token_t *tok) {
struct exit_policy_t *tmpe, *newe;