summaryrefslogtreecommitdiff
path: root/bin/named/statschannel.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/named/statschannel.c')
-rw-r--r--bin/named/statschannel.c76
1 files changed, 57 insertions, 19 deletions
diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c
index 37e98a8e..8ec08d7b 100644
--- a/bin/named/statschannel.c
+++ b/bin/named/statschannel.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2013 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2008-2014 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -27,6 +27,7 @@
#include <isc/print.h>
#include <isc/socket.h>
#include <isc/stats.h>
+#include <isc/string.h>
#include <isc/task.h>
#include <dns/cache.h>
@@ -1057,7 +1058,7 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
ISC_XMLCHAR "type=\"text/xsl\" href=\"/bind9.ver3.xsl\""));
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "statistics"));
TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "version",
- ISC_XMLCHAR "3.0"));
+ ISC_XMLCHAR "3.3"));
/* Set common fields for statistics dump */
dumparg.type = statsformat_xml;
@@ -1093,9 +1094,9 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
if (dumparg.result != ISC_R_SUCCESS)
goto error;
}
+else fprintf(stderr, "WTF WHERE'S RESQUERYRSTATS\n");
TRY0(xmlTextWriterEndElement(writer));
- /* <resstats> */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "counters"));
TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type",
ISC_XMLCHAR "resstats"));
@@ -1109,7 +1110,7 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
if (result != ISC_R_SUCCESS)
goto error;
}
- TRY0(xmlTextWriterEndElement(writer)); /* </resstats> */
+ TRY0(xmlTextWriterEndElement(writer));
cacherrstats = dns_db_getrrsetstats(view->cachedb);
if (cacherrstats != NULL) {
@@ -1156,7 +1157,7 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
ISC_XMLCHAR "opcode"));
dns_opcodestats_dump(server->opcodestats, opcodestat_dump, &dumparg,
- 0);
+ ISC_STATSDUMP_VERBOSE);
if (dumparg.result != ISC_R_SUCCESS)
goto error;
@@ -1370,10 +1371,10 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) {
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "server"));
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "boot-time"));
TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR boottime));
- TRY0(xmlTextWriterEndElement(writer));
+ TRY0(xmlTextWriterEndElement(writer)); /* boot-time */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "current-time"));
TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR nowstr));
- TRY0(xmlTextWriterEndElement(writer));
+ TRY0(xmlTextWriterEndElement(writer)); /* current-time */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "requests"));
dumparg.result = ISC_R_SUCCESS;
@@ -1461,7 +1462,8 @@ wrap_xmlfree(isc_buffer_t *buffer, void *arg) {
}
static isc_result_t
-render_index(const char *url, const char *querystring, void *arg,
+render_index(const char *url, isc_httpdurl_t *urlinfo,
+ const char *querystring, const char *headers, void *arg,
unsigned int *retcode, const char **retmsg, const char **mimetype,
isc_buffer_t *b, isc_httpdfree_t **freecb,
void **freecb_args)
@@ -1472,7 +1474,9 @@ render_index(const char *url, const char *querystring, void *arg,
isc_result_t result;
UNUSED(url);
+ UNUSED(urlinfo);
UNUSED(querystring);
+ UNUSED(headers);
result = generatexml(server, &msglen, &msg);
@@ -1495,22 +1499,56 @@ render_index(const char *url, const char *querystring, void *arg,
#endif /* HAVE_LIBXML2 */
static isc_result_t
-render_xsl(const char *url, const char *querystring, void *args,
- unsigned int *retcode, const char **retmsg, const char **mimetype,
- isc_buffer_t *b, isc_httpdfree_t **freecb,
- void **freecb_args)
+render_xsl(const char *url, isc_httpdurl_t *urlinfo,
+ const char *querystring, const char *headers,
+ void *args, unsigned int *retcode, const char **retmsg,
+ const char **mimetype, isc_buffer_t *b,
+ isc_httpdfree_t **freecb, void **freecb_args)
{
+ isc_result_t result;
+
UNUSED(url);
UNUSED(querystring);
UNUSED(args);
+ *freecb = NULL;
+ *freecb_args = NULL;
+ *mimetype = "text/xslt+xml";
+
+ if (urlinfo->isstatic) {
+ isc_time_t when;
+ char *p = strcasestr(headers, "If-Modified-Since: ");
+
+ if (p != NULL) {
+ time_t t1, t2;
+ p += strlen("If-Modified-Since: ");
+ result = isc_time_parsehttptimestamp(p, &when);
+ if (result != ISC_R_SUCCESS)
+ goto send;
+
+ result = isc_time_secondsastimet(&when, &t1);
+ if (result != ISC_R_SUCCESS)
+ goto send;
+
+ result = isc_time_secondsastimet(&urlinfo->loadtime,
+ &t2);
+ if (result != ISC_R_SUCCESS)
+ goto send;
+
+ if (t1 < t2)
+ goto send;
+
+ *retcode = 304;
+ *retmsg = "Not modified";
+ return (ISC_R_SUCCESS);
+ }
+ }
+
+ send:
*retcode = 200;
*retmsg = "OK";
- *mimetype = "text/xslt+xml";
isc_buffer_reinit(b, xslmsg, strlen(xslmsg));
isc_buffer_add(b, strlen(xslmsg));
- *freecb = NULL;
- *freecb_args = NULL;
return (ISC_R_SUCCESS);
}
@@ -1647,11 +1685,11 @@ add_listener(ns_server_t *server, ns_statschannel_t **listenerp,
#endif /* NEWSTATS */
#endif
#ifdef NEWSTATS
- isc_httpdmgr_addurl(listener->httpdmgr, "/bind9.ver3.xsl", render_xsl,
- server);
+ isc_httpdmgr_addurl2(listener->httpdmgr, "/bind9.ver3.xsl", ISC_TRUE,
+ render_xsl, server);
#else /* OLDSTATS */
- isc_httpdmgr_addurl(listener->httpdmgr, "/bind9.xsl", render_xsl,
- server);
+ isc_httpdmgr_addurl2(listener->httpdmgr, "/bind9.xsl", ISC_TRUE,
+ render_xsl, server);
#endif /* NEWSTATS */
*listenerp = listener;
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,