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()
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);
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) {
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;
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;
-}
-
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,
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);
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");