From 53902963383e1babfccb8a4ffc7ed4e8accf2214 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Fri, 11 Mar 2016 10:45:03 -0500 Subject: [PATCH] rip out hid_serv_acting_as_directory() 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 | 8 -------- src/or/rendcache.c | 6 ------ src/or/rendcache.h | 1 - src/or/rendcommon.c | 11 ----------- src/or/rendcommon.h | 1 - src/test/test_dir_handle_get.c | 2 -- src/test/test_rendcache.c | 5 ----- 7 files changed, 34 deletions(-) diff --git a/src/or/directory.c b/src/or/directory.c index e4feda44fc..961e33424b 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -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); diff --git a/src/or/rendcache.c b/src/or/rendcache.c index 6c22503e53..dad4b2b5ba 100644 --- a/src/or/rendcache.c +++ b/src/or/rendcache.c @@ -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) { diff --git a/src/or/rendcache.h b/src/or/rendcache.h index 867270f996..3eecd3b2a0 100644 --- a/src/or/rendcache.h +++ b/src/or/rendcache.h @@ -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; diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index f1fb0d934c..79aba80694 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -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; -} - diff --git a/src/or/rendcommon.h b/src/or/rendcommon.h index b3ae790518..bab53fc1f6 100644 --- a/src/or/rendcommon.h +++ b/src/or/rendcommon.h @@ -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, diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c index 67bd840baf..c75b2b6632 100644 --- a/src/test/test_dir_handle_get.c +++ b/src/test/test_dir_handle_get.c @@ -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); diff --git a/src/test/test_rendcache.c b/src/test/test_rendcache.c index 9898e87098..3ccfe5f9bc 100644 --- a/src/test/test_rendcache.c +++ b/src/test/test_rendcache.c @@ -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"); -- 2.11.4.GIT