mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-02-17 17:48:16 -05:00
unbound-control -q option is quiet, patch from Mariano Absatz.
git-svn-id: file:///svn/unbound/trunk@2766 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
9c4bbfd37d
commit
f700558dc0
3 changed files with 20 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
|||
27 September 2012: Wouter
|
||||
- include: directive in config file accepts wildcards. Patch from
|
||||
Paul Wouters. Suggested use: include: "/etc/unbound.d/conf.d/*"
|
||||
- unbound-control -q option is quiet, patch from Mariano Absatz.
|
||||
|
||||
21 September 2012: Wouter
|
||||
- chdir to / after chroot call (suggested by Camiel Dobbelaar).
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
\- Unbound remote server control utility.
|
||||
.SH "SYNOPSIS"
|
||||
.B unbound\-control
|
||||
.RB [ \-h ]
|
||||
.RB [ \-hq ]
|
||||
.RB [ \-c
|
||||
.IR cfgfile ]
|
||||
.RB [ \-s
|
||||
|
|
@ -38,6 +38,9 @@ config file @ub_conf_file@ is used.
|
|||
.B \-s \fIserver[@port]
|
||||
IPv4 or IPv6 address of the server to contact. If not given, the
|
||||
address is read from the config file.
|
||||
.TP
|
||||
.B \-q
|
||||
quiet, if the option is given it does not print anything if it works ok.
|
||||
.SH "COMMANDS"
|
||||
There are several commands that the server understands.
|
||||
.TP
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
@ -263,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=" ";
|
||||
|
|
@ -297,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;
|
||||
|
|
@ -307,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;
|
||||
|
|
@ -328,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
|
||||
|
|
@ -350,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
|
||||
|
|
@ -392,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;
|
||||
|
|
@ -400,6 +405,9 @@ int main(int argc, char* argv[])
|
|||
case 's':
|
||||
svr = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
case '?':
|
||||
case 'h':
|
||||
default:
|
||||
|
|
@ -418,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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue