From e167910fce2b83d9de3a252cdf02cabdafced14b Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Fri, 11 Mar 2016 10:40:31 -0500 Subject: rip out hid_serv_responsible_for_desc_id() This simplifies relay behavior, because the relay offers the hsdir functionality independent of whether the directory authorities have decided this relay is suitable for clients to use yet. Implements ticket 18332. --- src/or/rendcommon.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/or/rendcommon.h') diff --git a/src/or/rendcommon.h b/src/or/rendcommon.h index fe45299598..b3ae790518 100644 --- a/src/or/rendcommon.h +++ b/src/or/rendcommon.h @@ -60,7 +60,6 @@ void rend_get_descriptor_id_bytes(char *descriptor_id_out, int hid_serv_get_responsible_directories(smartlist_t *responsible_dirs, const char *id); int hid_serv_acting_as_directory(void); -MOCK_DECL(int, hid_serv_responsible_for_desc_id, (const char *id)); rend_data_t *rend_data_dup(const rend_data_t *data); rend_data_t *rend_data_client_create(const char *onion_address, -- cgit v1.2.3-54-g00ecf From 53902963383e1babfccb8a4ffc7ed4e8accf2214 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Fri, 11 Mar 2016 10:45:03 -0500 Subject: 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(-) (limited to 'src/or/rendcommon.h') 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"); -- cgit v1.2.3-54-g00ecf From dc500c8cb4dc7643230d160d1b458a0acdadd242 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Fri, 11 Mar 2016 10:46:21 -0500 Subject: rip out rend_id_is_in_interval() it was used by hid_serv_responsible_for_desc_id(), which we no longer use. --- src/or/rendcommon.c | 31 ------------------------------- src/or/rendcommon.h | 1 - 2 files changed, 32 deletions(-) (limited to 'src/or/rendcommon.h') diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index 79aba80694..438fbc4d9a 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -688,37 +688,6 @@ rend_get_service_id(crypto_pk_t *pk, char *out) return 0; } -/** Determines whether a is in the interval of b (excluded) and - * c (included) in a circular digest ring; returns 1 if this is the - * case, and 0 otherwise. - */ -int -rend_id_is_in_interval(const char *a, const char *b, const char *c) -{ - int a_b, b_c, c_a; - tor_assert(a); - tor_assert(b); - tor_assert(c); - - /* There are five cases in which a is outside the interval ]b,c]: */ - a_b = tor_memcmp(a,b,DIGEST_LEN); - if (a_b == 0) - return 0; /* 1. a == b (b is excluded) */ - b_c = tor_memcmp(b,c,DIGEST_LEN); - if (b_c == 0) - return 0; /* 2. b == c (interval is empty) */ - else if (a_b <= 0 && b_c < 0) - return 0; /* 3. a b c */ - c_a = tor_memcmp(c,a,DIGEST_LEN); - if (c_a < 0 && a_b <= 0) - return 0; /* 4. c a b */ - else if (b_c < 0 && c_a < 0) - return 0; /* 5. b c a */ - - /* In the other cases (a c b; b a c; c b a), a is inside the interval. */ - return 1; -} - /** Return true iff query is a syntactically valid service ID (as * generated by rend_get_service_id). */ int diff --git a/src/or/rendcommon.h b/src/or/rendcommon.h index bab53fc1f6..c520c0634d 100644 --- a/src/or/rendcommon.h +++ b/src/or/rendcommon.h @@ -53,7 +53,6 @@ int rend_encode_v2_descriptors(smartlist_t *descs_out, int rend_compute_v2_desc_id(char *desc_id_out, const char *service_id, const char *descriptor_cookie, time_t now, uint8_t replica); -int rend_id_is_in_interval(const char *a, const char *b, const char *c); void rend_get_descriptor_id_bytes(char *descriptor_id_out, const char *service_id, const char *secret_id_part); -- cgit v1.2.3-54-g00ecf