commit 9f0cb5af1559d4dab0a49017bdd5f37b0af588f8 Merge: 4b182df f311c9f Author: Nick Mathewson nickm@torproject.org Date: Tue Sep 13 10:20:08 2016 -0400
Merge branch 'feature-17178-v7-squashed-v2'
changes/bug19677 | 6 + changes/feature17178 | 30 +++ doc/tor.1.txt | 39 +++- src/or/circuitbuild.c | 32 ++- src/or/circuitstats.c | 30 ++- src/or/config.c | 221 ++++++++++++++---- src/or/config.h | 2 + src/or/connection_edge.c | 29 ++- src/or/control.c | 22 ++ src/or/directory.c | 12 +- src/or/directory.h | 3 + src/or/main.c | 14 +- src/or/or.h | 48 +++- src/or/rendclient.c | 49 +++- src/or/rendclient.h | 3 + src/or/rendcommon.c | 48 ++++ src/or/rendcommon.h | 6 + src/or/rendservice.c | 574 ++++++++++++++++++++++++++++++++++++----------- src/or/rendservice.h | 68 +++++- src/test/test_hs.c | 207 +++++++++++++++++ src/test/test_options.c | 149 ++++++++++++ 21 files changed, 1371 insertions(+), 221 deletions(-)
diff --cc src/or/rendservice.c index 8d3a7d7,cce63f2..4f7d7aa --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@@ -3896,12 -4179,50 +4179,51 @@@ rend_service_set_connection_addr_port(e return -2; }
- /* Stub that should be replaced with the #17178 version of the function - * when merging. */ + /* Are HiddenServiceSingleHopMode and HiddenServiceNonAnonymousMode consistent? + */ + static int + rend_service_non_anonymous_mode_consistent(const or_options_t *options) + { + /* !! is used to make these options boolean */ + return (!! options->HiddenServiceSingleHopMode == + !! options->HiddenServiceNonAnonymousMode); + } + + /* Do the options allow onion services to make direct (non-anonymous) + * connections to introduction or rendezvous points? + * Must only be called after options_validate_single_onion() has successfully + * checked onion service option consistency. + * Returns true if tor is in HiddenServiceSingleHopMode. */ int - rend_service_allow_direct_connection(const or_options_t *options) + rend_service_allow_non_anonymous_connection(const or_options_t *options) { - (void)options; - return 0; + tor_assert(rend_service_non_anonymous_mode_consistent(options)); + return options->HiddenServiceSingleHopMode ? 1 : 0; + } + + /* Do the options allow us to reveal the exact startup time of the onion + * service? + * Single Onion Services prioritise availability over hiding their + * startup time, as their IP address is publicly discoverable anyway. + * Must only be called after options_validate_single_onion() has successfully + * checked onion service option consistency. + * Returns true if tor is in non-anonymous hidden service mode. */ + int + rend_service_reveal_startup_time(const or_options_t *options) + { + tor_assert(rend_service_non_anonymous_mode_consistent(options)); + return rend_service_non_anonymous_mode_enabled(options); + } + + /* Is non-anonymous mode enabled using the HiddenServiceNonAnonymousMode + * config option? + * Must only be called after options_validate_single_onion() has successfully + * checked onion service option consistency. + */ + int + rend_service_non_anonymous_mode_enabled(const or_options_t *options) + { + tor_assert(rend_service_non_anonymous_mode_consistent(options)); + return options->HiddenServiceNonAnonymousMode ? 1 : 0; } +