wg: include tools version

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2019-12-26 12:30:12 +01:00
parent 2f74ac29cf
commit 262b5196cf
2 changed files with 6 additions and 0 deletions

1
src/version.h Normal file
View file

@ -0,0 +1 @@
#define WIREGUARD_TOOLS_VERSION "0.0.20191219"

View file

@ -8,6 +8,7 @@
#include <string.h> #include <string.h>
#include "subcommands.h" #include "subcommands.h"
#include "version.h"
const char *PROG_NAME; const char *PROG_NAME;
@ -40,6 +41,10 @@ int main(int argc, char *argv[])
{ {
PROG_NAME = argv[0]; PROG_NAME = argv[0];
if (argc == 2 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version") || !strcmp(argv[1], "version"))) {
printf("wireguard-tools v%s - https://git.zx2c4.com/wireguard-tools/\n", WIREGUARD_TOOLS_VERSION);
return 0;
}
if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") || !strcmp(argv[1], "help"))) { if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help") || !strcmp(argv[1], "help"))) {
show_usage(stdout); show_usage(stdout);
return 0; return 0;