[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Merge remote-tracking branch 'teor/feature15775-fallback-v9-squashed'



commit 6ba8afe5f87a1edd16f4c61cbb59a29f9126c6c6
Merge: a56fb58 4c1c2a3
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Dec 15 14:04:00 2015 -0500

    Merge remote-tracking branch 'teor/feature15775-fallback-v9-squashed'

 .gitignore                          |    5 +
 changes/feature15775-fallback       |   19 +
 scripts/maint/fallback.blacklist    |   19 +
 scripts/maint/fallback.whitelist    |   13 +
 scripts/maint/updateFallbackDirs.py | 1225 +++++++++++++++++++++++++++++++++++
 src/or/config.c                     |    1 +
 src/or/fallback_dirs.inc            |    1 +
 src/or/include.am                   |    1 +
 src/or/routerlist.c                 |   11 +-
 src/test/test_config.c              |   32 +-
 10 files changed, 1320 insertions(+), 7 deletions(-)

diff --cc src/test/test_config.c
index 0137d1c,00489d1..53fc693
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@@ -3412,97 -3196,38 +3412,125 @@@ test_config_adding_dir_servers(void *ar
  }
  
  static void
 +test_config_default_dir_servers(void *arg)
 +{
 +  or_options_t *opts = NULL;
 +  (void)arg;
 +  int trusted_count = 0;
 +  int fallback_count = 0;
 +
 +  opts = tor_malloc_zero(sizeof(or_options_t));
 +  opts->UseDefaultFallbackDirs = 0;
 +  consider_adding_dir_servers(opts, opts);
 +  trusted_count = smartlist_len(router_get_trusted_dir_servers());
 +  fallback_count = smartlist_len(router_get_fallback_dir_servers());
 +  or_options_free(opts);
 +  opts = NULL;
 +
 +  /* assume a release will never go out with less than 7 authorities */
 +  tt_assert(trusted_count >= 7);
 +  /* if we disable the default fallbacks, there must not be any extra */
 +  tt_assert(fallback_count == trusted_count);
 +
 +  opts = tor_malloc_zero(sizeof(or_options_t));
 +  opts->UseDefaultFallbackDirs = 1;
 +  consider_adding_dir_servers(opts, opts);
 +  trusted_count = smartlist_len(router_get_trusted_dir_servers());
 +  fallback_count = smartlist_len(router_get_fallback_dir_servers());
 +  or_options_free(opts);
 +  opts = NULL;
 +
 +  /* assume a release will never go out with less than 7 authorities */
 +  tt_assert(trusted_count >= 7);
 +  /* XX/teor - allow for default fallbacks to be added without breaking
 +   * the unit tests. Set a minimum fallback count once the list is stable. */
 +  tt_assert(fallback_count >= trusted_count);
 +
 + done:
 +  or_options_free(opts);
 +}
 +
 +static void
 +test_config_use_multiple_directories(void *arg)
 +{
 +  (void)arg;
 +
 +  or_options_t *options = tor_malloc_zero(sizeof(or_options_t));
 +
 +  /* Clients can use multiple directory mirrors for bootstrap */
 +  memset(options, 0, sizeof(or_options_t));
 +  options->ClientOnly = 1;
 +  tt_assert(networkstatus_consensus_can_use_multiple_directories(options)
 +            == 1);
 +
 +  /* Bridge Clients can use multiple directory mirrors for bootstrap */
 +  memset(options, 0, sizeof(or_options_t));
 +  options->UseBridges = 1;
 +  tt_assert(networkstatus_consensus_can_use_multiple_directories(options)
 +            == 1);
 +
 +  /* Bridge Relays (Bridges) must act like clients, and use multiple
 +   * directory mirrors for bootstrap */
 +  memset(options, 0, sizeof(or_options_t));
 +  options->BridgeRelay = 1;
 +  tt_assert(networkstatus_consensus_can_use_multiple_directories(options)
 +            == 1);
 +
 +  /* Clients set to FetchDirInfoEarly must fetch it from the authorities */
 +  memset(options, 0, sizeof(or_options_t));
 +  options->FetchDirInfoEarly = 1;
 +  tt_assert(networkstatus_consensus_can_use_multiple_directories(options)
 +            == 0);
 +
 +  /* OR servers must fetch the consensus from the authorities */
 +  memset(options, 0, sizeof(or_options_t));
 +  options->ORPort_set = 1;
 +  tt_assert(networkstatus_consensus_can_use_multiple_directories(options)
 +            == 0);
 +
 + done:
 +  tor_free(options);
 +}
 +
++static void
+ test_config_default_fallback_dirs(void *arg)
+ {
+   const char *fallback[] = {
+ #include "../or/fallback_dirs.inc"
+     NULL
+   };
+ 
+   int n_included_fallback_dirs = 0;
+   int n_added_fallback_dirs = 0;
+ 
+   (void)arg;
+   clear_dir_servers();
+ 
+   while (fallback[n_included_fallback_dirs])
+     n_included_fallback_dirs++;
+ 
+   add_default_fallback_dir_servers();
+ 
+   n_added_fallback_dirs = smartlist_len(router_get_fallback_dir_servers());
+ 
+   tt_assert(n_included_fallback_dirs == n_added_fallback_dirs);
+ 
+   done:
+   clear_dir_servers();
+ }
+ 
  #define CONFIG_TEST(name, flags)                          \
    { #name, test_config_ ## name, flags, NULL, NULL }
  
  struct testcase_t config_tests[] = {
 -  CONFIG_TEST(adding_dir_servers, 0),
 +  CONFIG_TEST(adding_trusted_dir_server, TT_FORK),
 +  CONFIG_TEST(adding_fallback_dir_server, TT_FORK),
 +  CONFIG_TEST(parsing_trusted_dir_server, 0),
 +  CONFIG_TEST(parsing_fallback_dir_server, 0),
 +  CONFIG_TEST(adding_default_trusted_dir_servers, TT_FORK),
 +  CONFIG_TEST(adding_dir_servers, TT_FORK),
 +  CONFIG_TEST(default_dir_servers, TT_FORK),
+   CONFIG_TEST(default_fallback_dirs, 0),
    CONFIG_TEST(resolve_my_address, TT_FORK),
    CONFIG_TEST(addressmap, 0),
    CONFIG_TEST(parse_bridge_line, 0),

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