diff --git a/sockssrv.c b/sockssrv.c index bc919f4..dbd1f52 100644 --- a/sockssrv.c +++ b/sockssrv.c @@ -60,6 +60,7 @@ #define THREAD_STACK_SIZE 32*1024 #endif +static int quiet; static const char* auth_user; static const char* auth_pass; static sblist* auth_ips; @@ -106,7 +107,7 @@ struct thread { /* we log to stderr because it's not using line buffering, i.e. malloc which would need locking when called from different threads. for the same reason we use dprintf, which writes directly to an fd. */ -#define dolog(...) dprintf(2, __VA_ARGS__) +#define dolog(...) do { if(!quiet) dprintf(2, __VA_ARGS__); } while(0) #else static void dolog(const char* fmt, ...) { } #endif @@ -379,9 +380,10 @@ static int usage(void) { dprintf(2, "MicroSocks SOCKS5 Server\n" "------------------------\n" - "usage: microsocks -1 -i listenip -p port -u user -P password -b bindaddr\n" + "usage: microsocks -1 -q -i listenip -p port -u user -P password -b bindaddr\n" "all arguments are optional.\n" "by default listenip is 0.0.0.0 and port 1080.\n\n" + "option -q disables logging.\n" "option -b specifies which ip outgoing connections are bound to\n" "option -1 activates auth_once mode: once a specific ip address\n" "authed successfully with user/pass, it is added to a whitelist\n" @@ -403,11 +405,14 @@ int main(int argc, char** argv) { int ch; const char *listenip = "0.0.0.0"; unsigned port = 1080; - while((ch = getopt(argc, argv, ":1b:i:p:u:P:")) != -1) { + while((ch = getopt(argc, argv, ":1qb:i:p:u:P:")) != -1) { switch(ch) { case '1': auth_ips = sblist_new(sizeof(union sockaddr_union), 8); break; + case 'q': + quiet = 1; + break; case 'b': resolve_sa(optarg, 0, &bind_addr); break;