summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-06-27 09:46:16 -0400
committerDavid Goulet <dgoulet@torproject.org>2017-08-24 13:03:28 -0400
commit343af1a9cf64e060150caf7b53e513315cc37f72 (patch)
tree60306571d2c6ba1b4db03d91a25043ce1b04f3de /src/or
parentf93b77a18c5d1e77cb80fec0827d82d3672f9673 (diff)
downloadtor-343af1a9cf64e060150caf7b53e513315cc37f72.tar.gz
tor-343af1a9cf64e060150caf7b53e513315cc37f72.zip
prop224: Add the dir purpose HAS_FETCHED
Once a descriptor has been successfully downloaded from an HSDir, we flag the directory connection to "has fetched descriptor" so the connection subsystem doesn't trigger a new fetch on success. Same has DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2 but for prop224. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or')
-rw-r--r--src/or/directory.c11
-rw-r--r--src/or/or.h5
2 files changed, 11 insertions, 5 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 58d2e33070..698ee90139 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -184,6 +184,7 @@ purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose,
case DIR_PURPOSE_FETCH_EXTRAINFO:
case DIR_PURPOSE_FETCH_MICRODESC:
return 0;
+ case DIR_PURPOSE_HAS_FETCHED_HSDESC:
case DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2:
case DIR_PURPOSE_UPLOAD_RENDDESC_V2:
case DIR_PURPOSE_FETCH_RENDDESC_V2:
@@ -1126,6 +1127,7 @@ directory_request_new(uint8_t dir_purpose)
tor_assert(dir_purpose <= DIR_PURPOSE_MAX_);
tor_assert(dir_purpose != DIR_PURPOSE_SERVER);
tor_assert(dir_purpose != DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2);
+ tor_assert(dir_purpose != DIR_PURPOSE_HAS_FETCHED_HSDESC);
directory_request_t *result = tor_malloc_zero(sizeof(*result));
tor_addr_make_null(&result->or_addr_port.addr, AF_INET);
@@ -3110,6 +3112,7 @@ handle_response_fetch_hsdesc_v3(dir_connection_t *conn,
log_warn(LD_REND, "Failed to store hidden service descriptor");
} else {
log_info(LD_REND, "Stored hidden service descriptor successfully.");
+ TO_CONN(conn)->purpose = DIR_PURPOSE_HAS_FETCHED_HSDESC;
}
break;
case 404:
@@ -3409,10 +3412,10 @@ refetch_hsdesc_if_needed(dir_connection_t *dir_conn)
{
connection_t *conn = TO_CONN(dir_conn);
- /* If we were trying to fetch a v2 rend desc and did not succeed,
- * retry as needed. (If a fetch is successful, the connection state
- * is changed to DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2 to mark that
- * refetching is unnecessary.) */
+ /* If we were trying to fetch a v2 rend desc and did not succeed, retry as
+ * needed. (If a fetch is successful, the connection state is changed to
+ * DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2 or DIR_PURPOSE_HAS_FETCHED_HSDESC to
+ * mark that refetching is unnecessary.) */
if (conn->purpose == DIR_PURPOSE_FETCH_RENDDESC_V2 &&
dir_conn->rend_data &&
rend_valid_v2_service_id(
diff --git a/src/or/or.h b/src/or/or.h
index ff11c72790..3cd8239f1c 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -425,7 +425,10 @@ typedef enum {
#define DIR_PURPOSE_UPLOAD_HSDESC 20
/** A connection to a hidden service directory: fetch a v3 descriptor. */
#define DIR_PURPOSE_FETCH_HSDESC 21
-#define DIR_PURPOSE_MAX_ 21
+/** A connection to a directory server: set after a hidden service descriptor
+ * is downloaded. */
+#define DIR_PURPOSE_HAS_FETCHED_HSDESC 22
+#define DIR_PURPOSE_MAX_ 22
/** True iff <b>p</b> is a purpose corresponding to uploading
* data to a directory server. */