[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add a new function, tor_api_get_provider_version()



commit 772106c6bc37966f60be99a479240ced8abfea1b
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Jul 31 09:17:32 2018 -0400

    Add a new function, tor_api_get_provider_version()
    
    Closes ticket 26947.
---
 changes/ticket26947       |  3 +++
 src/feature/api/tor_api.c |  7 ++++++-
 src/feature/api/tor_api.h | 12 +++++++++++-
 src/tools/tor_runner.c    |  7 ++++++-
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/changes/ticket26947 b/changes/ticket26947
new file mode 100644
index 000000000..620a3a559
--- /dev/null
+++ b/changes/ticket26947
@@ -0,0 +1,3 @@
+  o Minor features (in-process API):
+    - The tor_api now has a function that returns the name and version
+      of the backend implementing the API. Closes ticket 26947.
diff --git a/src/feature/api/tor_api.c b/src/feature/api/tor_api.c
index 2a4458bf6..a53ade1f3 100644
--- a/src/feature/api/tor_api.c
+++ b/src/feature/api/tor_api.c
@@ -61,6 +61,12 @@ tor_main_configuration_free(tor_main_configuration_t *cfg)
   raw_free(cfg);
 }
 
+const char *
+tor_api_get_provider_version(void)
+{
+  return "tor " VERSION;
+}
+
 /* Main entry point for the Tor process.  Called from main().
  *
  * This function is distinct from main() only so we can link main.c into
@@ -85,4 +91,3 @@ tor_main(int argc, char *argv[])
   tor_main_configuration_free(cfg);
   return rv;
 }
-
diff --git a/src/feature/api/tor_api.h b/src/feature/api/tor_api.h
index ead9493c1..a08606ee3 100644
--- a/src/feature/api/tor_api.h
+++ b/src/feature/api/tor_api.h
@@ -58,6 +58,17 @@ int tor_main_configuration_set_command_line(tor_main_configuration_t *cfg,
 void tor_main_configuration_free(tor_main_configuration_t *cfg);
 
 /**
+ * Return the name and version of the software implementing the tor_api
+ * functionality.  Current implementors are "tor" and "libtorrunner".
+ *
+ * Note that if you're using libtorrunner, you'll see the version of
+ * libtorrunner, not the version of Tor that it's invoking for you.
+ *
+ * Added in Tor 0.3.5.1-alpha.
+ **/
+const char *tor_api_get_provider_version(void);
+
+/**
  * Run the tor process, as if from the command line.
  *
  * The command line arguments from tor_main_configuration_set_command_line()
@@ -98,4 +109,3 @@ int tor_run_main(const tor_main_configuration_t *);
 int tor_main(int argc, char **argv);
 
 #endif /* !defined(TOR_API_H) */
-
diff --git a/src/tools/tor_runner.c b/src/tools/tor_runner.c
index dd90af3df..f8805e650 100644
--- a/src/tools/tor_runner.c
+++ b/src/tools/tor_runner.c
@@ -46,6 +46,12 @@
 static void child(const tor_main_configuration_t *cfg)
   __attribute__((noreturn));
 
+const char *
+tor_api_get_provider_version(void)
+{
+  return "libtorrunner " VERSION;
+}
+
 int
 tor_run_main(const tor_main_configuration_t *cfg)
 {
@@ -98,4 +104,3 @@ child(const tor_main_configuration_t *cfg)
     abort(); /* Unreachable */
   }
 }
-



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits