]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
hs: Encode flow control value in the descriptor
authorDavid Goulet <dgoulet@torproject.org>
Thu, 4 Nov 2021 14:26:04 +0000 (10:26 -0400)
committerMike Perry <mikeperry-git@torproject.org>
Tue, 22 Feb 2022 19:28:34 +0000 (19:28 +0000)
This simply adds the "flow-control" line, as detailed in prop324, to the
descriptor. No decoding is done at this commit.

Part of #40506

src/feature/dirparse/parsecommon.h
src/feature/hs/hs_descriptor.c

index 0f343e9c624f01bd9c1985c911d3d85e25a1ffe3..675c5f68d56c13e3e8afbcc8f2a0ed6060648897 100644 (file)
@@ -172,6 +172,7 @@ typedef enum {
   R3_DESC_AUTH_KEY,
   R3_DESC_AUTH_CLIENT,
   R3_ENCRYPTED,
+  R3_FLOW_CONTROL,
 
   R_IPO_IDENTIFIER,
   R_IPO_IP_ADDRESS,
index a37eab5b5dc189c6a69ffbf14d4d405e199434e2..80273c27b153b6f52b6a43a053ec2e276e6f728c 100644 (file)
@@ -61,6 +61,8 @@
 #include "trunnel/ed25519_cert.h" /* Trunnel interface. */
 #include "feature/hs/hs_descriptor.h"
 #include "core/or/circuitbuild.h"
+#include "core/or/congestion_control_common.h"
+#include "core/or/protover.h"
 #include "lib/crypt_ops/crypto_rand.h"
 #include "lib/crypt_ops/crypto_util.h"
 #include "feature/dirparse/parsecommon.h"
@@ -69,6 +71,7 @@
 #include "feature/nodelist/torcert.h" /* tor_cert_encode_ed22519() */
 #include "lib/memarea/memarea.h"
 #include "lib/crypt_ops/crypto_format.h"
+#include "core/or/versions.h"
 
 #include "core/or/extend_info_st.h"
 
@@ -92,6 +95,7 @@
 #define str_ip_legacy_key "legacy-key"
 #define str_ip_legacy_key_cert "legacy-key-cert"
 #define str_intro_point_start "\n" str_intro_point " "
+#define str_flow_control "flow-control"
 /* Constant string value for the construction to encrypt the encrypted data
  * section. */
 #define str_enc_const_superencryption "hsdir-superencrypted-data"
@@ -138,6 +142,7 @@ static token_rule_t hs_desc_encrypted_v3_token_table[] = {
   T1_START(str_create2_formats, R3_CREATE2_FORMATS, CONCAT_ARGS, NO_OBJ),
   T01(str_intro_auth_required, R3_INTRO_AUTH_REQUIRED, GE(1), NO_OBJ),
   T01(str_single_onion, R3_SINGLE_ONION_SERVICE, ARGS, NO_OBJ),
+  T01(str_flow_control, R3_FLOW_CONTROL, GE(2), NO_OBJ),
   END_OF_TABLE
 };
 
@@ -765,6 +770,13 @@ get_inner_encrypted_layer_plaintext(const hs_descriptor_t *desc)
     if (desc->encrypted_data.single_onion_service) {
       smartlist_add_asprintf(lines, "%s\n", str_single_onion);
     }
+
+    if (congestion_control_enabled()) {
+      /* Add flow control line into the descriptor. */
+      smartlist_add_asprintf(lines, "%s %s %u\n", str_flow_control,
+                             protover_get_supported(PRT_FLOWCTRL),
+                             congestion_control_sendme_inc());
+    }
   }
 
   /* Build the introduction point(s) section. */