aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/policies.c
diff options
context:
space:
mode:
authorNeel Chauhan <neel@neelc.org>2019-04-16 08:19:44 -0400
committerNeel Chauhan <neel@neelc.org>2019-04-16 08:19:44 -0400
commite7c22e6e4882332cc0e3377f0d3494f3bf47ad96 (patch)
tree10dd46305eeaf1deeb55fdc8f5ea3afda234a964 /src/core/or/policies.c
parentd4f980d29ac4f9c850fff967018f88115bf3cc2d (diff)
downloadtor-e7c22e6e4882332cc0e3377f0d3494f3bf47ad96.tar.gz
tor-e7c22e6e4882332cc0e3377f0d3494f3bf47ad96.zip
Add policy_using_default_exit_options() to determine if we're using the default exit options
Diffstat (limited to 'src/core/or/policies.c')
-rw-r--r--src/core/or/policies.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/core/or/policies.c b/src/core/or/policies.c
index ab320dd2ca..41d221b19d 100644
--- a/src/core/or/policies.c
+++ b/src/core/or/policies.c
@@ -1164,6 +1164,15 @@ authdir_policy_badexit_address(uint32_t addr, uint16_t port)
#define REJECT(arg) \
STMT_BEGIN *msg = tor_strdup(arg); goto err; STMT_END
+/** Check <b>or_options</b> to determine whether or not we are using the
+ * default options for exit policy. Return true if so, false otherwise. */
+static int
+policy_using_default_exit_options(const or_options_t *or_options)
+{
+ return (or_options->ExitPolicy == NULL && or_options->ExitRelay == -1 &&
+ or_options->ReducedExitPolicy == 0 && or_options->IPv6Exit == 0);
+}
+
/** Config helper: If there's any problem with the policy configuration
* options in <b>options</b>, return -1 and set <b>msg</b> to a newly
* allocated description of the error. Else return 0. */
@@ -1183,8 +1192,7 @@ validate_addr_policies(const or_options_t *options, char **msg)
static int warned_about_nonexit = 0;
if (public_server_mode(options) && !warned_about_nonexit &&
- options->ExitPolicy == NULL && options->ExitRelay == -1 &&
- options->ReducedExitPolicy == 0 && options->IPv6Exit == 0) {
+ policy_using_default_exit_options(options)) {
warned_about_nonexit = 1;
log_notice(LD_CONFIG, "By default, Tor does not run as an exit relay. "
"If you want to be an exit relay, "
@@ -2143,8 +2151,7 @@ policies_parse_exit_policy_from_options(const or_options_t *or_options,
/* Short-circuit for non-exit relays, or for relays where we didn't specify
* ExitPolicy or ReducedExitPolicy and ExitRelay is auto. */
if (or_options->ExitRelay == 0 ||
- (or_options->ExitPolicy == NULL && or_options->ExitRelay == -1 &&
- or_options->ReducedExitPolicy == 0 && or_options->IPv6Exit == 0)) {
+ policy_using_default_exit_options(or_options)) {
append_exit_policy_string(result, "reject *4:*");
append_exit_policy_string(result, "reject *6:*");
return 0;