[tor-commits] [tor/master] hs: Add single-onion-service line to v3 descriptor
nickm at torproject.org
nickm at torproject.org
Thu Nov 10 14:16:24 UTC 2016
commit 34f14a35b60522e2482fade24ab455956370eee4
Author: David Goulet <dgoulet at torproject.org>
Date: Tue Nov 8 13:22:42 2016 -0500
hs: Add single-onion-service line to v3 descriptor
This field indicates if the service is a Single Onion Service if present in
the descriptor.
Closes #19642
Signed-off-by: David Goulet <dgoulet at torproject.org>
---
src/or/hs_descriptor.c | 13 +++++++++++++
src/or/hs_descriptor.h | 3 +++
src/or/parsecommon.h | 1 +
src/test/test_hs_descriptor.c | 1 +
4 files changed, 18 insertions(+)
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index 96db936..1517ccb 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -26,6 +26,7 @@
/* Constant string value for the encrypted part of the descriptor. */
#define str_create2_formats "create2-formats"
#define str_auth_required "authentication-required"
+#define str_single_onion "single-onion-service"
#define str_intro_point "introduction-point"
#define str_ip_auth_key "auth-key"
#define str_ip_enc_key "enc-key"
@@ -63,6 +64,7 @@ static token_rule_t hs_desc_v3_token_table[] = {
static token_rule_t hs_desc_encrypted_v3_token_table[] = {
T1_START(str_create2_formats, R3_CREATE2_FORMATS, CONCAT_ARGS, NO_OBJ),
T01(str_auth_required, R3_AUTHENTICATION_REQUIRED, ARGS, NO_OBJ),
+ T01(str_single_onion, R3_SINGLE_ONION_SERVICE, ARGS, NO_OBJ),
END_OF_TABLE
};
@@ -692,6 +694,10 @@ encode_encrypted_data(const hs_descriptor_t *desc,
smartlist_add_asprintf(lines, "%s %s\n", str_auth_required, buf);
tor_free(buf);
}
+
+ if (desc->encrypted_data.single_onion_service) {
+ smartlist_add_asprintf(lines, "%s\n", str_single_onion);
+ }
}
/* Build the introduction point(s) section. */
@@ -1613,6 +1619,13 @@ desc_decode_encrypted_v3(const hs_descriptor_t *desc,
goto err;
}
}
+
+ /* Is this service a single onion service? */
+ tok = find_opt_by_keyword(tokens, R3_SINGLE_ONION_SERVICE);
+ if (tok) {
+ desc_encrypted_out->single_onion_service = 1;
+ }
+
/* Initialize the descriptor's introduction point list before we start
* decoding. Having 0 intro point is valid. Then decode them all. */
desc_encrypted_out->intro_points = smartlist_new();
diff --git a/src/or/hs_descriptor.h b/src/or/hs_descriptor.h
index 8bc7256..895bed2 100644
--- a/src/or/hs_descriptor.h
+++ b/src/or/hs_descriptor.h
@@ -128,6 +128,9 @@ typedef struct hs_desc_encrypted_data_t {
* in order to contact the service. Contains NULL terminated strings. */
smartlist_t *auth_types;
+ /* Is this descriptor a single onion service? */
+ unsigned int single_onion_service : 1;
+
/* A list of intro points. Contains hs_desc_intro_point_t objects. */
smartlist_t *intro_points;
} hs_desc_encrypted_data_t;
diff --git a/src/or/parsecommon.h b/src/or/parsecommon.h
index 3a86c52..3019df6 100644
--- a/src/or/parsecommon.h
+++ b/src/or/parsecommon.h
@@ -158,6 +158,7 @@ typedef enum {
R3_SIGNATURE,
R3_CREATE2_FORMATS,
R3_AUTHENTICATION_REQUIRED,
+ R3_SINGLE_ONION_SERVICE,
R3_INTRODUCTION_POINT,
R3_INTRO_AUTH_KEY,
R3_INTRO_ENC_KEY,
diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c
index 6c88cc1..66ed3ce 100644
--- a/src/test/test_hs_descriptor.c
+++ b/src/test/test_hs_descriptor.c
@@ -102,6 +102,7 @@ helper_build_hs_desc(unsigned int no_ip)
/* Setup encrypted data section. */
desc->encrypted_data.create2_ntor = 1;
desc->encrypted_data.auth_types = smartlist_new();
+ desc->encrypted_data.single_onion_service = 1;
smartlist_add(desc->encrypted_data.auth_types, tor_strdup("ed25519"));
desc->encrypted_data.intro_points = smartlist_new();
if (!no_ip) {
More information about the tor-commits
mailing list