/*
* Globals
*/
-static int g_interactive = 1;
+static bool g_quiet = false;
+static bool g_interactive = true;
/*
* TTY control
if (lua_gettop(L) > 0) {
message = lua_tostring(L, -1);
}
+ /* Log to remote socket if connected */
+ const char *delim = g_quiet ? "" : "> ";
if (stream_fd != STDIN_FILENO) {
fprintf(stdout, "%s\n", cmd); /* Duplicate command to logs */
- fprintf(out, "%s\n> ", message); /* Duplicate output to sender */
+ if (message)
+ fprintf(out, "%s", message); /* Duplicate output to sender */
+ if (message || !g_quiet)
+ fprintf(out, "\n");
+ fprintf(out, "%s", delim);
}
- fprintf(ret ? stderr : stdout, "%s\n> ", message);
+ /* Log to standard streams */
+ FILE *fp_out = ret ? stderr : stdout;
+ if (message)
+ fprintf(fp_out, "%s", message);
+ if (message || !g_quiet)
+ fprintf(fp_out, "\n");
+ fprintf(fp_out, "%s", delim);
lua_settop(L, 0);
free(buf->base);
}
client->data = master->data;
uv_read_start((uv_stream_t *)client, tty_alloc, tty_read);
/* Write command line */
- uv_buf_t buf = { "> ", 2 };
- uv_try_write((uv_stream_t *)client, &buf, 1);
+ if (!g_quiet) {
+ uv_buf_t buf = { "> ", 2 };
+ uv_try_write((uv_stream_t *)client, &buf, 1);
+ }
}
}
" -c, --config=[path] Config file path (relative to [rundir]) (default: config).\n"
" -k, --keyfile=[path] File containing trust anchors (DS or DNSKEY).\n"
" -f, --forks=N Start N forks sharing the configuration.\n"
+ " -q, --quiet Quiet output, no prompt in interactive mode.\n"
" -v, --verbose Run in verbose mode.\n"
" -V, --version Print version of the server.\n"
" -h, --help Print help and usage.\n"
uv_pipe_init(loop, &pipe, 0);
pipe.data = engine;
if (g_interactive) {
- printf("[system] interactive mode\n> ");
+ if (!g_quiet)
+ printf("[system] interactive mode\n> ");
fflush(stdout);
uv_pipe_open(&pipe, 0);
uv_read_start((uv_stream_t*) &pipe, tty_alloc, tty_read);
{"keyfile",required_argument, 0, 'k'},
{"forks",required_argument, 0, 'f'},
{"verbose", no_argument, 0, 'v'},
+ {"quiet", no_argument, 0, 'q'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
- while ((c = getopt_long(argc, argv, "a:c:f:k:vVh", opts, &li)) != -1) {
+ while ((c = getopt_long(argc, argv, "a:c:f:k:vqVh", opts, &li)) != -1) {
switch (c)
{
case 'a':
config = optarg;
break;
case 'f':
- g_interactive = 0;
+ g_interactive = false;
forks = atoi(optarg);
if (forks == 0) {
kr_log_error("[system] error '-f' requires number, not '%s'\n", optarg);
case 'v':
kr_debug_set(true);
break;
+ case 'q':
+ g_quiet = true;
+ break;
case 'V':
kr_log_info("%s, version %s\n", "Knot DNS Resolver", PACKAGE_VERSION);
return EXIT_SUCCESS;