[tor-commits] [tor/master] Merge branch 'feature18329_029_squashed' into maint-0.3.2

2017-10-24 Thread nickm
commit b95ef19a77e2e04c740bbbe16d3b0ed7a5239aee
Merge: 594cf9249 f3af74ccf
Author: Nick Mathewson 
Date:   Tue Oct 24 19:35:32 2017 -0400

Merge branch 'feature18329_029_squashed' into maint-0.3.2

 changes/feature18329   |  2 +-
 src/test/test_config.c | 18 +-
 src/test/test_router.c |  7 +--
 3 files changed, 19 insertions(+), 8 deletions(-)




___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/master] Merge branch 'feature18329_029_squashed' into maint-0.3.2

2017-10-24 Thread nickm
commit 594cf92498c8ea12dc0b19f743d6b88d4a98f1eb
Merge: 122a7f884 02cde0d93
Author: Nick Mathewson 
Date:   Tue Oct 24 19:35:28 2017 -0400

Merge branch 'feature18329_029_squashed' into maint-0.3.2

 changes/feature18329   |   9 
 doc/tor.1.txt  |  11 +
 src/or/config.c|  62 +++-
 src/or/config.h|   2 +
 src/or/or.h|   4 ++
 src/or/router.c|  12 ++
 src/test/include.am|   1 +
 src/test/test.c|   1 +
 src/test/test_config.c |  63 
 src/test/test_router.c | 109 +
 10 files changed, 273 insertions(+), 1 deletion(-)

diff --cc src/or/config.c
index a2353b94d,0b1e6bed1..b123d4935
--- a/src/or/config.c
+++ b/src/or/config.c
@@@ -253,15 -182,14 +253,16 @@@ static config_var_t option_vars_[] = 
V(BridgePassword,  STRING,   NULL),
V(BridgeRecordUsageByCountry,  BOOL, "1"),
V(BridgeRelay, BOOL, "0"),
+   V(BridgeDistribution,  STRING,   NULL),
V(CellStatistics,  BOOL, "0"),
 +  V(PaddingStatistics,   BOOL, "1"),
V(LearnCircuitBuildTimeout,BOOL, "1"),
V(CircuitBuildTimeout, INTERVAL, "0"),
 -  V(CircuitIdleTimeout,  INTERVAL, "1 hour"),
 +  OBSOLETE("CircuitIdleTimeout"),
 +  V(CircuitsAvailableTimeout,INTERVAL, "0"),
V(CircuitStreamTimeout,INTERVAL, "0"),
V(CircuitPriorityHalflife, DOUBLE,  "-100.0"), /*negative:'Use 
default'*/
 -  V(ClientDNSRejectInternalAddresses, BOOL,"1"),
 +  V(TestingClientDNSRejectInternalAddresses, BOOL,"1"),
V(ClientOnly,  BOOL, "0"),
V(ClientPreferIPv6ORPort,  AUTOBOOL, "auto"),
V(ClientPreferIPv6DirPort, AUTOBOOL, "auto"),
@@@ -3504,14 -3346,16 +3504,23 @@@ options_validate(or_options_t *old_opti
  options->DirPort_set = 0;
}
  
 +  if (server_mode(options) && options->ConnectionPadding != -1) {
 +REJECT("Relays must use 'auto' for the ConnectionPadding setting.");
 +  }
 +
 +  if (server_mode(options) && options->ReducedConnectionPadding != 0) {
 +REJECT("Relays cannot set ReducedConnectionPadding. ");
 +  }
 +
+   if (options->BridgeDistribution) {
+ if (!options->BridgeRelay) {
+   REJECT("You set BridgeDistribution, but you didn't set BridgeRelay!");
+ }
+ if (check_bridge_distribution_setting(options->BridgeDistribution) < 0) {
+   REJECT("Invalid BridgeDistribution value.");
+ }
+   }
+ 
 -
if (options->MinUptimeHidServDirectoryV2 < 0) {
  log_warn(LD_CONFIG, "MinUptimeHidServDirectoryV2 option must be at "
  "least 0 seconds. Changing to 0.");
@@@ -4686,7 -4507,9 +4695,9 @@@ options_transition_affects_descriptor(c
get_effective_bwburst(old_options) !=
  get_effective_bwburst(new_options) ||
!opt_streq(old_options->ContactInfo, new_options->ContactInfo) ||
+   !opt_streq(old_options->BridgeDistribution,
+  new_options->BridgeDistribution) ||
 -  !opt_streq(old_options->MyFamily, new_options->MyFamily) ||
 +  !config_lines_eq(old_options->MyFamily, new_options->MyFamily) ||
!opt_streq(old_options->AccountingStart, new_options->AccountingStart) 
||
old_options->AccountingMax != new_options->AccountingMax ||
old_options->AccountingRule != new_options->AccountingRule ||
@@@ -6584,11 -6350,65 +6595,60 @@@ warn_client_dns_cache(const char *optio
  }
  
  /**
+  * Validate the configured bridge distribution method from a 
BridgeDistribution
+  * config line.
+  *
+  * The input bd, is a string taken from the BridgeDistribution config
+  * line (if present).  If the option wasn't set, return 0 immediately.  The
+  * BridgeDistribution option is then validated.  Currently valid, recognised
+  * options are:
+  *
+  * - "none"
+  * - "any"
+  * - "https"
+  * - "email"
+  * - "moat"
+  * - "hyphae"
+  *
+  * If the option string is unrecognised, a warning will be logged and 0 is
+  * returned.  If the option string contains an invalid character, -1 is
+  * returned.
+  **/
+ STATIC int
+ check_bridge_distribution_setting(const char *bd)
+ {
+   if (bd == NULL)
+ return 0;
+ 
+   const char *RECOGNIZED[] = {
+ "none", "any", "https", "email", "moat", "hyphae"
+   };
+   unsigned i;
+   for (i = 0; i < ARRAY_LENGTH(RECOGNIZED); ++i) {
+ if (!strcmp(bd, RECOGNIZED[i]))
+   return 0;
+   }
+ 
+   const char *cp = bd;
+   //  Method = (KeywordChar | "_") +
+   while (TOR_ISALNUM(*cp) || *cp == '-' || *cp == '_')
+ ++cp;
+ 
+   if (*cp == 0) {
+ log_warn(LD_CONFIG, "Unrecognized BridgeDistribution value %s. I'll "
+"assume you know what you are doing...", escaped(bd));
+ return 0; // we reached the end of the string; all is well
+   } else {
+ return -1; // we found a bad character in the string.
+   }
+ }
+ 
+ /**
   * Parse port