1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-23 06:25:24 +00:00

Feature: Export <role>s on stats.xml

This exports id and name of <role>s on stats.xml output. The <role>s
are in a <authentication> container tag and mimic the format used
by the config file.

See #2123
This commit is contained in:
Philipp Schafft 2014-12-19 10:44:24 +00:00
parent 40bb04b644
commit 4c429ab01b

View File

@ -40,6 +40,7 @@
#include "stats.h"
#include "xslt.h"
#include "util.h"
#include "auth.h"
#define CATMODULE "stats"
#include "logging.h"
@ -839,8 +840,11 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
if (source->hidden <= hidden &&
(show_mount == NULL || strcmp (show_mount, source->source) == 0))
{
xmlNodePtr metadata;
xmlNodePtr metadata, authentication, role;
source_t *source_real;
ice_config_t *config;
mount_proxy *mountproxy;
auth_stack_t *stack;
int i;
avl_node *avlnode2 = avl_get_first (source->stats_tree);
@ -863,6 +867,22 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i
for (i = 0; i < source_real->format->vc.comments; i++)
__add_metadata(metadata, source_real->format->vc.user_comments[i]);
avl_tree_unlock(global.source_tree);
authentication = xmlNewTextChild(xmlnode, NULL, XMLSTR("authentication"), NULL);
config = config_get_config();
mountproxy = config_find_mount(config, source->source, MOUNT_TYPE_NORMAL);
auth_stack_addref(stack = mountproxy->authstack);
while (stack) {
auth_t *auth = auth_stack_get(stack);
char idbuf[32];
snprintf(idbuf, sizeof(idbuf), "%lu", auth->id);
role = xmlNewTextChild(authentication, NULL, XMLSTR("role"), NULL);
xmlSetProp(role, XMLSTR("id"), XMLSTR(idbuf));
xmlSetProp(role, XMLSTR("name"), XMLSTR(auth->role));
auth_release(auth);
auth_stack_next(&stack);
}
config_release_config();
}
avlnode = avl_get_next (avlnode);
}