Commit 11c6e103 authored by Karl Heyes's avatar Karl Heyes
Browse files

change status code for server/stream full cases (#738), also some others places

where connections are terminated.

svn path=/icecast/trunk/icecast/; revision=10393
parent f7afa976
...@@ -389,7 +389,7 @@ void add_client (const char *mount, client_t *client) ...@@ -389,7 +389,7 @@ void add_client (const char *mount, client_t *client)
if (mountinfo && mountinfo->no_mount) if (mountinfo && mountinfo->no_mount)
{ {
config_release_config (); config_release_config ();
client_send_404 (client, "mountpoint unavailable"); client_send_403 (client, "mountpoint unavailable");
return; return;
} }
if (mountinfo && mountinfo->auth) if (mountinfo && mountinfo->auth)
...@@ -400,7 +400,7 @@ void add_client (const char *mount, client_t *client) ...@@ -400,7 +400,7 @@ void add_client (const char *mount, client_t *client)
{ {
config_release_config (); config_release_config ();
WARN0 ("too many clients awaiting authentication"); WARN0 ("too many clients awaiting authentication");
client_send_404 (client, "busy, please try again later"); client_send_403 (client, "busy, please try again later");
return; return;
} }
auth_client_setup (mountinfo, client); auth_client_setup (mountinfo, client);
...@@ -429,7 +429,7 @@ void add_client (const char *mount, client_t *client) ...@@ -429,7 +429,7 @@ void add_client (const char *mount, client_t *client)
int ret = add_authenticated_client (mount, mountinfo, client); int ret = add_authenticated_client (mount, mountinfo, client);
config_release_config (); config_release_config ();
if (ret < 0) if (ret < 0)
client_send_404 (client, "stream full"); client_send_403 (client, "max listeners reached");
} }
} }
......
...@@ -190,14 +190,15 @@ void client_send_401(client_t *client) { ...@@ -190,14 +190,15 @@ void client_send_401(client_t *client) {
fserve_add_client (client, NULL); fserve_add_client (client, NULL);
} }
void client_send_403(client_t *client) { void client_send_403(client_t *client, const char *reason)
int bytes = sock_write(client->con->sock, {
"HTTP/1.0 403 Forbidden\r\n" if (reason == NULL)
"\r\n" reason = "Forbidden";
"Access restricted.\r\n"); snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
if(bytes > 0) client->con->sent_bytes = bytes; "HTTP/1.0 403 %s\r\n\r\n", reason);
client->respcode = 403; client->respcode = 403;
client_destroy(client); client->refbuf->len = strlen (client->refbuf->data);
fserve_add_client (client, NULL);
} }
......
...@@ -72,7 +72,7 @@ void client_destroy(client_t *client); ...@@ -72,7 +72,7 @@ void client_destroy(client_t *client);
void client_send_504(client_t *client, char *message); void client_send_504(client_t *client, char *message);
void client_send_404(client_t *client, char *message); void client_send_404(client_t *client, char *message);
void client_send_401(client_t *client); void client_send_401(client_t *client);
void client_send_403(client_t *client); void client_send_403(client_t *client, const char *reason);
void client_send_400(client_t *client, char *message); void client_send_400(client_t *client, char *message);
int client_send_bytes (client_t *client, const void *buf, unsigned len); int client_send_bytes (client_t *client, const void *buf, unsigned len);
int client_read_bytes (client_t *client, void *buf, unsigned len); int client_read_bytes (client_t *client, void *buf, unsigned len);
......
...@@ -438,7 +438,7 @@ void connection_accept_loop(void) ...@@ -438,7 +438,7 @@ void connection_accept_loop(void)
if (client_create (&client, con, NULL) < 0) if (client_create (&client, con, NULL) < 0)
{ {
global_unlock(); global_unlock();
client_send_404 (client, "Icecast connection limit reached"); client_send_403 (client, "Icecast connection limit reached");
continue; continue;
} }
global_unlock(); global_unlock();
...@@ -515,7 +515,7 @@ int connection_complete_source (source_t *source, int response) ...@@ -515,7 +515,7 @@ int connection_complete_source (source_t *source, int response)
config_release_config(); config_release_config();
if (response) if (response)
{ {
client_send_404 (source->client, "Content-type not supported"); client_send_403 (source->client, "Content-type not supported");
source->client = NULL; source->client = NULL;
} }
WARN1("Content-type \"%s\" not supported, dropping source", contenttype); WARN1("Content-type \"%s\" not supported, dropping source", contenttype);
...@@ -535,7 +535,7 @@ int connection_complete_source (source_t *source, int response) ...@@ -535,7 +535,7 @@ int connection_complete_source (source_t *source, int response)
config_release_config(); config_release_config();
if (response) if (response)
{ {
client_send_404 (source->client, "internal format allocation problem"); client_send_403 (source->client, "internal format allocation problem");
source->client = NULL; source->client = NULL;
} }
WARN1 ("plugin format failed for \"%s\"", source->mount); WARN1 ("plugin format failed for \"%s\"", source->mount);
...@@ -566,7 +566,7 @@ int connection_complete_source (source_t *source, int response) ...@@ -566,7 +566,7 @@ int connection_complete_source (source_t *source, int response)
if (response) if (response)
{ {
client_send_404 (source->client, "too many sources connected"); client_send_403 (source->client, "too many sources connected");
source->client = NULL; source->client = NULL;
} }
...@@ -776,7 +776,7 @@ static void _handle_source_request (client_t *client, char *uri, int auth_style) ...@@ -776,7 +776,7 @@ static void _handle_source_request (client_t *client, char *uri, int auth_style)
} }
else else
{ {
client_send_404 (client, "Mountpoint in use"); client_send_403 (client, "Mountpoint in use");
WARN1 ("Mountpoint %s in use", uri); WARN1 ("Mountpoint %s in use", uri);
} }
} }
......
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