aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/or/hs_descriptor.c13
-rw-r--r--src/or/hs_descriptor.h3
-rw-r--r--src/or/parsecommon.h1
-rw-r--r--src/test/test_hs_descriptor.c1
4 files changed, 18 insertions, 0 deletions
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index 96db936735..1517ccb12e 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 8bc725674e..895bed2485 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 3a86c52f3c..3019df63eb 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 6c88cc1017..66ed3cea72 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) {