Skip to content

Commit

Permalink
Add shoutcast user auth and mount designation
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTaLlesT committed Nov 13, 2018
1 parent 4a5eefe commit 0d35359
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
15 changes: 8 additions & 7 deletions src/admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,22 @@ int admin_handle_request (client_t *client, const char *uri)
if(login_pass) *login_pass++ = '\0';
if(login_mount) *login_mount++ = '\0';

client->username = strdup(login_pass && (!login_mount || (login_mount && login_mount > pass_copy +1)) ? pass_copy : "source");
client->password = strdup(login_pass && login_pass < login_end ? login_pass : pass_copy);
client->username = strdup(login_pass && (!login_mount
|| (login_mount && login_mount > pass_copy +1)) ? pass_copy : "source");
client->password = strdup(login_pass && login_pass < login_end
? login_pass : pass_copy);

if (mount == NULL)
{
if (login_mount && login_mount < login_end)
{
if(*login_mount != '/')
*--login_mount = '/';
httpp_set_query_param (client->parser, "mount", login_mount);
if(*login_mount != '/') *--login_mount = '/';
httpp_set_query_param (client->parser, "mount", login_mount);
}
else if (client->server_conn && client->server_conn->shoutcast_mount)
{
httpp_set_query_param (client->parser, "mount",
client->server_conn->shoutcast_mount);
httpp_set_query_param (client->parser, "mount",
client->server_conn->shoutcast_mount);
}
mount = httpp_get_query_param (client->parser, "mount");
}
Expand Down
17 changes: 9 additions & 8 deletions src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1163,20 +1163,21 @@ static int shoutcast_source_client (client_t *client)
if(login_mount) *login_mount++ = '\0';

snprintf (header, sizeof(header), "%s:%s",
login_pass && (!login_mount || (login_mount && login_mount > refbuf->data +1)) ? refbuf->data : "source",
login_pass && (!login_mount || (login_mount && login_mount > refbuf->data +1))
? refbuf->data : "source",
login_pass && login_pass < login_end ? login_pass : refbuf->data
);

if(login_mount && login_mount < login_end)
{
if(*login_mount != '/')
*--login_mount = '/';
if(*login_mount != '/') *--login_mount = '/';

// Reject mounts with "unsafe" characters. Behavior is unpredictable/undesirable
if (!util_url_safe(login_mount +1)) {
INFO1("rejected mount '%s'", login_mount);
break;
}
// Reject mounts with "unsafe" characters. Behavior is unpredictable/undesirable
if (!util_url_safe(login_mount +1))
{
INFO1("rejected mount '%s'", login_mount);
break;
}
} else {
login_mount = client->server_conn->shoutcast_mount;
}
Expand Down

0 comments on commit 0d35359

Please sign in to comment.