1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Feature: Implemented DELETE on sources

This commit is contained in:
Philipp Schafft 2018-10-26 08:03:46 +00:00
parent ccca2460aa
commit 0bdad13fd2
2 changed files with 20 additions and 2 deletions

View File

@ -1101,7 +1101,7 @@ static void _parse_root(xmlDocPtr doc,
"legacy-global-source",
AUTH_TYPE_STATIC, "source",
source_password, NULL,
"source,put,get", 0, "*");
"source,put,get,delete", 0, "*");
}
} else {
ICECAST_LOG_ERROR("Can not find nor create default mount, but "
@ -1990,7 +1990,7 @@ static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node,
if (admin_password && admin_username)
__append_old_style_auth(&old_style, "legacy-admin", AUTH_TYPE_STATIC,
admin_username, admin_password, NULL, "get,post,head,stats,options", 1, "*");
admin_username, admin_password, NULL, "get,post,head,stats,options,delete", 1, "*");
if (relay_password && relay_username)
__append_old_style_auth(&old_style, "legacy-relay", AUTH_TYPE_STATIC,

View File

@ -1066,6 +1066,21 @@ static void _handle_get_request(client_t *client) {
}
}
static void _handle_delete_request(client_t *client) {
source_t *source;
avl_tree_wlock(global.source_tree);
source = source_find_mount_raw(client->uri);
if (source) {
source->running = 0;
avl_tree_unlock(global.source_tree);
client_send_204(client);
} else {
avl_tree_unlock(global.source_tree);
client_send_error_by_id(client, ICECAST_ERROR_CON_UNKNOWN_REQUEST);
}
}
static void _handle_shoutcast_compatible(client_queue_t *node)
{
char *http_compliant;
@ -1328,6 +1343,9 @@ static void _handle_authed_client(client_t *client, void *userdata, auth_result
case httpp_req_options:
_handle_get_request(client);
break;
case httpp_req_delete:
_handle_delete_request(client);
break;
default:
ICECAST_LOG_ERROR("Wrong request type from client");
client_send_error_by_id(client, ICECAST_ERROR_CON_UNKNOWN_REQUEST);