Commit 40bc1e76 authored by Philipp Schafft's avatar Philipp Schafft 🦁
Browse files

Updated listener_remove handler:

 * added ip= and agent=,
 * Some cleanup && made code more uniform,
 * avoid int for size_t vars.
actions: close #1422

svn path=/icecast/trunk/icecast/; revision=18798
parent 2c310838
...@@ -189,14 +189,23 @@ static auth_result url_remove_listener (auth_client *auth_user) ...@@ -189,14 +189,23 @@ static auth_result url_remove_listener (auth_client *auth_user)
ice_config_t *config; ice_config_t *config;
int port; int port;
char *userpwd = NULL, post [4096]; char *userpwd = NULL, post [4096];
const char *agent;
char *user_agent, *ipaddr;
if (url->removeurl == NULL) if (url->removeurl == NULL)
return AUTH_OK; return AUTH_OK;
config = config_get_config (); config = config_get_config ();
server = util_url_escape (config->hostname); server = util_url_escape (config->hostname);
port = config->port; port = config->port;
config_release_config (); config_release_config ();
agent = httpp_getvar (client->parser, "user-agent");
if (agent)
user_agent = util_url_escape (agent);
else
user_agent = strdup ("-");
if (client->username) if (client->username)
username = util_url_escape (client->username); username = util_url_escape (client->username);
else else
...@@ -212,16 +221,19 @@ static auth_result url_remove_listener (auth_client *auth_user) ...@@ -212,16 +221,19 @@ static auth_result url_remove_listener (auth_client *auth_user)
if (mountreq == NULL) if (mountreq == NULL)
mountreq = httpp_getvar (client->parser, HTTPP_VAR_URI); mountreq = httpp_getvar (client->parser, HTTPP_VAR_URI);
mount = util_url_escape (mountreq); mount = util_url_escape (mountreq);
ipaddr = util_url_escape (client->con->ip);
snprintf (post, sizeof (post), snprintf (post, sizeof (post),
"action=listener_remove&server=%s&port=%d&client=%lu&mount=%s" "action=listener_remove&server=%s&port=%d&client=%lu&mount=%s"
"&user=%s&pass=%s&duration=%lu", "&user=%s&pass=%s&duration=%lu&ip=%s&agent=%s",
server, port, client->con->id, mount, username, server, port, client->con->id, mount, username,
password, (long unsigned)duration); password, (long unsigned)duration, ipaddr, user_agent);
free (server); free (server);
free (mount); free (mount);
free (username); free (username);
free (password); free (password);
free (ipaddr);
free (user_agent);
if (strchr (url->removeurl, '@') == NULL) if (strchr (url->removeurl, '@') == NULL)
{ {
...@@ -232,7 +244,7 @@ static auth_result url_remove_listener (auth_client *auth_user) ...@@ -232,7 +244,7 @@ static auth_result url_remove_listener (auth_client *auth_user)
/* auth'd requests may not have a user/pass, but may use query args */ /* auth'd requests may not have a user/pass, but may use query args */
if (client->username && client->password) if (client->username && client->password)
{ {
int len = strlen (client->username) + strlen (client->password) + 2; size_t len = strlen (client->username) + strlen (client->password) + 2;
userpwd = malloc (len); userpwd = malloc (len);
snprintf (userpwd, len, "%s:%s", client->username, client->password); snprintf (userpwd, len, "%s:%s", client->username, client->password);
curl_easy_setopt (url->handle, CURLOPT_USERPWD, userpwd); curl_easy_setopt (url->handle, CURLOPT_USERPWD, userpwd);
...@@ -283,16 +295,20 @@ static auth_result url_add_listener (auth_client *auth_user) ...@@ -283,16 +295,20 @@ static auth_result url_add_listener (auth_client *auth_user)
server = util_url_escape (config->hostname); server = util_url_escape (config->hostname);
port = config->port; port = config->port;
config_release_config (); config_release_config ();
agent = httpp_getvar (client->parser, "user-agent"); agent = httpp_getvar (client->parser, "user-agent");
if (agent == NULL) if (agent)
agent = "-"; user_agent = util_url_escape (agent);
user_agent = util_url_escape (agent); else
user_agent = strdup ("-");
if (client->username) if (client->username)
username = util_url_escape (client->username); username = util_url_escape (client->username);
else else
username = strdup (""); username = strdup ("");
if (client->password) if (client->password)
password = util_url_escape (client->password); password = util_url_escape (client->password);
else else
password = strdup (""); password = strdup ("");
...@@ -353,7 +369,7 @@ static auth_result url_add_listener (auth_client *auth_user) ...@@ -353,7 +369,7 @@ static auth_result url_add_listener (auth_client *auth_user)
/* auth'd requests may not have a user/pass, but may use query args */ /* auth'd requests may not have a user/pass, but may use query args */
if (client->username && client->password) if (client->username && client->password)
{ {
int len = strlen (client->username) + strlen (client->password) + 2; size_t len = strlen (client->username) + strlen (client->password) + 2;
userpwd = malloc (len); userpwd = malloc (len);
snprintf (userpwd, len, "%s:%s", client->username, client->password); snprintf (userpwd, len, "%s:%s", client->username, client->password);
curl_easy_setopt (url->handle, CURLOPT_USERPWD, userpwd); curl_easy_setopt (url->handle, CURLOPT_USERPWD, userpwd);
......
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