mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
backport r12459
svn:r12611
This commit is contained in:
+2
-3
@@ -2600,9 +2600,8 @@ void policies_parse_from_options(or_options_t *options);
|
||||
int cmp_addr_policies(addr_policy_t *a, addr_policy_t *b);
|
||||
addr_policy_result_t compare_addr_to_addr_policy(uint32_t addr,
|
||||
uint16_t port, addr_policy_t *policy);
|
||||
int policies_parse_exit_policy(config_line_t *cfg,
|
||||
addr_policy_t **dest,
|
||||
int rejectprivate);
|
||||
int policies_parse_exit_policy(config_line_t *cfg, addr_policy_t **dest,
|
||||
int rejectprivate, const char *local_address);
|
||||
int exit_policy_is_general_exit(addr_policy_t *policy);
|
||||
int policy_is_reject_star(addr_policy_t *policy);
|
||||
int getinfo_helper_policies(control_connection_t *conn,
|
||||
|
||||
+9
-3
@@ -232,7 +232,7 @@ validate_addr_policies(or_options_t *options, char **msg)
|
||||
*msg = NULL;
|
||||
|
||||
if (policies_parse_exit_policy(options->ExitPolicy, &addr_policy,
|
||||
options->ExitPolicyRejectPrivate))
|
||||
options->ExitPolicyRejectPrivate, NULL))
|
||||
REJECT("Error in ExitPolicy entry.");
|
||||
|
||||
/* The rest of these calls *append* to addr_policy. So don't actually
|
||||
@@ -554,10 +554,16 @@ exit_policy_remove_redundancies(addr_policy_t **dest)
|
||||
*/
|
||||
int
|
||||
policies_parse_exit_policy(config_line_t *cfg, addr_policy_t **dest,
|
||||
int rejectprivate)
|
||||
int rejectprivate, const char *local_address)
|
||||
{
|
||||
if (rejectprivate)
|
||||
if (rejectprivate) {
|
||||
append_exit_policy_string(dest, "reject private:*");
|
||||
if (local_address) {
|
||||
char buf[POLICY_BUF_LEN];
|
||||
tor_snprintf(buf, sizeof(buf), "reject %s:*", local_address);
|
||||
append_exit_policy_string(dest, buf);
|
||||
}
|
||||
}
|
||||
if (parse_addr_policy(cfg, dest, -1))
|
||||
return -1;
|
||||
append_exit_policy_string(dest, DEFAULT_EXIT_POLICY);
|
||||
|
||||
+1
-1
@@ -895,7 +895,7 @@ router_rebuild_descriptor(int force)
|
||||
}
|
||||
|
||||
policies_parse_exit_policy(options->ExitPolicy, &ri->exit_policy,
|
||||
options->ExitPolicyRejectPrivate);
|
||||
options->ExitPolicyRejectPrivate, ri->address);
|
||||
|
||||
if (desc_routerinfo) { /* inherit values */
|
||||
ri->is_valid = desc_routerinfo->is_valid;
|
||||
|
||||
+2
-2
@@ -1753,7 +1753,7 @@ test_policies(void)
|
||||
compare_addr_to_addr_policy(0xc0a80102, 2, policy));
|
||||
|
||||
policy2 = NULL;
|
||||
test_assert(0 == policies_parse_exit_policy(NULL, &policy2, 1));
|
||||
test_assert(0 == policies_parse_exit_policy(NULL, &policy2, 1, NULL));
|
||||
test_assert(policy2);
|
||||
|
||||
test_assert(!exit_policy_is_general_exit(policy));
|
||||
@@ -1773,7 +1773,7 @@ test_policies(void)
|
||||
line.key = (char*)"foo";
|
||||
line.value = (char*)"accept *:80,reject private:*,reject *:*";
|
||||
line.next = NULL;
|
||||
test_assert(0 == policies_parse_exit_policy(&line, &policy, 0));
|
||||
test_assert(0 == policies_parse_exit_policy(&line, &policy, 0, NULL));
|
||||
test_assert(policy);
|
||||
test_streq(policy->string, "accept *:80");
|
||||
test_streq(policy->next->string, "reject *:*");
|
||||
|
||||
Reference in New Issue
Block a user