]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Include "IMPLEMENTATION" parameter to STATUS TYPE=version PT messages.
authorAlexander Færøy <ahf@torproject.org>
Fri, 21 Jul 2023 00:10:21 +0000 (02:10 +0200)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 18 Jun 2024 19:15:20 +0000 (15:15 -0400)
src/feature/client/transports.c
src/feature/client/transports.h
src/test/test_pt.c

index 8c3b71f7d0a2264c44081758921219c675f27cb7..416e538efc94ef27f22d1d1749473c3d6e41e357 100644 (file)
@@ -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;
   }
 }
index 1f6c10961d180f3f96c76e1777635d9154dc5125..71e7feea379991fe41efd2689b2320766f470556 100644 (file)
@@ -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;
index e97b0b2087f915a6ff587c53e7d2b26d3c255947..7725a82233f23e7c004ae15bb03477b74c1d68bc 100644 (file)
@@ -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);