diff options
author | Alexander Færøy <ahf@torproject.org> | 2023-07-21 02:10:21 +0200 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2024-06-18 15:15:20 -0400 |
commit | f45934448849a931be09aed7dd0ac3d275b218e4 (patch) | |
tree | e48703d8f59bfb159bd5458fa884c81edce8e375 | |
parent | d27ce6b8f0ad716597df888f19b7593a5a11f476 (diff) | |
download | tor-f45934448849a931be09aed7dd0ac3d275b218e4.tar.gz tor-f45934448849a931be09aed7dd0ac3d275b218e4.zip |
Include "IMPLEMENTATION" parameter to STATUS TYPE=version PT messages.
-rw-r--r-- | src/feature/client/transports.c | 12 | ||||
-rw-r--r-- | src/feature/client/transports.h | 3 | ||||
-rw-r--r-- | src/test/test_pt.c | 7 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/feature/client/transports.c b/src/feature/client/transports.c index 8c3b71f7d0..416e538efc 100644 --- a/src/feature/client/transports.c +++ b/src/feature/client/transports.c @@ -743,6 +743,7 @@ managed_proxy_destroy(managed_proxy_t *mp, /* free our version, if any is set. */ tor_free(mp->version); + tor_free(mp->implementation); /* do we want to terminate our process if it's still running? */ if (also_terminate_process && mp->process) { @@ -1318,6 +1319,8 @@ handle_status_message(const config_line_t *values, /* Handle VERSION messages. */ if (! strcasecmp(message_type->value, "version")) { const config_line_t *version = config_line_find(values, "VERSION"); + const config_line_t *implementation = config_line_find(values, + "IMPLEMENTATION"); if (version == NULL) { log_warn(LD_PT, "Managed proxy \"%s\" wrote a STATUS TYPE=version line " @@ -1325,9 +1328,18 @@ handle_status_message(const config_line_t *values, return; } + if (implementation == NULL) { + log_warn(LD_PT, "Managed proxy \"%s\" wrote a STATUS TYPE=version line " + "with a missing IMPLEMENTATION field", mp->argv[0]); + return; + } + tor_free(mp->version); mp->version = tor_strdup(version->value); + tor_free(mp->implementation); + mp->implementation = tor_strdup(implementation->value); + return; } } diff --git a/src/feature/client/transports.h b/src/feature/client/transports.h index 1f6c10961d..71e7feea37 100644 --- a/src/feature/client/transports.h +++ b/src/feature/client/transports.h @@ -117,6 +117,9 @@ typedef struct { /** Version as set by STATUS TYPE=version messages. */ char *version; + /** Implementation as set by the STATUS TYPE=version messages. */ + char *implementation; + /* The 'transports' list contains all the transports this proxy has launched. */ smartlist_t *transports; diff --git a/src/test/test_pt.c b/src/test/test_pt.c index e97b0b2087..7725a82233 100644 --- a/src/test/test_pt.c +++ b/src/test/test_pt.c @@ -160,12 +160,17 @@ test_pt_status_parsing(void *arg) /* STATUS TYPE=version messages. */ tt_ptr_op(mp->version, OP_EQ, NULL); - strlcpy(line, "STATUS TRANSPORT=x " + tt_ptr_op(mp->implementation, OP_EQ, NULL); + + strlcpy(line, "STATUS " + "IMPLEMENTATION=xyz " "TYPE=version " "VERSION=\"1.33.7-hax beta\"", sizeof(line)); handle_proxy_line(line, mp); + tt_str_op(mp->version, OP_EQ, "1.33.7-hax beta"); + tt_str_op(mp->implementation, OP_EQ, "xyz"); reset_mp(mp); |