From 5708e1a023c349af53383d8bfe52e2af65c597bc Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 16 Jun 2008 11:38:19 +0200 Subject: client: Proxy type config option added --- src/main.c | 7 +++++-- src/pianobar.1 | 15 ++++++++++++--- src/settings.c | 13 +++++++++++++ src/settings.h | 3 +++ 4 files changed, 33 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index e893b1d..a1041e7 100644 --- a/src/main.c +++ b/src/main.c @@ -292,8 +292,11 @@ int main (int argc, char **argv) { PianoInit (&ph); /* setup control connection */ - curl_easy_setopt (ph.curlHandle, CURLOPT_PROXY, bsettings.controlProxy); - curl_easy_setopt (ph.curlHandle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A); + if (bsettings.controlProxy != NULL && bsettings.controlProxyType != -1) { + curl_easy_setopt (ph.curlHandle, CURLOPT_PROXY, bsettings.controlProxy); + curl_easy_setopt (ph.curlHandle, CURLOPT_PROXYTYPE, + bsettings.controlProxyType); + } curl_easy_setopt (ph.curlHandle, CURLOPT_CONNECTTIMEOUT, 60); termSetBuffer (0); diff --git a/src/pianobar.1 b/src/pianobar.1 index 3d00a53..0b1d4f5 100644 --- a/src/pianobar.1 +++ b/src/pianobar.1 @@ -24,7 +24,8 @@ Per-user configuration file. See .SH CONFIGURATION The configuration file consists of simple .B key = value -lines. Each terminated with a newline (\\n) character. +lines. Each terminated with a newline (\\n) character. Keys and values are both +case sensitive. .TP .B control_proxy = host:port @@ -32,12 +33,20 @@ Non-american users need a proxy to use pandora.com. Currently this needs to be a SOCKS4a proxy like Tor. .TP -.B user = your@user.name -Your pandora.com username. +.B control_proxy_type = {http,socks4,socks4a,socks5} +If you want to use a proxy you need to specify the proxy type you're going to +use. Note that +.B socks5 +needs an IP address specified in +.B control_proxy .TP .B password = plaintext_password Your pandora.com password. Plain-text. +.TP +.B user = your@user.name +Your pandora.com username. + .SH AUTHOR Lars-Dominik Braun diff --git a/src/settings.c b/src/settings.c index 40a5064..588a34f 100644 --- a/src/settings.c +++ b/src/settings.c @@ -90,6 +90,19 @@ void readSettings (BarSettings_t *settings) { } if (strcmp ("control_proxy", key) == 0) { settings->controlProxy = strdup (val); + } else if (strcmp ("control_proxy_type", key) == 0) { + if (strcmp ("http", val) == 0) { + settings->controlProxyType = CURLPROXY_HTTP; + } else if (strcmp ("socks4", val) == 0) { + settings->controlProxyType = CURLPROXY_SOCKS4; + } else if (strcmp ("socks4a", val) == 0) { + settings->controlProxyType = CURLPROXY_SOCKS4A; + } else if (strcmp ("socks5", val) == 0) { + settings->controlProxyType = CURLPROXY_SOCKS5; + } else { + /* error: don't use proxy at all */ + settings->controlProxyType = -1; + } } else if (strcmp ("user", key) == 0) { settings->username = strdup (val); } else if (strcmp ("password", key) == 0) { diff --git a/src/settings.h b/src/settings.h index 26ca527..15b5396 100644 --- a/src/settings.h +++ b/src/settings.h @@ -23,10 +23,13 @@ THE SOFTWARE. #ifndef _SETTINGS_H #define _SETTINGS_H +#include + struct BarSettings { char *username; char *password; char *controlProxy; /* non-american listeners need this */ + curl_proxytype controlProxyType; }; typedef struct BarSettings BarSettings_t; -- cgit v1.2.3