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.)
This commit is contained in:
Roger Dingledine 2016-03-11 10:45:03 -05:00
parent e167910fce
commit 5390296338
7 changed files with 0 additions and 34 deletions

View 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);

View 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) {

View 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;

View 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;
}

View 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,

View 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);

View 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");