diff options
author | Chelsea H. Komlo <chelsea.komlo@gmail.com> | 2016-10-08 19:28:38 -0500 |
---|---|---|
committer | Chelsea H. Komlo <chelsea.komlo@gmail.com> | 2016-10-18 18:40:50 -0500 |
commit | 195ccce94e250a150e208f7a8fb9ba8375b6fe89 (patch) | |
tree | e24de23c5ea00bf4827d3280f59718b6cbb87b79 /src/or/directory.c | |
parent | 9a3adb07c49a522ffbefb009687c3bd9ee282d59 (diff) | |
download | tor-195ccce94e250a150e208f7a8fb9ba8375b6fe89.tar.gz tor-195ccce94e250a150e208f7a8fb9ba8375b6fe89.zip |
Refactor to use purpose_needs_anonymity and remove is_sensitive_dir_purpose
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 1f894d9fb3..8dc30952a6 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -120,17 +120,22 @@ static void connection_dir_close_consensus_fetches( /********* END VARIABLES ************/ -/** Return true iff the directory purpose <b>dir_purpose</b> (and if it's - * fetching descriptors, it's fetching them for <b>router_purpose</b>) - * must use an anonymous connection to a directory. */ +/** Return false if the directory purpose <b>dir_purpose</b> + * does not require an anonymous (three-hop) connection. + * + * Return true 1) by default, 2) if all directory actions have + * specifically been configured to be over an anonymous connection, + * or 3) if the router is a bridge */ int purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose) { if (get_options()->AllDirActionsPrivate) return 1; + if (router_purpose == ROUTER_PURPOSE_BRIDGE) return 1; /* if no circuits yet, this might break bootstrapping, but it's * needed to be safe. */ + if (dir_purpose == DIR_PURPOSE_UPLOAD_DIR || dir_purpose == DIR_PURPOSE_UPLOAD_VOTE || dir_purpose == DIR_PURPOSE_UPLOAD_SIGNATURES || @@ -1078,18 +1083,6 @@ directory_initiate_command(const tor_addr_t *or_addr, uint16_t or_port, if_modified_since, NULL); } -/** Return non-zero iff a directory connection with purpose - * <b>dir_purpose</b> reveals sensitive information about a Tor - * instance's client activities. (Such connections must be performed - * through normal three-hop Tor circuits.) */ -int -is_sensitive_dir_purpose(uint8_t dir_purpose) -{ - return ((dir_purpose == DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2) || - (dir_purpose == DIR_PURPOSE_UPLOAD_RENDDESC_V2) || - (dir_purpose == DIR_PURPOSE_FETCH_RENDDESC_V2)); -} - /** Same as directory_initiate_command(), but accepts rendezvous data to * fetch a hidden service descriptor, and takes its address & port arguments * as tor_addr_port_t. */ @@ -1137,7 +1130,7 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port, log_debug(LD_DIR, "Initiating %s", dir_conn_purpose_to_string(dir_purpose)); - if (is_sensitive_dir_purpose(dir_purpose)) { + if (purpose_needs_anonymity(dir_purpose, router_purpose)) { tor_assert(anonymized_connection || rend_non_anonymous_mode_enabled(options)); } |