Ticket #22311: 22311.2.patch

File 22311.2.patch, 6.3 KB (added by huyvq, 2 years ago)
  • src/or/config.c

    From 84873a957c786adb7b73aff9948786df076a6d73 Mon Sep 17 00:00:00 2001
    From: huyvq <huyvq.c633@gmail.com>
    Date: Wed, 24 May 2017 00:50:07 +0700
    Subject: [PATCH] Remove authdir_mode_any_nonhidserv() and
     authdir_mode_any_main()
    
    * Also simplify some authdir_mode* wrapper functions
    
    * Close #22311
    ---
     src/or/config.c     |  2 +-
     src/or/directory.c  |  2 +-
     src/or/main.c       |  4 ++--
     src/or/router.c     | 26 ++++++--------------------
     src/or/router.h     |  2 --
     src/or/routerlist.c |  4 ++--
     6 files changed, 12 insertions(+), 28 deletions(-)
    
    diff --git a/src/or/config.c b/src/or/config.c
    index c96f42c6e..776730984 100644
    a b options_validate(or_options_t *old_options, or_options_t *options, 
    31523152               "UseEntryGuards. Disabling.");
    31533153      options->UseEntryGuards = 0;
    31543154    }
    3155     if (!options->DownloadExtraInfo && authdir_mode_any_main(options)) {
     3155    if (!options->DownloadExtraInfo && options->V3AuthoritativeDir) {
    31563156      log_info(LD_CONFIG, "Authoritative directories always try to download "
    31573157               "extra-info documents. Setting DownloadExtraInfo.");
    31583158      options->DownloadExtraInfo = 1;
  • src/or/directory.c

    diff --git a/src/or/directory.c b/src/or/directory.c
    index 740333d46..c2fc6557a 100644
    a b directory_handle_command_post,(dir_connection_t *conn, const char *headers, 
    48124812    goto done;
    48134813  }
    48144814
    4815   if (authdir_mode_handles_descs(options, -1) &&
     4815  if (authdir_mode(options) &&
    48164816      !strcmp(url,"/tor/")) { /* server descriptor post */
    48174817    const char *msg = "[None]";
    48184818    uint8_t purpose = authdir_mode_bridge(options) ?
  • src/or/main.c

    diff --git a/src/or/main.c b/src/or/main.c
    index 2520a7e21..30962d7aa 100644
    a b do_hup(void) 
    23492349      tor_free(msg);
    23502350    }
    23512351  }
    2352   if (authdir_mode_handles_descs(options, -1)) {
     2352  if (authdir_mode(options)) {
    23532353    /* reload the approved-routers file */
    23542354    if (dirserv_load_fingerprint_file() < 0) {
    23552355      /* warnings are logged from dirserv_load_fingerprint_file() directly */
    sandbox_init_filter(void) 
    34713471  if (options->BridgeAuthoritativeDir)
    34723472    OPEN_DATADIR_SUFFIX("networkstatus-bridges", ".tmp");
    34733473
    3474   if (authdir_mode_handles_descs(options, -1))
     3474  if (authdir_mode(options))
    34753475    OPEN_DATADIR("approved-routers");
    34763476
    34773477  if (options->ServerDNSResolvConfFile)
  • src/or/router.c

    diff --git a/src/or/router.c b/src/or/router.c
    index 642f415a3..bf39fa9c0 100644
    a b init_keys(void) 
    10641064  /* 4. Build our router descriptor. */
    10651065  /* Must be called after keys are initialized. */
    10661066  mydesc = router_get_my_descriptor();
    1067   if (authdir_mode_handles_descs(options, ROUTER_PURPOSE_GENERAL)) {
     1067  if (authdir_mode_v3(options)) {
    10681068    const char *m = NULL;
    10691069    routerinfo_t *ri;
    10701070    /* We need to add our own fingerprint so it gets recognized. */
    authdir_mode_v3(const or_options_t *options) 
    15951595{
    15961596  return authdir_mode(options) && options->V3AuthoritativeDir != 0;
    15971597}
    1598 /** Return true iff we are a v3 directory authority. */
    1599 int
    1600 authdir_mode_any_main(const or_options_t *options)
    1601 {
    1602   return options->V3AuthoritativeDir;
    1603 }
    1604 /** Return true if we believe ourselves to be any kind of
    1605  * authoritative directory beyond just a hidserv authority. */
    1606 int
    1607 authdir_mode_any_nonhidserv(const or_options_t *options)
    1608 {
    1609   return options->BridgeAuthoritativeDir ||
    1610          authdir_mode_any_main(options);
    1611 }
    16121598/** Return true iff we are an authoritative directory server that is
    16131599 * authoritative about receiving and serving descriptors of type
    16141600 * <b>purpose</b> on its dirport.  Use -1 for "any purpose". */
    int 
    16161602authdir_mode_handles_descs(const or_options_t *options, int purpose)
    16171603{
    16181604  if (purpose < 0)
    1619     return authdir_mode_any_nonhidserv(options);
     1605    return authdir_mode(options);
    16201606  else if (purpose == ROUTER_PURPOSE_GENERAL)
    1621     return authdir_mode_any_main(options);
     1607    return authdir_mode_v3(options);
    16221608  else if (purpose == ROUTER_PURPOSE_BRIDGE)
    1623     return (options->BridgeAuthoritativeDir);
     1609    return authdir_mode_bridge(options);
    16241610  else
    16251611    return 0;
    16261612}
    authdir_mode_publishes_statuses(const or_options_t *options) 
    16321618{
    16331619  if (authdir_mode_bridge(options))
    16341620    return 0;
    1635   return authdir_mode_any_nonhidserv(options);
     1621  return authdir_mode(options);
    16361622}
    16371623/** Return true iff we are an authoritative directory server that
    16381624 * tests reachability of the descriptors it learns about.
    authdir_mode_publishes_statuses(const or_options_t *options) 
    16401626int
    16411627authdir_mode_tests_reachability(const or_options_t *options)
    16421628{
    1643   return authdir_mode_handles_descs(options, -1);
     1629  return authdir_mode(options);
    16441630}
    16451631/** Return true iff we believe ourselves to be a bridge authoritative
    16461632 * directory server.
  • src/or/router.h

    diff --git a/src/or/router.h b/src/or/router.h
    index 9c5def521..97f331713 100644
    a b int net_is_disabled(void); 
    5454
    5555int authdir_mode(const or_options_t *options);
    5656int authdir_mode_v3(const or_options_t *options);
    57 int authdir_mode_any_main(const or_options_t *options);
    58 int authdir_mode_any_nonhidserv(const or_options_t *options);
    5957int authdir_mode_handles_descs(const or_options_t *options, int purpose);
    6058int authdir_mode_publishes_statuses(const or_options_t *options);
    6159int authdir_mode_tests_reachability(const or_options_t *options);
  • src/or/routerlist.c

    diff --git a/src/or/routerlist.c b/src/or/routerlist.c
    index a790265af..fa30454de 100644
    a b launch_descriptor_downloads(int purpose, 
    50325032    }
    50335033  }
    50345034
    5035   if (!authdir_mode_any_nonhidserv(options)) {
     5035  if (!authdir_mode(options)) {
    50365036    /* If we wind up going to the authorities, we want to only open one
    50375037     * connection to each authority at a time, so that we don't overload
    50385038     * them.  We do this by setting PDS_NO_EXISTING_SERVERDESC_FETCH
    update_consensus_router_descriptor_downloads(time_t now, int is_vote, 
    51635163      smartlist_add(downloadable, rs->descriptor_digest);
    51645164  } SMARTLIST_FOREACH_END(rsp);
    51655165
    5166   if (!authdir_mode_handles_descs(options, ROUTER_PURPOSE_GENERAL)
     5166  if (!authdir_mode_v3(options)
    51675167      && smartlist_len(no_longer_old)) {
    51685168    routerlist_t *rl = router_get_routerlist();
    51695169    log_info(LD_DIR, "%d router descriptors listed in consensus are "