aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Milbourn <joe.milbourn+mpd@gmail.com>2009-01-13 23:10:41 +0100
committerMax Kellermann <max@duempel.org>2009-01-13 23:10:41 +0100
commit7320db5af2cca2040520694aed4996eb84dba323 (patch)
treee54a575e38587d80cfacf7c51adc25b7e968f47b
parent823ea562421449dabfcf3afc621a211db2c40d3d (diff)
downloadmpd-7320db5af2cca2040520694aed4996eb84dba323.tar.gz
mpd-7320db5af2cca2040520694aed4996eb84dba323.tar.xz
mpd-7320db5af2cca2040520694aed4996eb84dba323.zip
input_curl: honour http_proxy_* config directives
If http_proxy_{host, port, user, password} are provided in mpd.conf they are not passed on to libcurl. As a result mpd cannot stream from behind an http proxy. The attached patch `http_proxy.patch` makes the relevant calls to curl_easy_setopt(...) for all proxy configuration parameters, but is only tested for host and port.
-rw-r--r--NEWS1
-rw-r--r--src/input_curl.c30
2 files changed, 31 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 577ba3fe4..1326154fe 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ MPD 0.14.1 - not yet released
- save the database even if it is empty
* input_curl:
- use select() to eliminate busy loop during connect
+ - honour http_proxy_* config directives
* log: automatically append newline
* fix setenv() conflict on Solaris
* configure.ac: check for pkg-config before using it
diff --git a/src/input_curl.c b/src/input_curl.c
index 20d03222a..f853a6043 100644
--- a/src/input_curl.c
+++ b/src/input_curl.c
@@ -19,6 +19,7 @@
#include "input_curl.h"
#include "input_stream.h"
#include "dlist.h"
+#include "conf.h"
#include "config.h"
#include <assert.h>
@@ -453,6 +454,10 @@ input_curl_easy_init(struct input_stream *is)
struct input_curl *c = is->data;
CURLcode code;
CURLMcode mcode;
+ ConfigParam *proxy_host;
+ ConfigParam *proxy_port;
+ ConfigParam *proxy_user;
+ ConfigParam *proxy_pass;
c->eof = false;
@@ -480,6 +485,31 @@ input_curl_easy_init(struct input_stream *is)
curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, true);
curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error);
+ proxy_host = getConfigParam(CONF_HTTP_PROXY_HOST);
+ proxy_port = getConfigParam(CONF_HTTP_PROXY_PORT);
+ proxy_user = getConfigParam(CONF_HTTP_PROXY_USER);
+ proxy_pass = getConfigParam(CONF_HTTP_PROXY_PASSWORD);
+
+ if (proxy_host != NULL) {
+ char *proxy_host_str;
+
+ if (proxy_port == NULL) {
+ proxy_host_str = g_strdup(proxy_host->value);
+ } else {
+ proxy_host_str =
+ g_strconcat(proxy_host->value, ":", proxy_port->value, NULL);
+ }
+ curl_easy_setopt(c->easy, CURLOPT_PROXY, proxy_host_str);
+ g_free(proxy_host_str);
+ }
+
+ if ((proxy_user != NULL) && (proxy_pass != NULL)) {
+ char *proxy_auth_str =
+ g_strconcat(proxy_user->value, ":", proxy_pass->value, NULL);
+ curl_easy_setopt(c->easy, CURLOPT_PROXYUSERPWD, proxy_auth_str);
+ g_free(proxy_auth_str);
+ }
+
code = curl_easy_setopt(c->easy, CURLOPT_URL, c->url);
if (code != CURLE_OK)
return false;