From: Nick Mathewson Date: Tue, 13 Sep 2016 14:20:08 +0000 (-0400) Subject: Merge branch 'feature-17178-v7-squashed-v2' X-Git-Tag: tor-0.2.9.3-alpha~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f0cb5af1559d4dab0a49017bdd5f37b0af588f8;p=thirdparty%2Ftor.git Merge branch 'feature-17178-v7-squashed-v2' --- 9f0cb5af1559d4dab0a49017bdd5f37b0af588f8 diff --cc src/or/rendservice.c index 8d3a7d704c,cce63f29fa..4f7d7aa726 --- 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; } +