Commit 4b44c73d authored by Philipp Schafft's avatar Philipp Schafft 🦁

Clanup: Unify <authentication> parser code

parent ed266a5d
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment