From 6f08d121d96be29c2ce2d9ef9df4416141651951 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Mon, 27 Mar 2006 02:25:34 +0000 Subject: Refactor and consolidate addr/exit policies into a new policies.c. Fix some minor bugs and memory leaks along the way. svn:r6246 --- src/or/directory.c | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'src/or/directory.c') diff --git a/src/or/directory.c b/src/or/directory.c index 5254d6bc9..9a63ad2b1 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()->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 addr is permitted to connect to our dir port, - * based on dir_policy. 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 -- cgit v1.2.3