mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Feature: Added JSON output for admin command manageauth
This commit is contained in:
parent
5e9feb611a
commit
9ad34f97ad
@ -100,6 +100,7 @@
|
|||||||
#define ADMIN_XSL_RESPONSE "response.xsl"
|
#define ADMIN_XSL_RESPONSE "response.xsl"
|
||||||
#define MANAGEAUTH_RAW_REQUEST "manageauth"
|
#define MANAGEAUTH_RAW_REQUEST "manageauth"
|
||||||
#define MANAGEAUTH_HTML_REQUEST "manageauth.xsl"
|
#define MANAGEAUTH_HTML_REQUEST "manageauth.xsl"
|
||||||
|
#define MANAGEAUTH_JSON_REQUEST "manageauth.json"
|
||||||
#define UPDATEMETADATA_RAW_REQUEST "updatemetadata"
|
#define UPDATEMETADATA_RAW_REQUEST "updatemetadata"
|
||||||
#define UPDATEMETADATA_HTML_REQUEST "updatemetadata.xsl"
|
#define UPDATEMETADATA_HTML_REQUEST "updatemetadata.xsl"
|
||||||
#define UPDATEMETADATA_JSON_REQUEST "updatemetadata.json"
|
#define UPDATEMETADATA_JSON_REQUEST "updatemetadata.json"
|
||||||
@ -177,6 +178,7 @@ static const admin_command_handler_t handlers[] = {
|
|||||||
{ KILLSOURCE_JSON_REQUEST, ADMINTYPE_MOUNT, ADMIN_FORMAT_JSON, command_kill_source, NULL},
|
{ KILLSOURCE_JSON_REQUEST, ADMINTYPE_MOUNT, ADMIN_FORMAT_JSON, command_kill_source, NULL},
|
||||||
{ MANAGEAUTH_RAW_REQUEST, ADMINTYPE_GENERAL, ADMIN_FORMAT_RAW, command_manageauth, NULL},
|
{ MANAGEAUTH_RAW_REQUEST, ADMINTYPE_GENERAL, ADMIN_FORMAT_RAW, command_manageauth, NULL},
|
||||||
{ MANAGEAUTH_HTML_REQUEST, ADMINTYPE_GENERAL, ADMIN_FORMAT_HTML, command_manageauth, NULL},
|
{ MANAGEAUTH_HTML_REQUEST, ADMINTYPE_GENERAL, ADMIN_FORMAT_HTML, command_manageauth, NULL},
|
||||||
|
{ MANAGEAUTH_JSON_REQUEST, ADMINTYPE_GENERAL, ADMIN_FORMAT_JSON, command_manageauth, NULL},
|
||||||
{ UPDATEMETADATA_RAW_REQUEST, ADMINTYPE_MOUNT, ADMIN_FORMAT_RAW, command_updatemetadata, NULL},
|
{ UPDATEMETADATA_RAW_REQUEST, ADMINTYPE_MOUNT, ADMIN_FORMAT_RAW, command_updatemetadata, NULL},
|
||||||
{ UPDATEMETADATA_HTML_REQUEST, ADMINTYPE_MOUNT, ADMIN_FORMAT_HTML, command_updatemetadata, NULL},
|
{ UPDATEMETADATA_HTML_REQUEST, ADMINTYPE_MOUNT, ADMIN_FORMAT_HTML, command_updatemetadata, NULL},
|
||||||
{ UPDATEMETADATA_JSON_REQUEST, ADMINTYPE_MOUNT, ADMIN_FORMAT_JSON, command_updatemetadata, NULL},
|
{ UPDATEMETADATA_JSON_REQUEST, ADMINTYPE_MOUNT, ADMIN_FORMAT_JSON, command_updatemetadata, NULL},
|
||||||
|
@ -378,9 +378,13 @@ static void render_node_legacystats(json_renderer_t *renderer, xmlDocPtr doc, xm
|
|||||||
json_renderer_write_key(renderer, (const char *)cur->name, JSON_RENDERER_FLAGS_NONE);
|
json_renderer_write_key(renderer, (const char *)cur->name, JSON_RENDERER_FLAGS_NONE);
|
||||||
handle_node_modules(renderer, doc, cur, node, cache);
|
handle_node_modules(renderer, doc, cur, node, cache);
|
||||||
nodelist_unset(&nodelist, i);
|
nodelist_unset(&nodelist, i);
|
||||||
} else if (strcmp((const char *)cur->name, "source") == 0) {
|
} else if (strcmp((const char *)cur->name, "source") == 0 || strcmp((const char *)cur->name, "role") == 0) {
|
||||||
|
const char *key = "id";
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
|
if (strcmp((const char *)cur->name, "source") == 0)
|
||||||
|
key = "mount";
|
||||||
|
|
||||||
json_renderer_write_key(renderer, (const char *)cur->name, JSON_RENDERER_FLAGS_NONE);
|
json_renderer_write_key(renderer, (const char *)cur->name, JSON_RENDERER_FLAGS_NONE);
|
||||||
json_renderer_begin(renderer, JSON_ELEMENT_TYPE_OBJECT);
|
json_renderer_begin(renderer, JSON_ELEMENT_TYPE_OBJECT);
|
||||||
|
|
||||||
@ -390,10 +394,10 @@ static void render_node_legacystats(json_renderer_t *renderer, xmlDocPtr doc, xm
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (subcur->type == XML_ELEMENT_NODE && subcur->name && strcmp((const char *)cur->name, (const char *)subcur->name) == 0) {
|
if (subcur->type == XML_ELEMENT_NODE && subcur->name && strcmp((const char *)cur->name, (const char *)subcur->name) == 0) {
|
||||||
xmlChar *mount = xmlGetProp(subcur, XMLSTR("mount"));
|
xmlChar *keyval = xmlGetProp(subcur, XMLSTR(key));
|
||||||
if (mount) {
|
if (keyval) {
|
||||||
json_renderer_write_key(renderer, (const char *)mount, JSON_RENDERER_FLAGS_NONE);
|
json_renderer_write_key(renderer, (const char *)keyval, JSON_RENDERER_FLAGS_NONE);
|
||||||
xmlFree(mount);
|
xmlFree(keyval);
|
||||||
nodelist_unset(&nodelist, j);
|
nodelist_unset(&nodelist, j);
|
||||||
render_node_legacystats(renderer, doc, subcur, cur, cache);
|
render_node_legacystats(renderer, doc, subcur, cur, cache);
|
||||||
}
|
}
|
||||||
@ -401,7 +405,6 @@ static void render_node_legacystats(json_renderer_t *renderer, xmlDocPtr doc, xm
|
|||||||
}
|
}
|
||||||
|
|
||||||
json_renderer_end(renderer);
|
json_renderer_end(renderer);
|
||||||
nodelist_unset(&nodelist, i);
|
|
||||||
} else if (strcmp((const char *)cur->name, "listener") == 0) {
|
} else if (strcmp((const char *)cur->name, "listener") == 0) {
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
@ -508,6 +511,38 @@ static void render_node_legacystats(json_renderer_t *renderer, xmlDocPtr doc, xm
|
|||||||
}
|
}
|
||||||
} while ((cur = cur->next));
|
} while ((cur = cur->next));
|
||||||
}
|
}
|
||||||
|
if (node->xmlChildrenNode) {
|
||||||
|
xmlNodePtr cur = node->xmlChildrenNode;
|
||||||
|
do {
|
||||||
|
if (cur->type == XML_ELEMENT_NODE && cur->name) {
|
||||||
|
if (strcmp((const char *)cur->name, "users") == 0) {
|
||||||
|
json_renderer_write_key(renderer, (const char *)cur->name, JSON_RENDERER_FLAGS_NONE);
|
||||||
|
json_renderer_begin(renderer, JSON_ELEMENT_TYPE_ARRAY);
|
||||||
|
if (cur->xmlChildrenNode) {
|
||||||
|
xmlNodePtr subcur = cur->xmlChildrenNode;
|
||||||
|
do {
|
||||||
|
render_node_legacystats(renderer, doc, subcur, cur, cache);
|
||||||
|
subcur = subcur->next;
|
||||||
|
} while (subcur);
|
||||||
|
}
|
||||||
|
json_renderer_end(renderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur = cur->next;
|
||||||
|
} while (cur);
|
||||||
|
}
|
||||||
|
json_renderer_end(renderer);
|
||||||
|
} else if (strcmp(nodename, "user") == 0) {
|
||||||
|
json_renderer_begin(renderer, JSON_ELEMENT_TYPE_OBJECT);
|
||||||
|
if (node->xmlChildrenNode) {
|
||||||
|
xmlNodePtr cur = node->xmlChildrenNode;
|
||||||
|
do {
|
||||||
|
if (cur->xmlChildrenNode && !cur->xmlChildrenNode->next && cur->xmlChildrenNode->type == XML_TEXT_NODE) {
|
||||||
|
handle_textchildnode(renderer, doc, cur, node, cache);
|
||||||
|
}
|
||||||
|
cur = cur->next;
|
||||||
|
} while (cur);
|
||||||
|
}
|
||||||
json_renderer_end(renderer);
|
json_renderer_end(renderer);
|
||||||
} else {
|
} else {
|
||||||
handled = 0;
|
handled = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user