mirror of
https://github.com/darkk/redsocks.git
synced 2025-08-25 19:25:30 +00:00
Added -h, -? CLI options for help & -v for redsocks-version.
This commit is contained in:
parent
9fce864ae0
commit
457c5eb79a
19
Makefile
19
Makefile
@ -1,4 +1,4 @@
|
|||||||
OBJS := parser.o main.o redsocks.o log.o http-connect.o socks4.o socks5.o http-relay.o base.o base64.o md5.o http-auth.o utils.o redudp.o dnstc.o
|
OBJS := parser.o main.o redsocks.o log.o http-connect.o socks4.o socks5.o http-relay.o base.o base64.o md5.o http-auth.o utils.o redudp.o dnstc.o gen/version.o
|
||||||
SRCS := $(OBJS:.o=.c)
|
SRCS := $(OBJS:.o=.c)
|
||||||
CONF := config.h
|
CONF := config.h
|
||||||
DEPS := .depend
|
DEPS := .depend
|
||||||
@ -29,6 +29,22 @@ $(CONF):
|
|||||||
;; \
|
;; \
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Dependency on .git is useful to rebuild `version.c' after commit
|
||||||
|
# FIXME: non-git builds should be supported.
|
||||||
|
gen/version.c: *.c *.h gen/.build .git
|
||||||
|
rm -f $@.tmp
|
||||||
|
echo '/* this file is auto-generated during build */' > $@.tmp
|
||||||
|
echo '#include "../version.h"' > $@.tmp
|
||||||
|
echo 'const char* redsocks_version = "redsocks.git/"' >> $@.tmp
|
||||||
|
echo '"'`git describe --tags`'"' >> $@.tmp
|
||||||
|
[ `git status --porcelain | grep -v -c '^??'` != 0 ] && { echo '"-unclean"' >> $@.tmp; } || true
|
||||||
|
echo ';' >> $@.tmp
|
||||||
|
mv -f $@.tmp $@
|
||||||
|
|
||||||
|
gen/.build:
|
||||||
|
mkdir -p gen
|
||||||
|
touch $@
|
||||||
|
|
||||||
base.c: $(CONF)
|
base.c: $(CONF)
|
||||||
|
|
||||||
$(DEPS): $(SRCS)
|
$(DEPS): $(SRCS)
|
||||||
@ -64,3 +80,4 @@ clean:
|
|||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) tags $(DEPS)
|
$(RM) tags $(DEPS)
|
||||||
|
$(RM) -r gen
|
||||||
|
12
main.c
12
main.c
@ -25,6 +25,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
extern app_subsys redsocks_subsys;
|
extern app_subsys redsocks_subsys;
|
||||||
extern app_subsys base_subsys;
|
extern app_subsys base_subsys;
|
||||||
@ -66,7 +67,7 @@ int main(int argc, char **argv)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
red_srand();
|
red_srand();
|
||||||
while ((opt = getopt(argc, argv, "tc:p:")) != -1) {
|
while ((opt = getopt(argc, argv, "h?vtc:p:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 't':
|
case 't':
|
||||||
conftest = true;
|
conftest = true;
|
||||||
@ -77,13 +78,18 @@ int main(int argc, char **argv)
|
|||||||
case 'p':
|
case 'p':
|
||||||
pidfile = optarg;
|
pidfile = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
puts(redsocks_version);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
default:
|
default:
|
||||||
printf(
|
printf(
|
||||||
"Usage: %s [-t] [-c config] [-p pidfile]\n"
|
"Usage: %s [-?hvt] [-c config] [-p pidfile]\n"
|
||||||
|
" -h, -? this message\n"
|
||||||
|
" -v print version\n"
|
||||||
" -t test config syntax\n"
|
" -t test config syntax\n"
|
||||||
" -p write pid to pidfile\n",
|
" -p write pid to pidfile\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
return EXIT_FAILURE;
|
return (opt == '?' || opt == 'h') ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user