summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-03-27 02:25:34 +0000
committerRoger Dingledine <arma@torproject.org>2006-03-27 02:25:34 +0000
commit6f08d121d96be29c2ce2d9ef9df4416141651951 (patch)
tree91c4acf09b72156d35b9bf259c2e5b48b968a14a /src/or/directory.c
parent74d35c8027937fe8dac031bf76e31a017d4fa81f (diff)
downloadtor-6f08d121d96be29c2ce2d9ef9df4416141651951.tar.gz
tor-6f08d121d96be29c2ce2d9ef9df4416141651951.zip
Refactor and consolidate addr/exit policies into a new policies.c.
Fix some minor bugs and memory leaks along the way. svn:r6246
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 5254d6bc9e..9a63ad2b1f 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -54,60 +54,12 @@ static void note_request(const char *key, size_t bytes);
/********* START VARIABLES **********/
-static addr_policy_t *dir_policy = NULL;
-
/** How far in the future do we allow a directory server to tell us it is
* before deciding that one of us has the wrong time? */
#define ALLOW_DIRECTORY_TIME_SKEW (30*60)
/********* END VARIABLES ************/
-/** Parse get_options()-&gt;DirPolicy, and put the processed version in
- * &dir_policy. Ignore port specifiers.
- */
-void
-parse_dir_policy(void)
-{
- addr_policy_t *n;
- if (dir_policy) {
- addr_policy_free(dir_policy);
- dir_policy = NULL;
- }
- config_parse_addr_policy(get_options()->DirPolicy, &dir_policy, -1);
- /* ports aren't used. */
- for (n=dir_policy; n; n = n->next) {
- n->prt_min = 1;
- n->prt_max = 65535;
- }
-}
-
-/** Free storage used to hold parsed directory policy */
-void
-free_dir_policy(void)
-{
- addr_policy_free(dir_policy);
- dir_policy = NULL;
-}
-
-/** Return 1 if <b>addr</b> is permitted to connect to our dir port,
- * based on <b>dir_policy</b>. Else return 0.
- */
-int
-dir_policy_permits_address(uint32_t addr)
-{
- int a;
-
- if (!dir_policy) /* 'no dir policy' means 'accept' */
- return 1;
- a = router_compare_addr_to_addr_policy(addr, 1, dir_policy);
- if (a==ADDR_POLICY_REJECTED)
- return 0;
- else if (a==ADDR_POLICY_ACCEPTED)
- return 1;
- log_warn(LD_BUG, "Bug: got unexpected 'maybe' answer from dir policy");
- return 0;
-}
-
/** Return true iff the directory purpose 'purpose' must use an
* anonymous connection to a directory. */
static int