MCPcopy Create free account
hub / github.com/apache/httpd / md_domains_status_hook

Function md_domains_status_hook

modules/md/mod_md_status.c:742–812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

740}
741
742int md_domains_status_hook(request_rec *r, int flags)
743{
744 const md_srv_conf_t *sc;
745 const md_mod_conf_t *mc;
746 int i;
747 status_ctx ctx;
748 apr_array_header_t *mds;
749 md_json_t *jstatus, *jstock;
750
751 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "server-status for managed domains, start");
752 sc = ap_get_module_config(r->server->module_config, &md_module);
753 if (!sc) return DECLINED;
754 mc = sc->mc;
755 if (!mc || !mc->server_status_enabled) return DECLINED;
756
757 ctx.p = r->pool;
758 ctx.mc = mc;
759 ctx.bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
760 ctx.flags = flags;
761 ctx.prefix = "ManagedCertificates";
762 ctx.separator = " ";
763
764 mds = apr_array_copy(r->pool, mc->mds);
765 qsort(mds->elts, (size_t)mds->nelts, sizeof(md_t *), md_name_cmp);
766
767 if (!HTML_STATUS(&ctx)) {
768 int total = 0, complete = 0, renewing = 0, errored = 0, ready = 0;
769 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "no-html managed domain status summary");
770 if (mc->mds->nelts > 0) {
771 md_status_take_stock(&jstock, mds, mc->reg, r->pool);
772 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "got JSON managed domain status summary");
773 total = (int)md_json_getl(jstock, MD_KEY_TOTAL, NULL);
774 complete = (int)md_json_getl(jstock, MD_KEY_COMPLETE, NULL);
775 renewing = (int)md_json_getl(jstock, MD_KEY_RENEWING, NULL);
776 errored = (int)md_json_getl(jstock, MD_KEY_ERRORED, NULL);
777 ready = (int)md_json_getl(jstock, MD_KEY_READY, NULL);
778 }
779 apr_brigade_printf(ctx.bb, NULL, NULL, "%sTotal: %d\n", ctx.prefix, total);
780 apr_brigade_printf(ctx.bb, NULL, NULL, "%sOK: %d\n", ctx.prefix, complete);
781 apr_brigade_printf(ctx.bb, NULL, NULL, "%sRenew: %d\n", ctx.prefix, renewing);
782 apr_brigade_printf(ctx.bb, NULL, NULL, "%sErrored: %d\n", ctx.prefix, errored);
783 apr_brigade_printf(ctx.bb, NULL, NULL, "%sReady: %d\n", ctx.prefix, ready);
784 }
785 if (mc->mds->nelts > 0) {
786 md_status_get_json(&jstatus, mds, mc->reg, mc->ocsp, r->pool);
787 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "got JSON managed domain status");
788 if (HTML_STATUS(&ctx)) {
789 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "html managed domain status table");
790 apr_brigade_puts(ctx.bb, NULL, NULL,
791 "<hr>\n<h3>Managed Certificates</h3>\n<table class='md_status'><thead><tr>\n");
792 for (i = 0; i < (int)(sizeof(status_infos)/sizeof(status_infos[0])); ++i) {
793 si_add_header(&ctx, &status_infos[i]);
794 }
795 apr_brigade_puts(ctx.bb, NULL, NULL, "</tr>\n</thead><tbody>");
796 }
797 else {
798 ctx.prefix = "ManagedDomain";
799 }

Callers

nothing calls this directly

Calls 7

ap_get_module_configFunction · 0.85
md_status_take_stockFunction · 0.85
md_json_getlFunction · 0.85
md_status_get_jsonFunction · 0.85
si_add_headerFunction · 0.85
md_json_iteraFunction · 0.85
ap_pass_brigadeFunction · 0.85

Tested by

no test coverage detected