0
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-06-30 22:18:19 -04:00

Feature: Added some more useful client fast events

This commit is contained in:
Philipp Schafft 2018-07-05 11:10:32 +00:00
parent 08cf0c1233
commit cdd09669fa
3 changed files with 18 additions and 0 deletions

View File

@ -393,6 +393,8 @@ void client_send_101(client_t *client, reuse_t reuse)
client->respcode = 101; client->respcode = 101;
client->refbuf->len = strlen(client->refbuf->data); client->refbuf->len = strlen(client->refbuf->data);
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
fserve_add_client(client, NULL); fserve_add_client(client, NULL);
} }
@ -416,6 +418,8 @@ void client_send_204(client_t *client)
client->respcode = 204; client->respcode = 204;
client->refbuf->len = strlen(client->refbuf->data); client->refbuf->len = strlen(client->refbuf->data);
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
fserve_add_client(client, NULL); fserve_add_client(client, NULL);
} }
@ -446,6 +450,8 @@ void client_send_426(client_t *client, reuse_t reuse)
client->reuse = ICECAST_REUSE_KEEPALIVE; client->reuse = ICECAST_REUSE_KEEPALIVE;
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
fserve_add_client(client, NULL); fserve_add_client(client, NULL);
} }
@ -457,6 +463,10 @@ static inline void client_send_500(client_t *client, const char *message)
const ssize_t header_len = sizeof(header) - 1; const ssize_t header_len = sizeof(header) - 1;
ssize_t ret; ssize_t ret;
client->respcode = 500;
client->refbuf->len = 0;
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
ret = client_send_bytes(client, header, header_len); ret = client_send_bytes(client, header, header_len);
/* only send message if we have one AND if header could have transmitted completly */ /* only send message if we have one AND if header could have transmitted completly */
@ -576,6 +586,7 @@ void client_send_reportxml(client_t *client, reportxml_t *report, document_domai
client->refbuf->len = ret; client->refbuf->len = ret;
xmlFree(buff); xmlFree(buff);
client->respcode = status; client->respcode = status;
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
fserve_add_client (client, NULL); fserve_add_client (client, NULL);
} else { } else {
char *fullpath_xslt_template; char *fullpath_xslt_template;
@ -604,6 +615,7 @@ void client_send_reportxml(client_t *client, reportxml_t *report, document_domai
config_release_config(); config_release_config();
ICECAST_LOG_DEBUG("Sending XSLT (%s)", fullpath_xslt_template); ICECAST_LOG_DEBUG("Sending XSLT (%s)", fullpath_xslt_template);
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
xslt_transform(doc, fullpath_xslt_template, client, status); xslt_transform(doc, fullpath_xslt_template, client, status);
free(fullpath_xslt_template); free(fullpath_xslt_template);
} }

View File

@ -1277,6 +1277,8 @@ static void _handle_authed_client(client_t *client, void *uri, auth_result resul
auth_stack_release(client->authstack); auth_stack_release(client->authstack);
client->authstack = NULL; client->authstack = NULL;
fastevent_emit(FASTEVENT_TYPE_CLIENT_AUTHED, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
if (result != AUTH_OK) { if (result != AUTH_OK) {
client_send_error_by_id(client, ICECAST_ERROR_GEN_CLIENT_NEEDS_TO_AUTHENTICATE); client_send_error_by_id(client, ICECAST_ERROR_GEN_CLIENT_NEEDS_TO_AUTHENTICATE);
free(uri); free(uri);
@ -1417,6 +1419,7 @@ static void _handle_authentication_mount_normal(client_t *client, char *uri)
static void _handle_authentication(client_t *client, char *uri) static void _handle_authentication(client_t *client, char *uri)
{ {
fastevent_emit(FASTEVENT_TYPE_CLIENT_READY_FOR_AUTH, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
_handle_authentication_mount_normal(client, uri); _handle_authentication_mount_normal(client, uri);
} }

View File

@ -29,6 +29,9 @@ typedef enum {
FASTEVENT_TYPE_CLIENT_READ, FASTEVENT_TYPE_CLIENT_READ,
FASTEVENT_TYPE_CLIENT_WRITE, FASTEVENT_TYPE_CLIENT_WRITE,
FASTEVENT_TYPE_CLIENT_READ_BODY, FASTEVENT_TYPE_CLIENT_READ_BODY,
FASTEVENT_TYPE_CLIENT_READY_FOR_AUTH,
FASTEVENT_TYPE_CLIENT_AUTHED,
FASTEVENT_TYPE_CLIENT_SEND_RESPONSE,
FASTEVENT_TYPE__END /* must be last element */ FASTEVENT_TYPE__END /* must be last element */
} fastevent_type_t; } fastevent_type_t;