Skip to content

Commit 655c53d

Browse files
committed
add option -q to disable logging
closes #43
1 parent 8f6cb09 commit 655c53d

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

sockssrv.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#define THREAD_STACK_SIZE 32*1024
6161
#endif
6262

63+
static int quiet;
6364
static const char* auth_user;
6465
static const char* auth_pass;
6566
static sblist* auth_ips;
@@ -106,7 +107,7 @@ struct thread {
106107
/* we log to stderr because it's not using line buffering, i.e. malloc which would need
107108
locking when called from different threads. for the same reason we use dprintf,
108109
which writes directly to an fd. */
109-
#define dolog(...) dprintf(2, __VA_ARGS__)
110+
#define dolog(...) do { if(!quiet) dprintf(2, __VA_ARGS__); } while(0)
110111
#else
111112
static void dolog(const char* fmt, ...) { }
112113
#endif
@@ -379,9 +380,10 @@ static int usage(void) {
379380
dprintf(2,
380381
"MicroSocks SOCKS5 Server\n"
381382
"------------------------\n"
382-
"usage: microsocks -1 -i listenip -p port -u user -P password -b bindaddr\n"
383+
"usage: microsocks -1 -q -i listenip -p port -u user -P password -b bindaddr\n"
383384
"all arguments are optional.\n"
384385
"by default listenip is 0.0.0.0 and port 1080.\n\n"
386+
"option -q disables logging.\n"
385387
"option -b specifies which ip outgoing connections are bound to\n"
386388
"option -1 activates auth_once mode: once a specific ip address\n"
387389
"authed successfully with user/pass, it is added to a whitelist\n"
@@ -403,11 +405,14 @@ int main(int argc, char** argv) {
403405
int ch;
404406
const char *listenip = "0.0.0.0";
405407
unsigned port = 1080;
406-
while((ch = getopt(argc, argv, ":1b:i:p:u:P:")) != -1) {
408+
while((ch = getopt(argc, argv, ":1qb:i:p:u:P:")) != -1) {
407409
switch(ch) {
408410
case '1':
409411
auth_ips = sblist_new(sizeof(union sockaddr_union), 8);
410412
break;
413+
case 'q':
414+
quiet = 1;
415+
break;
411416
case 'b':
412417
resolve_sa(optarg, 0, &bind_addr);
413418
break;

0 commit comments

Comments
 (0)