1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-22 04:15:54 -04:00

Feature: Added id and type property to <listen-socket>

This commit is contained in:
Philipp Schafft 2018-05-11 14:01:11 +00:00
parent e1f944a3f5
commit 6ad7f8d3db
2 changed files with 29 additions and 1 deletions

View File

@ -172,6 +172,18 @@ operation_mode config_str_to_omode(const char *str)
}
}
static listener_type_t config_str_to_listener_type(const char *str)
{
if (!str || !*str) {
return LISTENER_TYPE_NORMAL;
} else if (strcasecmp(str, "normal") == 0) {
return LISTENER_TYPE_NORMAL;
} else {
ICECAST_LOG_ERROR("Unknown listener type \"%s\", falling back to NORMAL.", str);
return LISTENER_TYPE_NORMAL;
}
}
static void create_locks(void)
{
thread_mutex_create(&_locks.relay_lock);
@ -580,6 +592,7 @@ listener_t *config_clear_listener(listener_t *listener)
if (listener)
{
next = listener->next;
if (listener->id) xmlFree(listener->id);
if (listener->bind_address) xmlFree(listener->bind_address);
if (listener->shoutcast_mount) xmlFree(listener->shoutcast_mount);
free (listener);
@ -999,7 +1012,7 @@ static void _parse_root(xmlDocPtr doc,
xmlFree(configuration->mimetypes_fn);
configuration->mimetypes_fn = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (xmlStrcmp(node->name, XMLSTR("listen-socket")) == 0) {
_parse_listen_socket(doc, node->xmlChildrenNode, configuration);
_parse_listen_socket(doc, node, configuration);
} else if (xmlStrcmp(node->name, XMLSTR("port")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
if (tmp && *tmp) {
@ -1744,6 +1757,14 @@ static void _parse_listen_socket(xmlDocPtr doc,
return;
listener->port = 8000;
listener->id = (char *)xmlGetProp(node, XMLSTR("id"));
tmp = (char *)xmlGetProp(node, XMLSTR("type"));
listener->type = config_str_to_listener_type(tmp);
xmlFree(tmp);
node = node->xmlChildrenNode;
do {
if (node == NULL)
break;
@ -2486,6 +2507,7 @@ listener_t *config_copy_listener_one(const listener_t *listener) {
n->next = NULL;
n->port = listener->port;
n->so_sndbuf = listener->so_sndbuf;
n->id = (char*)xmlStrdup(XMLSTR(listener->id));
n->bind_address = (char*)xmlStrdup(XMLSTR(listener->bind_address));
n->shoutcast_compat = listener->shoutcast_compat;
n->shoutcast_mount = (char*)xmlStrdup(XMLSTR(listener->shoutcast_mount));

View File

@ -147,8 +147,14 @@ typedef struct _resource {
struct _resource *next;
} resource_t;
typedef enum _listener_type_tag {
LISTENER_TYPE_NORMAL
} listener_type_t;
typedef struct _listener_t {
struct _listener_t *next;
char *id;
listener_type_t type;
int port;
int so_sndbuf;
char *bind_address;