]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Add management client version
authorSelva Nair <selva.nair@gmail.com>
Thu, 25 Jan 2018 19:41:00 +0000 (14:41 -0500)
committerGert Doering <gert@greenie.muc.de>
Mon, 29 Jan 2018 19:14:18 +0000 (20:14 +0100)
- "version" command from client to management can now set
  the version of management interface supported by the client
  by specifying an optional integer parameter.

  If no parameter is specified the version of OpenVPN
  and its management interface is returned (current behaviour).

  The client version defaults to 1 which is the current version of
  the Management Interface.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1516909261-31623-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16363.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
doc/management-notes.txt
src/openvpn/manage.c
src/openvpn/manage.h

index 908b9813929292c7d5f0c1d6f3ca6df839ff7089..e03cd390a861347074b3c0ab12b09aa7a30ed535 100644 (file)
@@ -432,8 +432,12 @@ Command examples:
 COMMAND -- version
 ------------------
 
-Show the current OpenVPN and Management Interface versions.
+Set the version (integer) of Management Interface supported by the
+client or show the current OpenVPN and Management Interface versions.
 
+Command examples:
+  version 2  -- Change management version of client to 2 (default = 1)
+  version    -- Show the version of OpenVPN and its Management Interface
 
 COMMAND -- auth-retry
 ---------------------
index 650f9e08d0b9818600d1f3b0d5861421143e72af..c36d94d8774c4cc5b5bcf2c194ab5066a51ed25a 100644 (file)
@@ -123,7 +123,7 @@ man_help(void)
     msg(M_CLIENT, "test n                 : Produce n lines of output for testing/debugging.");
     msg(M_CLIENT, "username type u        : Enter username u for a queried OpenVPN username.");
     msg(M_CLIENT, "verb [n]               : Set log verbosity level to n, or show if n is absent.");
-    msg(M_CLIENT, "version                : Show current version number.");
+    msg(M_CLIENT, "version [n]            : Set client's version to n or show current version of daemon.");
     msg(M_CLIENT, "END");
 }
 
@@ -1240,6 +1240,15 @@ man_network_change(struct management *man, bool samenetwork)
 }
 #endif
 
+static void
+set_client_version(struct management *man, const char *version)
+{
+    if (version)
+    {
+        man->connection.client_version = atoi(version);
+    }
+}
+
 static void
 man_dispatch_command(struct management *man, struct status_output *so, const char **p, const int nparms)
 {
@@ -1255,6 +1264,10 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha
     {
         man_help();
     }
+    else if (streq(p[0], "version") && p[1])
+    {
+        set_client_version(man, p[1]);
+    }
     else if (streq(p[0], "version"))
     {
         msg(M_CLIENT, "OpenVPN Version: %s", title_string);
@@ -2508,6 +2521,8 @@ man_connection_init(struct management *man)
             man->connection.es = event_set_init(&maxevents, EVENT_METHOD_FAST);
         }
 
+        man->connection.client_version = 1; /* default version */
+
         /*
          * Listen/connect socket
          */
index 364488f496a60ce2ba3fe513459772f773670735..3bd4e503cab1cfed41335ae97c26088a2d069be9 100644 (file)
@@ -318,6 +318,7 @@ struct man_connection {
     int fdtosend;
     int lastfdreceived;
 #endif
+    int client_version;
 };
 
 struct management