summaryrefslogtreecommitdiff
path: root/src/feature/hs
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2022-02-03 20:06:36 +0000
committerMike Perry <mikeperry-git@torproject.org>2022-02-22 19:28:34 +0000
commit89f5eeefb83231c6eb7b8a857b173a9f962f3c0d (patch)
tree2095691800547cf08dec4aa2e6cd8e7a3bfda1e5 /src/feature/hs
parent95639f35aede81bfde8bd4ee1616e10048176cc7 (diff)
downloadtor-89f5eeefb83231c6eb7b8a857b173a9f962f3c0d.tar.gz
tor-89f5eeefb83231c6eb7b8a857b173a9f962f3c0d.zip
hs: Decode flow-control line
This puts the flow control version (unparsed) in the descriptor. The client doesn't use it yet. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/hs')
-rw-r--r--src/feature/hs/hs_descriptor.c18
-rw-r--r--src/feature/hs/hs_descriptor.h4
2 files changed, 22 insertions, 0 deletions
diff --git a/src/feature/hs/hs_descriptor.c b/src/feature/hs/hs_descriptor.c
index 80273c27b1..523ededf8c 100644
--- a/src/feature/hs/hs_descriptor.c
+++ b/src/feature/hs/hs_descriptor.c
@@ -2347,6 +2347,23 @@ desc_decode_encrypted_v3(const hs_descriptor_t *desc,
desc_encrypted_out->single_onion_service = 1;
}
+ /* Get flow control if any. */
+ tok = find_opt_by_keyword(tokens, R3_FLOW_CONTROL);
+ if (tok) {
+ int ok;
+
+ tor_asprintf(&desc_encrypted_out->flow_control_pv, "FlowCtrl=%s",
+ tok->args[0]);
+ uint8_t sendme_inc =
+ (uint8_t) tor_parse_uint64(tok->args[1], 10, 0, UINT8_MAX, &ok, NULL);
+ if (!ok || !congestion_control_validate_sendme_increment(sendme_inc)) {
+ log_warn(LD_REND, "Service descriptor flow control sendme "
+ "value is invalid");
+ goto err;
+ }
+ desc_encrypted_out->sendme_inc = sendme_inc;
+ }
+
/* 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();
@@ -2757,6 +2774,7 @@ hs_desc_encrypted_data_free_contents(hs_desc_encrypted_data_t *desc)
hs_desc_intro_point_free(ip));
smartlist_free(desc->intro_points);
}
+ tor_free(desc->flow_control_pv);
memwipe(desc, 0, sizeof(*desc));
}
diff --git a/src/feature/hs/hs_descriptor.h b/src/feature/hs/hs_descriptor.h
index d959431369..8f5ee6a2f1 100644
--- a/src/feature/hs/hs_descriptor.h
+++ b/src/feature/hs/hs_descriptor.h
@@ -167,6 +167,10 @@ typedef struct hs_desc_encrypted_data_t {
/** Is this descriptor a single onion service? */
unsigned int single_onion_service : 1;
+ /** Flow control protocol version line. */
+ char *flow_control_pv;
+ uint8_t sendme_inc;
+
/** A list of intro points. Contains hs_desc_intro_point_t objects. */
smartlist_t *intro_points;
} hs_desc_encrypted_data_t;