mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-01-03 14:56:34 -05:00
Clanup: Unify <authentication> parser code
This commit is contained in:
parent
ed266a5dc7
commit
4b44c73d1c
@ -1188,6 +1188,34 @@ static void _parse_limits(xmlDocPtr doc,
|
||||
} while ((node = node->next));
|
||||
}
|
||||
|
||||
static void _parse_authentication_node(xmlNodePtr node, auth_stack_t **authstack)
|
||||
{
|
||||
xmlChar *tmp;
|
||||
|
||||
if (xmlStrcmp(node->name, XMLSTR("authentication")) != 0)
|
||||
return;
|
||||
|
||||
tmp = xmlGetProp(node, XMLSTR("type"));
|
||||
if (tmp) {
|
||||
ICECAST_LOG_ERROR("new style parser called on old style config.");
|
||||
xmlFree(tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
xmlNodePtr child = node->xmlChildrenNode;
|
||||
do {
|
||||
if (child == NULL)
|
||||
break;
|
||||
if (xmlIsBlankNode(child))
|
||||
continue;
|
||||
if (xmlStrcmp(child->name, XMLSTR("role")) == 0) {
|
||||
auth_t *auth = auth_get_authenticator(child);
|
||||
auth_stack_push(authstack, auth);
|
||||
auth_release(auth);
|
||||
}
|
||||
} while ((child = child->next));
|
||||
}
|
||||
|
||||
static void _parse_mount_oldstyle_authentication(mount_proxy *mount,
|
||||
xmlNodePtr node,
|
||||
auth_stack_t **authstack)
|
||||
@ -1474,18 +1502,7 @@ static void _parse_mount(xmlDocPtr doc,
|
||||
xmlFree(tmp);
|
||||
_parse_mount_oldstyle_authentication(mount, node, &authstack);
|
||||
} else {
|
||||
xmlNodePtr child = node->xmlChildrenNode;
|
||||
do {
|
||||
if (child == NULL)
|
||||
break;
|
||||
if (xmlIsBlankNode(child))
|
||||
continue;
|
||||
if (xmlStrcmp(child->name, XMLSTR("role")) == 0) {
|
||||
auth_t *auth = auth_get_authenticator(child);
|
||||
auth_stack_push(&authstack, auth);
|
||||
auth_release(auth);
|
||||
}
|
||||
} while ((child = child->next));
|
||||
_parse_authentication_node(node, &authstack);
|
||||
}
|
||||
} else if (xmlStrcmp(node->name, XMLSTR("on-connect")) == 0) {
|
||||
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
@ -1895,18 +1912,7 @@ static void _parse_listen_socket(xmlDocPtr doc,
|
||||
} else if (xmlStrcmp(node->name, XMLSTR("so-sndbuf")) == 0) {
|
||||
__read_int(doc, node, &listener->so_sndbuf, "<so-sndbuf> must not be empty.");
|
||||
} else if (xmlStrcmp(node->name, XMLSTR("authentication")) == 0) {
|
||||
xmlNodePtr child = node->xmlChildrenNode;
|
||||
do {
|
||||
if (child == NULL)
|
||||
break;
|
||||
if (xmlIsBlankNode(child))
|
||||
continue;
|
||||
if (xmlStrcmp(child->name, XMLSTR("role")) == 0) {
|
||||
auth_t *auth = auth_get_authenticator(child);
|
||||
auth_stack_push(&(listener->authstack), auth);
|
||||
auth_release(auth);
|
||||
}
|
||||
} while ((child = child->next));
|
||||
_parse_authentication_node(node, &(listener->authstack));
|
||||
}
|
||||
} while ((node = node->next));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user