]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
rip out hid_serv_acting_as_directory()
authorRoger Dingledine <arma@torproject.org>
Fri, 11 Mar 2016 15:45:03 +0000 (10:45 -0500)
committerRoger Dingledine <arma@torproject.org>
Fri, 11 Mar 2016 15:45:03 +0000 (10:45 -0500)
When we made HidServDirectoryV2 always 1, we removed the situation
where a relay could choose not to be an HSDir. Now simplify the
rest of the code to reflect this decision.

(We have to remove two apparently unrelated free() calls in the unit
tests, since they used to free stuff that we created as a side effect
of calling router_get_my_routerinfo(), and now we no longer call that.)

src/or/directory.c
src/or/rendcache.c
src/or/rendcache.h
src/or/rendcommon.c
src/or/rendcommon.h
src/test/test_dir_handle_get.c
src/test/test_rendcache.c

index e4feda44fc5a234d0fb3094e2b8bf16a44f4a1e7..961e33424b254d2a90defc0a1af45449e9bf27b1 100644 (file)
@@ -2301,7 +2301,6 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
                                   conn->requested_resource, conn->rend_data,
                                   &entry)) {
           case RCS_BADDESC:
-          case RCS_NOTDIR: /* Impossible */
             log_warn(LD_REND,"Fetching v2 rendezvous descriptor failed. "
                      "Retrying at another directory.");
             /* We'll retry when connection_about_to_close_connection()
@@ -3428,13 +3427,6 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
   if (connection_dir_is_encrypted(conn) &&
       !strcmpstart(url,"/tor/rendezvous2/publish")) {
     switch (rend_cache_store_v2_desc_as_dir(body)) {
-      case RCS_NOTDIR:
-        log_info(LD_REND, "Rejected v2 rend descriptor (length %d) from %s "
-                 "since we're not currently a hidden service directory.",
-                 (int)body_len, conn->base_.address);
-        write_http_status_line(conn, 503, "Currently not acting as v2 "
-                               "hidden service directory");
-        break;
       case RCS_BADDESC:
         log_warn(LD_REND, "Rejected v2 rend descriptor (length %d) from %s.",
                  (int)body_len, conn->base_.address);
index 6c22503e5387119a75b4f3b16791e9cc67b4c8bd..dad4b2b5ba50f748fd3616b5e632cea07e11fc97 100644 (file)
@@ -641,12 +641,6 @@ rend_cache_store_v2_desc_as_dir(const char *desc)
   time_t now = time(NULL);
   tor_assert(rend_cache_v2_dir);
   tor_assert(desc);
-  if (!hid_serv_acting_as_directory()) {
-    /* Cannot store descs, because we are (currently) not acting as
-     * hidden service directory. */
-    log_info(LD_REND, "Cannot store descs: Not acting as hs dir");
-    return RCS_NOTDIR;
-  }
   while (rend_parse_v2_service_descriptor(&parsed, desc_id, &intro_content,
                                           &intro_size, &encoded_size,
                                           &next_desc, current_desc, 1) >= 0) {
index 867270f9964b9e32b2dfb461bf8cadc53e7fcc82..3eecd3b2a0a1947a1b69fd07c6f4684364fd4dd6 100644 (file)
@@ -66,7 +66,6 @@ int rend_cache_lookup_v2_desc_as_service(const char *query,
 int rend_cache_lookup_v2_desc_as_dir(const char *query, const char **desc);
 /** Return value from rend_cache_store_v2_desc_as_{dir,client}. */
 typedef enum {
-  RCS_NOTDIR = -2, /**< We're not a directory */
   RCS_BADDESC = -1, /**< This descriptor is no good. */
   RCS_OKAY = 0 /**< All worked as expected */
 } rend_cache_store_status_t;
index f1fb0d934c1d36cdff3811f5c672d214eb5fa45a..79aba806949bd478965634a386c22a75fed4184a 100644 (file)
@@ -972,14 +972,3 @@ hid_serv_get_responsible_directories(smartlist_t *responsible_dirs,
   return smartlist_len(responsible_dirs) ? 0 : -1;
 }
 
-/** Return true if this node is currently acting as hidden service
- * directory, false otherwise. */
-int
-hid_serv_acting_as_directory(void)
-{
-  const routerinfo_t *me = router_get_my_routerinfo();
-  if (!me)
-    return 0;
-  return 1;
-}
-
index b3ae79051891a6249e3df4108a7c7d364193f554..bab53fc1f64d3e067ca19c2ac1961f792a97e632 100644 (file)
@@ -59,7 +59,6 @@ void rend_get_descriptor_id_bytes(char *descriptor_id_out,
                                   const char *secret_id_part);
 int hid_serv_get_responsible_directories(smartlist_t *responsible_dirs,
                                                                         const char *id);
-int hid_serv_acting_as_directory(void);
 
 rend_data_t *rend_data_dup(const rend_data_t *data);
 rend_data_t *rend_data_client_create(const char *onion_address,
index 67bd840baf8ee3530f947596eccd03cbeef6b4da..c75b2b6632134273e1a8124f1d501d9d072c2cd4 100644 (file)
@@ -462,8 +462,6 @@ test_dir_handle_get_rendezvous2_on_encrypted_conn_success(void *data)
   done:
     UNMOCK(connection_write_to_buf_impl_);
     NS_UNMOCK(router_get_my_routerinfo);
-    tor_free(mock_routerinfo->cache_info.signed_descriptor_body);
-    tor_free(mock_routerinfo);
 
     connection_free_(TO_CONN(conn));
     tor_free(header);
index 9898e87098f17cdbdd14bc696985e1ce662b6f66..3ccfe5f9bc9c99effcb16b60e80b884d20d95ba2 100644 (file)
@@ -454,11 +454,6 @@ test_rend_cache_store_v2_desc_as_dir(void *data)
 
   rend_cache_init();
 
-  // Test when we are not an HS dir
-  mock_routerinfo = NULL;
-  ret = rend_cache_store_v2_desc_as_dir("");
-  tt_int_op(ret, OP_EQ, RCS_NOTDIR);
-
   // Test when we can't parse the descriptor
   mock_routerinfo = tor_malloc(sizeof(routerinfo_t));
   ret = rend_cache_store_v2_desc_as_dir("unparseable");