diff options
Diffstat (limited to 'smallapp/unbound-control.c')
| -rw-r--r-- | smallapp/unbound-control.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/smallapp/unbound-control.c b/smallapp/unbound-control.c index 58be7b7abfc0..cc48866c5dbd 100644 --- a/smallapp/unbound-control.c +++ b/smallapp/unbound-control.c @@ -68,6 +68,7 @@ usage() printf("Options:\n"); printf(" -c file config file, default is %s\n", CONFIGFILE); printf(" -s ip[@port] server address, if omitted config is used.\n"); + printf(" -q quiet (don't print anything if it works ok).\n"); printf(" -h show this usage help.\n"); printf("Commands:\n"); printf(" start start server; runs unbound(8)\n"); @@ -93,6 +94,7 @@ usage() printf(" flush_type <name> <type> flush name, type from cache\n"); printf(" flush_zone <name> flush everything at or under name\n"); printf(" from rr and dnssec caches\n"); + printf(" flush_bogus flush all bogus data\n"); printf(" flush_stats flush statistics, make zero\n"); printf(" flush_requestlist drop queries that are worked on\n"); printf(" dump_requestlist show what is worked on\n"); @@ -262,7 +264,7 @@ send_file(SSL* ssl, FILE* in, char* buf, size_t sz) /** send command and display result */ static int -go_cmd(SSL* ssl, int argc, char* argv[]) +go_cmd(SSL* ssl, int quiet, int argc, char* argv[]) { char pre[10]; const char* space=" "; @@ -296,9 +298,12 @@ go_cmd(SSL* ssl, int argc, char* argv[]) ssl_err("could not SSL_read"); } buf[r] = 0; - printf("%s", buf); - if(first_line && strncmp(buf, "error", 5) == 0) + if(first_line && strncmp(buf, "error", 5) == 0) { + printf("%s", buf); was_error = 1; + } else if (!quiet) + printf("%s", buf); + first_line = 0; } return was_error; @@ -306,7 +311,7 @@ go_cmd(SSL* ssl, int argc, char* argv[]) /** go ahead and read config, contact server and perform command and display */ static int -go(const char* cfgfile, char* svr, int argc, char* argv[]) +go(const char* cfgfile, char* svr, int quiet, int argc, char* argv[]) { struct config_file* cfg; int fd, ret; @@ -327,7 +332,7 @@ go(const char* cfgfile, char* svr, int argc, char* argv[]) ssl = setup_ssl(ctx, fd); /* send command */ - ret = go_cmd(ssl, argc, argv); + ret = go_cmd(ssl, quiet, argc, argv); SSL_free(ssl); #ifndef USE_WINSOCK @@ -349,6 +354,7 @@ extern char* optarg; int main(int argc, char* argv[]) { int c, ret; + int quiet = 0; const char* cfgfile = CONFIGFILE; char* svr = NULL; #ifdef USE_WINSOCK @@ -379,7 +385,8 @@ int main(int argc, char* argv[]) if(!RAND_status()) { /* try to seed it */ unsigned char buf[256]; - unsigned int v, seed=(unsigned)time(NULL) ^ (unsigned)getpid(); + unsigned int seed=(unsigned)time(NULL) ^ (unsigned)getpid(); + unsigned int v = seed; size_t i; for(i=0; i<256/sizeof(v); i++) { memmove(buf+i*sizeof(v), &v, sizeof(v)); @@ -390,7 +397,7 @@ int main(int argc, char* argv[]) } /* parse the options */ - while( (c=getopt(argc, argv, "c:s:h")) != -1) { + while( (c=getopt(argc, argv, "c:s:qh")) != -1) { switch(c) { case 'c': cfgfile = optarg; @@ -398,6 +405,9 @@ int main(int argc, char* argv[]) case 's': svr = optarg; break; + case 'q': + quiet = 1; + break; case '?': case 'h': default: @@ -416,7 +426,7 @@ int main(int argc, char* argv[]) } } - ret = go(cfgfile, svr, argc, argv); + ret = go(cfgfile, svr, quiet, argc, argv); #ifdef USE_WINSOCK WSACleanup(); |
