Skip to content

Commit

Permalink
Add graftcp version info
Browse files Browse the repository at this point in the history
  • Loading branch information
hmgle committed Dec 6, 2020
1 parent 33c4ee5 commit 80c3b25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ifneq ($(KERNEL), Linux)
$(error only support Linux now.)
endif

VERSION = $(shell git describe --tags)

debug = 0

PREFIX = /usr/local
Expand All @@ -33,6 +35,10 @@ else
CFLAGS += -O2 -DNDEBUG
endif

ifeq ($(shell echo $(VERSION) | head -c 1), v)
CFLAGS += -DVERSION=$(VERSION)
endif

SRC := $(wildcard *.c)

GRAFTCP_LOCAL_BIN = graftcp-local/graftcp-local
Expand Down
10 changes: 10 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "graftcp.h"
#include "string-set.h"

#ifndef VERSION
#define VERSION "v0.3"
#endif

struct sockaddr_in PROXY_SA;
struct sockaddr_in6 PROXY_SA6;
char *LOCAL_ADDR = "127.0.0.1";
Expand Down Expand Up @@ -367,6 +371,8 @@ static void usage(char **argv)
" -n --not-ignore-local\n"
" Connecting to local is not changed by default, this\n"
" option will redirect it to SOCKS5\n"
" -V --version\n"
" Show version\n"
" -h --help\n"
" Display this help and exit\n"
"\n", argv[0]);
Expand All @@ -378,6 +384,7 @@ int main(int argc, char **argv)
bool ignore_local = true;
struct option long_opts[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"local-addr", required_argument, 0, 'a'},
{"local-port", required_argument, 0, 'p'},
{"local-fifo", required_argument, 0, 'f'},
Expand Down Expand Up @@ -408,6 +415,9 @@ int main(int argc, char **argv)
case 'n':
ignore_local = false;
break;
case 'V':
fprintf(stderr, "graftcp %s\n", VERSION);
exit(0);
case 0:
case 'h':
default:
Expand Down

0 comments on commit 80c3b25

Please sign in to comment.