From f63cb718b3e824a1c26c29a4c18f3980326610f4 Mon Sep 17 00:00:00 2001 From: Logan oos Even <46396513+Logan007@users.noreply.github.com> Date: Sun, 5 Jun 2022 18:57:14 +0200 Subject: [PATCH] unified verbosity handling for edge and tools (#1009) --- edge.8 | 3 +++ src/edge.c | 10 +++++++++- tools/n2n-portfwd.c | 8 ++++---- tools/n2n-route.c | 8 ++++---- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/edge.8 b/edge.8 index 720581f..fcccd3e 100644 --- a/edge.8 +++ b/edge.8 @@ -198,6 +198,9 @@ access to JSON API at the management port. \fB\-v\fR, \fB\-\-verbose\fR make more verbose, repeat as required .TP +\fB\-V\fR +make less verbose, repeat as required +.TP \fB\-u \fR<\fIUID\fR>, \fB\-\-euid\fR=<\fIUID\fR> numeric user ID to use when privileges are dropped .TP diff --git a/src/edge.c b/src/edge.c index c6e2801..428f37d 100644 --- a/src/edge.c +++ b/src/edge.c @@ -211,6 +211,7 @@ static void help (int level) { "[--management-password ] " "\n " "[-v] " + "[-V] " #ifndef WIN32 "\n " "[-u ] " @@ -238,6 +239,7 @@ static void help (int level) { "\n [-f] do not fork but run in foreground" #endif "\n [-v] make more verbose, repeat as required" + "\n [-V] make less verbose, repeat as required" "\n " "\n -h shows this quick reference including all available options" @@ -332,6 +334,7 @@ static void help (int level) { printf(" --management_... | management port password, defaults to '%s'\n" " ...password | \n", N2N_MGMT_PASSWORD); printf(" -v | make more verbose, repeat as required\n"); + printf(" -V | make less verbose, repeat as required\n"); #ifndef WIN32 printf(" -u | numeric user ID to use when privileges are dropped\n"); printf(" -g | numeric group ID to use when privileges are dropped\n"); @@ -732,6 +735,11 @@ static int setOption (int optkey, char *optargument, n2n_tuntap_priv_config_t *e setTraceLevel(getTraceLevel() + 1); break; + case 'V': /* less verbose */ { + setTraceLevel(getTraceLevel() - 1); + break; + } + case 'R': /* network traffic filter */ { filter_rule_t *new_rule = malloc(sizeof(filter_rule_t)); memset(new_rule, 0, sizeof(filter_rule_t)); @@ -787,7 +795,7 @@ static int loadFromCLI (int argc, char *argv[], n2n_edge_conf_t *conf, n2n_tunta u_char c; while ((c = getopt_long(argc, argv, - "k:a:c:Eu:g:m:M:s:d:l:p:fvhrt:i:I:J:P:S::DL:z::A::Hn:R:e:" + "k:a:c:Eu:g:m:M:s:d:l:p:fvVhrt:i:I:J:P:S::DL:z::A::Hn:R:e:" #ifdef __linux__ "T:" #endif diff --git a/tools/n2n-portfwd.c b/tools/n2n-portfwd.c index fbb0731..f90f2ce 100644 --- a/tools/n2n-portfwd.c +++ b/tools/n2n-portfwd.c @@ -163,14 +163,14 @@ static void help (int level) { if(level == 0) return; /* no help required */ - printf(" n2n-portfwd [-t ] [-V] [-v]" + printf(" n2n-portfwd [-t ] [-v] [-V]" "\n" "\n This tool tries to find a router in local network and asks it to" "\n forward the edge's port(UDP and TCP) by sending corresponding" "\n UPnP and PMP requests." "\n\n Adapt port (default: %d) to match your edge's management port" "\n configuration." - "\n\n Verbosity can be increased or decreased with -V or -v , repeat as" + "\n\n Verbosity can be increased or decreased with -v or -V , repeat as" "\n as needed." "\n\n", N2N_EDGE_MGMT_PORT); @@ -192,12 +192,12 @@ static int set_option (n2n_portfwd_conf_t *ppp, int optkey, char *optargument) { break; } - case 'V': /* more verbose */ { + case 'v': /* more verbose */ { setTraceLevel(getTraceLevel() + 1); break; } - case 'v': /* less verbose */ { + case 'V': /* less verbose */ { setTraceLevel(getTraceLevel() - 1); break; } diff --git a/tools/n2n-route.c b/tools/n2n-route.c index c554305..3f00023 100644 --- a/tools/n2n-route.c +++ b/tools/n2n-route.c @@ -445,7 +445,7 @@ static void help (int level) { if(level == 0) return; /* no help required */ - printf(" n2n-route [-t ] [-p ] [-V] [-v]" + printf(" n2n-route [-t ] [-p ] [-v] [-V]" "\n [-g ] [-n /bitlen] " "\n" "\n This tool sets new routes for all the traffic to be routed via the" @@ -456,7 +456,7 @@ static void help (int level) { "\n\n If no provided, the tool will try to auto-detect." "\n\n To not route all traffic through vpn, inidicate the networks to be" "\n routed with '-n' option and use as many as required." - "\n\n Verbosity can be increased or decreased with -V or -v , repeat as" + "\n\n Verbosity can be increased or decreased with -v or -V , repeat as" "\n as needed." "\n\n Run with sufficient rights to let the tool add and delete routes." "\n\n", @@ -525,12 +525,12 @@ static int set_option (n2n_route_conf_t *rrr, int optkey, char *optargument) { break; } - case 'V': /* more verbose */ { + case 'v': /* more verbose */ { setTraceLevel(getTraceLevel() + 1); break; } - case 'v': /* less verbose */ { + case 'V': /* less verbose */ { setTraceLevel(getTraceLevel() - 1); break; }