From cd4aee19977bb204fc550b54788f4094ae5e61ea Mon Sep 17 00:00:00 2001 From: rofl0r Date: Tue, 22 Jul 2014 14:10:08 +0200 Subject: [PATCH] print proxychains version on DLL init framework to print version stolen from musl --- .gitignore | 1 + Makefile | 10 +++++++++- VERSION | 1 + src/libproxychains.c | 4 +++- src/version.c | 6 ++++++ tools/version.sh | 12 ++++++++++++ 6 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 VERSION create mode 100644 src/version.c create mode 100644 tools/version.sh diff --git a/.gitignore b/.gitignore index a0a2c85..67e8e48 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ *.out *~ *.patch +version.h # Autoconf stuff libtool diff --git a/Makefile b/Makefile index d2211ef..d0788eb 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,13 @@ sysconfdir=$(prefix)/etc SRCS = $(sort $(wildcard src/*.c)) OBJS = $(SRCS:.c=.o) -LOBJS = src/nameinfo.o \ +LOBJS = src/nameinfo.o src/version.o \ src/core.o src/common.o src/libproxychains.o src/shm.o \ src/allocator_thread.o src/ip_type.o src/stringdump.o \ src/hostentdb.o src/hash.o src/debug.o +GENH = src/version.h + CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe NO_AS_NEEDED = -Wl,--no-as-needed LIBDL = -ldl @@ -61,6 +63,12 @@ clean: rm -f $(ALL_LIBS) rm -f $(ALL_TOOLS) rm -f $(OBJS) + rm -f $(GENH) + +src/version.h: $(wildcard VERSION .git) + printf '#define VERSION "%s"\n' "$$(sh tools/version.sh)" > $@ + +src/version.o: src/version.h %.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $< diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..4f8c639 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +4.7 diff --git a/src/libproxychains.c b/src/libproxychains.c index 08fd451..fb5e43f 100644 --- a/src/libproxychains.c +++ b/src/libproxychains.c @@ -98,6 +98,8 @@ static void* load_sym(char* symname, void* proxyfunc) { #include "allocator_thread.h" #include "stringdump.h" +const char *proxychains_get_version(void); + static void do_init(void) { srand(time(NULL)); dumpstring_init(); // global string garbage can @@ -108,7 +110,7 @@ static void do_init(void) { get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct); DUMP_PROXY_CHAIN(proxychains_pd, proxychains_proxy_count); - proxychains_write_log(LOG_PREFIX "DLL init\n"); + proxychains_write_log(LOG_PREFIX "DLL init: proxychains-ng %s\n", proxychains_get_version()); SETUP_SYM(connect); SETUP_SYM(gethostbyname); diff --git a/src/version.c b/src/version.c new file mode 100644 index 000000000..5a53388 --- /dev/null +++ b/src/version.c @@ -0,0 +1,6 @@ +#include "version.h" +static const char version[] = VERSION; +const char *proxychains_get_version(void) { + return version; +} + diff --git a/tools/version.sh b/tools/version.sh new file mode 100644 index 000000000..f1cc594 --- /dev/null +++ b/tools/version.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +if test -d .git ; then +if type git >/dev/null 2>&1 ; then +git describe --tags --match 'v[0-9]*' 2>/dev/null \ +| sed -e 's/^v//' -e 's/-/-git-/' +else +sed 's/$/-git/' < VERSION +fi +else +cat VERSION +fi