mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
Partial support for "rndc status". Not all of the fields are filled in yet.
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: control.c,v 1.5 2001/05/08 00:28:28 gson Exp $ */
|
/* $Id: control.c,v 1.6 2001/05/08 04:09:36 bwelling Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ command_compare(const char *text, const char *command) {
|
|||||||
* when a control channel message is received.
|
* when a control channel message is received.
|
||||||
*/
|
*/
|
||||||
isc_result_t
|
isc_result_t
|
||||||
ns_control_docommand(isccc_sexpr_t *message) {
|
ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) {
|
||||||
isccc_sexpr_t *data;
|
isccc_sexpr_t *data;
|
||||||
char *command;
|
char *command;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
@@ -108,6 +108,8 @@ ns_control_docommand(isccc_sexpr_t *message) {
|
|||||||
result = ISC_R_SUCCESS;
|
result = ISC_R_SUCCESS;
|
||||||
} else if (command_compare(command, NS_COMMAND_FLUSH)) {
|
} else if (command_compare(command, NS_COMMAND_FLUSH)) {
|
||||||
result = ns_server_flushcache(ns_g_server);
|
result = ns_server_flushcache(ns_g_server);
|
||||||
|
} else if (command_compare(command, NS_COMMAND_STATUS)) {
|
||||||
|
result = ns_server_status(ns_g_server, text);
|
||||||
} else {
|
} else {
|
||||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
||||||
NS_LOGMODULE_CONTROL, ISC_LOG_WARNING,
|
NS_LOGMODULE_CONTROL, ISC_LOG_WARNING,
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: controlconf.c,v 1.6 2001/05/08 03:42:27 gson Exp $ */
|
/* $Id: controlconf.c,v 1.7 2001/05/08 04:09:37 bwelling Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -302,6 +302,8 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
|
|||||||
isc_buffer_t b;
|
isc_buffer_t b;
|
||||||
isc_region_t r;
|
isc_region_t r;
|
||||||
isc_uint32_t len;
|
isc_uint32_t len;
|
||||||
|
isc_buffer_t text;
|
||||||
|
char textarray[1024];
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_result_t eresult;
|
isc_result_t eresult;
|
||||||
|
|
||||||
@@ -335,7 +337,9 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
eresult = ns_control_docommand(request);
|
isc_buffer_init(&text, textarray, sizeof(textarray));
|
||||||
|
|
||||||
|
eresult = ns_control_docommand(request, &text);
|
||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_stdtime_get(&now);
|
||||||
result = isccc_cc_createresponse(request, now, now + 60, &response);
|
result = isccc_cc_createresponse(request, now, now + 60, &response);
|
||||||
@@ -352,6 +356,17 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isc_buffer_usedlength(&text) > 0) {
|
||||||
|
isccc_sexpr_t *data;
|
||||||
|
|
||||||
|
data = isccc_alist_lookup(response, "_data");
|
||||||
|
if (data != NULL) {
|
||||||
|
char *str = (char *)isc_buffer_base(&text);
|
||||||
|
if (isccc_cc_definestring(data, "text", str) == NULL)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ccregion.rstart = conn->buffer + 4;
|
ccregion.rstart = conn->buffer + 4;
|
||||||
ccregion.rend = conn->buffer + sizeof(conn->buffer);
|
ccregion.rend = conn->buffer + sizeof(conn->buffer);
|
||||||
result = isccc_cc_towire(response, &ccregion, &secret);
|
result = isccc_cc_towire(response, &ccregion, &secret);
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: control.h,v 1.5 2001/05/08 03:42:31 gson Exp $ */
|
/* $Id: control.h,v 1.6 2001/05/08 04:09:40 bwelling Exp $ */
|
||||||
|
|
||||||
#ifndef NAMED_CONTROL_H
|
#ifndef NAMED_CONTROL_H
|
||||||
#define NAMED_CONTROL_H 1
|
#define NAMED_CONTROL_H 1
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
#define NS_COMMAND_TRACE "trace"
|
#define NS_COMMAND_TRACE "trace"
|
||||||
#define NS_COMMAND_NOTRACE "notrace"
|
#define NS_COMMAND_NOTRACE "notrace"
|
||||||
#define NS_COMMAND_FLUSH "flush"
|
#define NS_COMMAND_FLUSH "flush"
|
||||||
|
#define NS_COMMAND_STATUS "status"
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
ns_controls_create(ns_server_t *server, ns_controls_t **ctrlsp);
|
ns_controls_create(ns_server_t *server, ns_controls_t **ctrlsp);
|
||||||
@@ -75,6 +76,6 @@ ns_controls_shutdown(ns_controls_t *controls);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
ns_control_docommand(isccc_sexpr_t *message);
|
ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text);
|
||||||
|
|
||||||
#endif /* NAMED_CONTROL_H */
|
#endif /* NAMED_CONTROL_H */
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: server.h,v 1.55 2001/05/08 03:42:33 gson Exp $ */
|
/* $Id: server.h,v 1.56 2001/05/08 04:09:41 bwelling Exp $ */
|
||||||
|
|
||||||
#ifndef NAMED_SERVER_H
|
#ifndef NAMED_SERVER_H
|
||||||
#define NAMED_SERVER_H 1
|
#define NAMED_SERVER_H 1
|
||||||
@@ -162,4 +162,10 @@ ns_server_setdebuglevel(ns_server_t *server, char *args);
|
|||||||
isc_result_t
|
isc_result_t
|
||||||
ns_server_flushcache(ns_server_t *server);
|
ns_server_flushcache(ns_server_t *server);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Report the server's status.
|
||||||
|
*/
|
||||||
|
isc_result_t
|
||||||
|
ns_server_status(ns_server_t *server, isc_buffer_t *text);
|
||||||
|
|
||||||
#endif /* NAMED_SERVER_H */
|
#endif /* NAMED_SERVER_H */
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: server.c,v 1.321 2001/05/08 03:42:30 gson Exp $ */
|
/* $Id: server.c,v 1.322 2001/05/08 04:09:39 bwelling Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -2777,3 +2777,26 @@ ns_server_flushcache(ns_server_t *server) {
|
|||||||
isc_task_endexclusive(server->task);
|
isc_task_endexclusive(server->task);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
ns_server_status(ns_server_t *server, isc_buffer_t *text) {
|
||||||
|
int n;
|
||||||
|
|
||||||
|
n = snprintf((char *)isc_buffer_used(text),
|
||||||
|
isc_buffer_availablelength(text),
|
||||||
|
"number of zones: %d\n"
|
||||||
|
"debug level: %d\n"
|
||||||
|
"xfers running: %d\n"
|
||||||
|
"xfers deferred: %d\n"
|
||||||
|
"soa queries in progress: %d\n"
|
||||||
|
"query logging is %s\n"
|
||||||
|
"server is up and running",
|
||||||
|
-1, /* XXX */
|
||||||
|
ns_g_debuglevel,
|
||||||
|
-1, -1, -1, /* XXX */
|
||||||
|
server->log_queries ? "ON" : "OFF");
|
||||||
|
if (n < 0)
|
||||||
|
return (ISC_R_NOSPACE);
|
||||||
|
isc_buffer_add(text, n);
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: rndc.c,v 1.58 2001/05/08 01:19:01 gson Exp $ */
|
/* $Id: rndc.c,v 1.59 2001/05/08 04:09:35 bwelling Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Principal Author: DCL
|
* Principal Author: DCL
|
||||||
@@ -113,7 +113,7 @@ command is one of the following:\n\
|
|||||||
trace level Change the debugging level.\n\
|
trace level Change the debugging level.\n\
|
||||||
notrace Set debugging level to 0.\n\
|
notrace Set debugging level to 0.\n\
|
||||||
flush Flushes the server's cache.\n\
|
flush Flushes the server's cache.\n\
|
||||||
*status Display ps(1) status of named.\n\
|
status Display status of named.\n\
|
||||||
*restart Restart the server.\n\
|
*restart Restart the server.\n\
|
||||||
\n\
|
\n\
|
||||||
* == not yet implemented\n\
|
* == not yet implemented\n\
|
||||||
@@ -222,6 +222,7 @@ rndc_recvdone(isc_task_t *task, isc_event_t *event) {
|
|||||||
isccc_sexpr_t *data;
|
isccc_sexpr_t *data;
|
||||||
isccc_region_t source;
|
isccc_region_t source;
|
||||||
char *errormsg = NULL;
|
char *errormsg = NULL;
|
||||||
|
char *textmsg = NULL;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
recvs--;
|
recvs--;
|
||||||
@@ -256,6 +257,13 @@ rndc_recvdone(isc_task_t *task, isc_event_t *event) {
|
|||||||
fprintf(stderr, "%s: parsing response failed: %s\n",
|
fprintf(stderr, "%s: parsing response failed: %s\n",
|
||||||
progname, isc_result_totext(result));
|
progname, isc_result_totext(result));
|
||||||
|
|
||||||
|
result = isccc_cc_lookupstring(data, "text", &textmsg);
|
||||||
|
if (result == ISC_R_SUCCESS)
|
||||||
|
printf("%s\n", textmsg);
|
||||||
|
else if (result != ISC_R_NOTFOUND)
|
||||||
|
fprintf(stderr, "%s: parsing response failed: %s\n",
|
||||||
|
progname, isc_result_totext(result));
|
||||||
|
|
||||||
isc_event_free(&event);
|
isc_event_free(&event);
|
||||||
isccc_sexpr_free(&response);
|
isccc_sexpr_free(&response);
|
||||||
isc_socket_detach(&sock);
|
isc_socket_detach(&sock);
|
||||||
@@ -585,7 +593,7 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
notify(command);
|
notify(command);
|
||||||
|
|
||||||
if (strcmp(command, "restart") == 0 || strcmp(command, "status") == 0)
|
if (strcmp(command, "restart") == 0)
|
||||||
fatal("%s: '%s' is not implemented", progname, command);
|
fatal("%s: '%s' is not implemented", progname, command);
|
||||||
|
|
||||||
DO("post event", isc_app_onrun(mctx, task, rndc_start, NULL));
|
DO("post event", isc_app_onrun(mctx, task, rndc_start, NULL));
|
||||||
|
Reference in New Issue
Block a user