diff options
author | David Goulet <dgoulet@torproject.org> | 2021-11-04 10:26:04 -0400 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2022-02-22 19:28:34 +0000 |
commit | 95639f35aede81bfde8bd4ee1616e10048176cc7 (patch) | |
tree | ade1de734bc5c2b80d1b700bc26ad3642d053d02 /src | |
parent | 02f4e7b42e2158039a138c9cb68211304a754a1d (diff) | |
download | tor-95639f35aede81bfde8bd4ee1616e10048176cc7.tar.gz tor-95639f35aede81bfde8bd4ee1616e10048176cc7.zip |
hs: Encode flow control value in the descriptor
This simply adds the "flow-control" line, as detailed in prop324, to the
descriptor. No decoding is done at this commit.
Part of #40506
Diffstat (limited to 'src')
-rw-r--r-- | src/feature/dirparse/parsecommon.h | 1 | ||||
-rw-r--r-- | src/feature/hs/hs_descriptor.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/feature/dirparse/parsecommon.h b/src/feature/dirparse/parsecommon.h index 0f343e9c62..675c5f68d5 100644 --- a/src/feature/dirparse/parsecommon.h +++ b/src/feature/dirparse/parsecommon.h @@ -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, diff --git a/src/feature/hs/hs_descriptor.c b/src/feature/hs/hs_descriptor.c index a37eab5b5d..80273c27b1 100644 --- a/src/feature/hs/hs_descriptor.c +++ b/src/feature/hs/hs_descriptor.c @@ -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. */ |