[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] prop224: Add client code to handle fetched HS descriptors.
commit f93b77a18c5d1e77cb80fec0827d82d3672f9673
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date: Thu Jun 1 14:25:46 2017 +0300
prop224: Add client code to handle fetched HS descriptors.
This code handles received HS descriptors by storing them in the
client-side HS cache.
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/or/directory.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/or/directory.h | 4 ++++
2 files changed, 59 insertions(+)
diff --git a/src/or/directory.c b/src/or/directory.c
index 010bc8c7b..58d2e3307 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2538,6 +2538,9 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
case DIR_PURPOSE_UPLOAD_HSDESC:
rv = handle_response_upload_hsdesc(conn, &args);
break;
+ case DIR_PURPOSE_FETCH_HSDESC:
+ rv = handle_response_fetch_hsdesc_v3(conn, &args);
+ break;
default:
tor_assert_nonfatal_unreached();
rv = -1;
@@ -3083,6 +3086,58 @@ handle_response_upload_signatures(dir_connection_t *conn,
}
/**
+ * Handler function: processes a response to a request for a v3 hidden service
+ * descriptor.
+ **/
+STATIC int
+handle_response_fetch_hsdesc_v3(dir_connection_t *conn,
+ const response_handler_args_t *args)
+{
+ const int status_code = args->status_code;
+ const char *reason = args->reason;
+ const char *body = args->body;
+ const size_t body_len = args->body_len;
+
+ tor_assert(conn->hs_ident);
+
+ log_info(LD_REND,"Received v3 hsdesc (body size %d, status %d (%s))",
+ (int)body_len, status_code, escaped(reason));
+
+ switch (status_code) {
+ case 200:
+ /* We got something: Try storing it in the cache. */
+ if (hs_cache_store_as_client(body, &conn->hs_ident->identity_pk) < 0) {
+ log_warn(LD_REND, "Failed to store hidden service descriptor");
+ } else {
+ log_info(LD_REND, "Stored hidden service descriptor successfully.");
+ }
+ break;
+ case 404:
+ /* Not there. We'll retry when connection_about_to_close_connection()
+ * tries to clean this conn up. */
+ log_info(LD_REND, "Fetching hidden service v3 descriptor not found: "
+ "Retrying at another directory.");
+ /* TODO: Inform the control port */
+ break;
+ case 400:
+ log_warn(LD_REND, "Fetching v3 hidden service descriptor failed: "
+ "http status 400 (%s). Dirserver didn't like our "
+ "query? Retrying at another directory.",
+ escaped(reason));
+ break;
+ default:
+ log_warn(LD_REND, "Fetching v3 hidden service descriptor failed: "
+ "http status %d (%s) response unexpected from HSDir server "
+ "'%s:%d'. Retrying at another directory.",
+ status_code, escaped(reason), TO_CONN(conn)->address,
+ TO_CONN(conn)->port);
+ break;
+ }
+
+ return 0;
+}
+
+/**
* Handler function: processes a response to a request for a v2 hidden service
* descriptor.
**/
diff --git a/src/or/directory.h b/src/or/directory.h
index d3f8a45a8..92d9b266d 100644
--- a/src/or/directory.h
+++ b/src/or/directory.h
@@ -176,6 +176,10 @@ STATIC char *accept_encoding_header(void);
STATIC int allowed_anonymous_connection_compression_method(compress_method_t);
STATIC void warn_disallowed_anonymous_compression_method(compress_method_t);
+typedef struct response_handler_args_t response_handler_args_t;
+STATIC int handle_response_fetch_hsdesc_v3(dir_connection_t *conn,
+ const response_handler_args_t *args);
+
#endif
#ifdef TOR_UNIT_TESTS
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits