aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2024-06-11 12:38:56 -0400
committerDavid Goulet <dgoulet@torproject.org>2024-06-18 15:15:32 -0400
commitd587ba01a70b81e8c15f6e53e72c133ebe977719 (patch)
treee84a0f16c25ee839229cd26c125576bbe78f5394
parent1941f25f4ccdab3f0a94ccac8232c958153e3f2a (diff)
downloadtor-d587ba01a70b81e8c15f6e53e72c133ebe977719.tar.gz
tor-d587ba01a70b81e8c15f6e53e72c133ebe977719.zip
bridge: Always put transport-info line
Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r--src/feature/client/transports.c19
-rw-r--r--src/test/test_pt.c4
2 files changed, 13 insertions, 10 deletions
diff --git a/src/feature/client/transports.c b/src/feature/client/transports.c
index 403bedc183..878675ac4d 100644
--- a/src/feature/client/transports.c
+++ b/src/feature/client/transports.c
@@ -1798,20 +1798,21 @@ pt_get_extra_info_descriptor_string(void)
/* Set transport-info line. */
{
- char *transport_info_args = NULL;
+ char *version = NULL;
+ char *impl = NULL;
if (mp->version) {
- tor_asprintf(&transport_info_args, " version=%s", mp->version);
+ tor_asprintf(&version, " version=%s", mp->version);
}
if (mp->implementation) {
- tor_asprintf(&transport_info_args, " implementation=%s",
- mp->implementation);
- }
- if (transport_info_args) {
- smartlist_add_asprintf(string_chunks, "transport-info%s",
- transport_info_args ? transport_info_args : "");
- tor_free(transport_info_args);
+ tor_asprintf(&impl, " implementation=%s", mp->implementation);
}
+ /* Always put in the line even if empty. Else, we don't know to which
+ * transport this applies to. */
+ smartlist_add_asprintf(string_chunks, "transport-info%s%s",
+ version ? version: "", impl ? impl: "");
+ tor_free(version);
+ tor_free(impl);
}
} SMARTLIST_FOREACH_END(mp);
diff --git a/src/test/test_pt.c b/src/test/test_pt.c
index 62519a235f..10bf7829d1 100644
--- a/src/test/test_pt.c
+++ b/src/test/test_pt.c
@@ -413,7 +413,9 @@ test_pt_get_extrainfo_string(void *arg)
tt_assert(s);
tt_str_op(s, OP_EQ,
"transport hagbard 127.0.0.1:5555\n"
- "transport celine 127.0.0.1:1723 card=no-enemy\n");
+ "transport-info\n"
+ "transport celine 127.0.0.1:1723 card=no-enemy\n"
+ "transport-info\n");
done:
/* XXXX clean up better */