commit 6e63a724cbce44a1a3f98fa4ba278ac4c833661b
parent 7688b89550911b2c2b0e99083862f2ca0fd79c70
Author: sin <sin@2f30.org>
Date: Tue, 12 Apr 2016 11:57:55 +0100
get rid of the foreground option and overload debug
Diffstat:
4 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/log.c b/log.c
@@ -13,7 +13,7 @@ static char *progname;
static void
logmsg(int priority, char *msg, va_list ap)
{
- if (foreground) {
+ if (debug) {
fprintf(stderr, "%s: ", progname);
vfprintf(stderr, msg, ap);
fputc('\n', stderr);
@@ -26,7 +26,8 @@ void
loginit(char *prog)
{
progname = prog;
- openlog(progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
+ if (!debug)
+ openlog(progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
}
void
@@ -34,11 +35,9 @@ logdbg(char *msg, ...)
{
va_list ap;
- if (debug) {
- va_start(ap, msg);
- logmsg(LOG_DAEMON | LOG_DEBUG, msg, ap);
- va_end(ap);
- }
+ va_start(ap, msg);
+ logmsg(LOG_DAEMON | LOG_DEBUG, msg, ap);
+ va_end(ap);
}
void
diff --git a/stun.8 b/stun.8
@@ -1,4 +1,4 @@
-.Dd April 6, 2016
+.Dd April 12, 2016
.Dt STUN 8
.Os
.Sh NAME
@@ -6,7 +6,7 @@
.Nd simple tunnel
.Sh SYNOPSIS
.Nm stun
-.Op Fl df
+.Op Fl d
.Fl s
.Op Fl b Ar address
.Op Fl p Ar port
@@ -14,7 +14,7 @@
.Op Fl c Ar cipher
.Ar interface
.Nm stun
-.Op Fl df
+.Op Fl d
.Fl h Ar host
.Op Fl p Ar port
.Op Fl t Ar devtype
@@ -29,8 +29,6 @@ stack on the server side.
.Bl -tag -width "-b address"
.It Fl d
Enable debug output.
-.It Fl f
-Run in foreground.
.It Fl s
Enable server mode. Default is off.
.It Fl b Ar address
diff --git a/stun.c b/stun.c
@@ -70,7 +70,6 @@ char *port = "12080";
char *cipher = DEFCIPHER;
int devtype = TUNDEV;
int debug;
-int foreground;
int sflag;
int
@@ -233,8 +232,8 @@ err:
void
usage(void)
{
- fprintf(stderr, "usage: stun [-df] -s [-b address] [-p port] [-t devtype] [-c cipher] interface\n");
- fprintf(stderr, " stun [-df] -h host [-p port] [-t devtype] [-c cipher] interface\n");
+ fprintf(stderr, "usage: stun [-d] -s [-b address] [-p port] [-t devtype] [-c cipher] interface\n");
+ fprintf(stderr, " stun [-d] -h host [-p port] [-t devtype] [-c cipher] interface\n");
exit(1);
}
@@ -249,9 +248,6 @@ main(int argc, char *argv[])
case 'd':
debug = 1;
break;
- case 'f':
- foreground = 1;
- break;
case 's':
sflag = 1;
break;
@@ -284,10 +280,9 @@ main(int argc, char *argv[])
usage();
signal(SIGPIPE, SIG_IGN);
- if (!foreground) {
+ if (!debug)
daemon(0, 0);
- loginit("stun");
- }
+ loginit("stun");
devfd = opendev(argv[0]);
/* disable core dumps as memory contains the pre-shared key */
diff --git a/stun.h b/stun.h
@@ -17,7 +17,6 @@ enum {
/* stun.c */
extern int devtype;
extern int debug;
-extern int foreground;
extern char *cipher;
/* auth.c */