summaryrefslogtreecommitdiff
path: root/src/or/policies.c
diff options
context:
space:
mode:
authorrl1987 <nobody@nowhere.int>2013-08-23 21:06:42 +0300
committerNick Mathewson <nickm@torproject.org>2014-04-08 13:50:02 -0400
commit51e13cd1ad5f7c130521e2a964ea462f35d1880e (patch)
treec7f5cbaf837e96d0bb60f351e67aa724f0f9cdfe /src/or/policies.c
parent77e4a01f12cc127022df16922fbe526bfc5824d9 (diff)
downloadtor-51e13cd1ad5f7c130521e2a964ea462f35d1880e.tar.gz
tor-51e13cd1ad5f7c130521e2a964ea462f35d1880e.zip
Making entire exit policy available to Tor controller.
Diffstat (limited to 'src/or/policies.c')
-rw-r--r--src/or/policies.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/or/policies.c b/src/or/policies.c
index be4da55061..d5bd22d89a 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -13,6 +13,7 @@
#include "dirserv.h"
#include "nodelist.h"
#include "policies.h"
+#include "router.h"
#include "routerparse.h"
#include "geoip.h"
#include "ht.h"
@@ -1680,6 +1681,28 @@ getinfo_helper_policies(control_connection_t *conn,
(void) errmsg;
if (!strcmp(question, "exit-policy/default")) {
*answer = tor_strdup(DEFAULT_EXIT_POLICY);
+ } else if (!strcmpstart(question, "exit-policy/")) {
+ const routerinfo_t *me = router_get_my_routerinfo();
+
+ int include_ipv4 = 0;
+ int include_ipv6 = 0;
+
+ if (!strcmp(question, "exit-policy/ipv4")) {
+ include_ipv4 = 1;
+ } else if (!strcmp(question, "exit-policy/ipv6")) {
+ include_ipv6 = 1;
+ } else if (!strcmp(question, "exit-policy/full")) {
+ include_ipv4 = include_ipv6 = 1;
+ } else {
+ return 0; /* No such key. */
+ }
+
+ if (!me) {
+ *errmsg = "router_get_my_routerinfo returned NULL";
+ return -1;
+ }
+
+ *answer = router_dump_exit_policy_to_string(me,include_ipv4,include_ipv6);
}
return 0;
}