diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-02-20 08:48:17 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-02-20 08:48:17 -0500 |
commit | f733b8acd67f487a56e56bfb454ff99bc8d1cab0 (patch) | |
tree | 611a792d7e6ab2d9a181c453a71960298af4486a /src/feature/dirauth | |
parent | a79841fd83b6d800796c04855841170c364ff2a9 (diff) | |
parent | f0964628e6e6b4f5dda6df30fbb19f74c59eccfd (diff) | |
download | tor-f733b8acd67f487a56e56bfb454ff99bc8d1cab0.tar.gz tor-f733b8acd67f487a56e56bfb454ff99bc8d1cab0.zip |
Merge remote-tracking branch 'tor-github/pr/1719/head' into maint-0.4.3
Diffstat (limited to 'src/feature/dirauth')
-rw-r--r-- | src/feature/dirauth/dirauth_config.c | 9 | ||||
-rw-r--r-- | src/feature/dirauth/dirauth_config.h | 4 | ||||
-rw-r--r-- | src/feature/dirauth/dirauth_options.inc | 7 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/feature/dirauth/dirauth_config.c b/src/feature/dirauth/dirauth_config.c index 3aeeab3b31..ca16dc8424 100644 --- a/src/feature/dirauth/dirauth_config.c +++ b/src/feature/dirauth/dirauth_config.c @@ -27,6 +27,7 @@ #include "feature/dirauth/authmode.h" #include "feature/dirauth/bwauth.h" #include "feature/dirauth/dirauth_periodic.h" +#include "feature/dirauth/dirauth_sys.h" #include "feature/dirauth/dirvote.h" #include "feature/dirauth/guardfraction.h" #include "feature/dirauth/dirauth_options_st.h" @@ -45,6 +46,14 @@ #define YES_IF_CHANGED_INT(opt) \ if (!CFG_EQ_INT(old_options, new_options, opt)) return 1; +/** Return true iff we are configured to reject request under load for non + * relay connections. */ +bool +dirauth_should_reject_requests_under_load(void) +{ + return !!dirauth_get_options()->AuthDirRejectRequestsUnderLoad; +} + /** * Legacy validation/normalization function for the dirauth mode options in * options. Uses old_options as the previous options. diff --git a/src/feature/dirauth/dirauth_config.h b/src/feature/dirauth/dirauth_config.h index 2ebafd917e..1ec599717c 100644 --- a/src/feature/dirauth/dirauth_config.h +++ b/src/feature/dirauth/dirauth_config.h @@ -35,6 +35,8 @@ int options_act_dirauth_mtbf(const struct or_options_t *old_options); int options_act_dirauth_stats(const struct or_options_t *old_options, bool *print_notice_out); +bool dirauth_should_reject_requests_under_load(void); + extern const struct config_format_t dirauth_options_fmt; #else /* !defined(HAVE_MODULE_DIRAUTH) */ @@ -78,6 +80,8 @@ options_validate_dirauth_mode(const struct or_options_t *old_options, #define options_act_dirauth_stats(old_options, print_notice_out) \ (((void)(old_options)),((void)(print_notice_out)),0) +#define dirauth_should_reject_requests_under_load() (false) + #endif /* defined(HAVE_MODULE_DIRAUTH) */ #endif /* !defined(TOR_FEATURE_DIRAUTH_DIRAUTH_CONFIG_H) */ diff --git a/src/feature/dirauth/dirauth_options.inc b/src/feature/dirauth/dirauth_options.inc index 5939010fe7..21f4996c39 100644 --- a/src/feature/dirauth/dirauth_options.inc +++ b/src/feature/dirauth/dirauth_options.inc @@ -95,4 +95,11 @@ CONF_VAR(TestingMinFastFlagThreshold, MEMUNIT, 0, "0") * versions? */ CONF_VAR(VersioningAuthoritativeDirectory, BOOL, 0, "0") +/** Boolean: Under bandwidth pressure, if set to 1, the authority will always + * answer directory requests from relays but will start sending 503 error code + * for the other connections. If set to 0, all connections are considered the + * same and the authority will try to answer them all regardless of bandwidth + * pressure or not. */ +CONF_VAR(AuthDirRejectRequestsUnderLoad, BOOL, 0, "1") + END_CONF_STRUCT(dirauth_options_t) |