Skip to content

Commit

Permalink
add option -q to disable logging
Browse files Browse the repository at this point in the history
closes #43
  • Loading branch information
rofl0r committed Sep 18, 2022
1 parent 8f6cb09 commit 655c53d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sockssrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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;
Expand Down

0 comments on commit 655c53d

Please sign in to comment.