mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
make admin replies go via fserve
svn path=/icecast/trunk/icecast/; revision=9741
This commit is contained in:
parent
dde143d4b1
commit
9179ffe661
35
src/admin.c
35
src/admin.c
@ -280,6 +280,7 @@ void admin_send_response(xmlDocPtr doc, client_t *client,
|
|||||||
"Content-Length: ";
|
"Content-Length: ";
|
||||||
xmlDocDumpMemory(doc, &buff, &len);
|
xmlDocDumpMemory(doc, &buff, &len);
|
||||||
buf_len = strlen (http) + len + 20;
|
buf_len = strlen (http) + len + 20;
|
||||||
|
client_set_queue (client, NULL);
|
||||||
client->refbuf = refbuf_new (buf_len);
|
client->refbuf = refbuf_new (buf_len);
|
||||||
len = snprintf (client->refbuf->data, buf_len, "%s%d\r\n\r\n%s", http, len, buff);
|
len = snprintf (client->refbuf->data, buf_len, "%s%d\r\n\r\n%s", http, len, buff);
|
||||||
client->refbuf->len = len;
|
client->refbuf->len = len;
|
||||||
@ -547,15 +548,13 @@ static void admin_handle_mount_request(client_t *client, source_t *source,
|
|||||||
|
|
||||||
static void html_success(client_t *client, char *message)
|
static void html_success(client_t *client, char *message)
|
||||||
{
|
{
|
||||||
int bytes;
|
|
||||||
|
|
||||||
client->respcode = 200;
|
client->respcode = 200;
|
||||||
bytes = sock_write(client->con->sock,
|
snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
|
||||||
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"
|
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"
|
||||||
"<html><head><title>Admin request successful</title></head>"
|
"<html><head><title>Admin request successful</title></head>"
|
||||||
"<body><p>%s</p></body></html>", message);
|
"<body><p>%s</p></body></html>", message);
|
||||||
if(bytes > 0) client->con->sent_bytes = bytes;
|
client->refbuf->len = strlen (client->refbuf->data);
|
||||||
client_destroy(client);
|
fserve_add_client (client, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -679,33 +678,28 @@ static void command_buildm3u(client_t *client, source_t *source,
|
|||||||
{
|
{
|
||||||
char *username = NULL;
|
char *username = NULL;
|
||||||
char *password = NULL;
|
char *password = NULL;
|
||||||
char *host = NULL;
|
|
||||||
int port = 0;
|
|
||||||
ice_config_t *config;
|
ice_config_t *config;
|
||||||
|
|
||||||
COMMAND_REQUIRE(client, "username", username);
|
COMMAND_REQUIRE(client, "username", username);
|
||||||
COMMAND_REQUIRE(client, "password", password);
|
COMMAND_REQUIRE(client, "password", password);
|
||||||
|
|
||||||
config = config_get_config();
|
|
||||||
host = strdup(config->hostname);
|
|
||||||
port = config->port;
|
|
||||||
config_release_config();
|
|
||||||
|
|
||||||
client->respcode = 200;
|
client->respcode = 200;
|
||||||
sock_write(client->con->sock,
|
config = config_get_config();
|
||||||
|
snprintf (client->refbuf->data, client->refbuf->len,
|
||||||
"HTTP/1.0 200 OK\r\n"
|
"HTTP/1.0 200 OK\r\n"
|
||||||
"Content-Type: audio/x-mpegurl\r\n"
|
"Content-Type: audio/x-mpegurl\r\n"
|
||||||
"Content-Disposition = attachment; filename=listen.m3u\r\n\r\n"
|
"Content-Disposition = attachment; filename=listen.m3u\r\n\r\n"
|
||||||
"http://%s:%s@%s:%d%s\r\n",
|
"http://%s:%s@%s:%d%s\r\n",
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
host,
|
config->hostname,
|
||||||
port,
|
config->port,
|
||||||
source->mount
|
source->mount
|
||||||
);
|
);
|
||||||
|
config_release_config();
|
||||||
|
|
||||||
free(host);
|
client->refbuf->len = strlen (client->refbuf->data);
|
||||||
client_destroy(client);
|
fserve_add_client (client, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -978,12 +972,11 @@ static void command_list_mounts(client_t *client, int response)
|
|||||||
if (response == PLAINTEXT)
|
if (response == PLAINTEXT)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
unsigned int remaining = 4096;
|
int remaining = PER_CLIENT_REFBUF_SIZE;
|
||||||
int ret;
|
int ret;
|
||||||
ice_config_t *config = config_get_config ();
|
ice_config_t *config = config_get_config ();
|
||||||
mount_proxy *mountinfo = config->mounts;
|
mount_proxy *mountinfo = config->mounts;
|
||||||
|
|
||||||
client->refbuf = refbuf_new (remaining);
|
|
||||||
buf = client->refbuf->data;
|
buf = client->refbuf->data;
|
||||||
ret = snprintf (buf, remaining,
|
ret = snprintf (buf, remaining,
|
||||||
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
|
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
|
||||||
@ -1011,12 +1004,12 @@ static void command_list_mounts(client_t *client, int response)
|
|||||||
config_release_config();
|
config_release_config();
|
||||||
|
|
||||||
/* handle last line */
|
/* handle last line */
|
||||||
if (ret > 0 && (unsigned)ret < remaining)
|
if (ret > 0 && ret < remaining)
|
||||||
{
|
{
|
||||||
remaining -= ret;
|
remaining -= ret;
|
||||||
buf += ret;
|
buf += ret;
|
||||||
}
|
}
|
||||||
client->refbuf->len = 4096 - remaining;
|
client->refbuf->len = PER_CLIENT_REFBUF_SIZE - remaining;
|
||||||
fserve_add_client (client, NULL);
|
fserve_add_client (client, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user