summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c22
-rw-r--r--src/pianobar.15
-rw-r--r--src/settings.c11
-rw-r--r--src/settings.h1
4 files changed, 37 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 8467065..7a260fc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -123,8 +123,15 @@ int main (int argc, char **argv) {
settings.password = strdup (passBuf);
}
- /* setup control connection */
- if (settings.controlProxy != NULL) {
+ /* set up proxy (control proxy for non-us citizen or global proxy for poor
+ * firewalled fellows) */
+ if (settings.proxy != NULL && strlen (settings.proxy) > 0) {
+ char tmpPath[2];
+ WaitressSplitUrl (settings.proxy, waith.proxyHost,
+ sizeof (waith.proxyHost), waith.proxyPort,
+ sizeof (waith.proxyPort), tmpPath, sizeof (tmpPath));
+ } else if (settings.controlProxy != NULL) {
+ /* global proxy overrides control proxy */
char tmpPath[2];
WaitressSplitUrl (settings.controlProxy, waith.proxyHost,
sizeof (waith.proxyHost), waith.proxyPort,
@@ -267,6 +274,17 @@ int main (int argc, char **argv) {
WaitressInit (&player.waith);
WaitressSetUrl (&player.waith, playlist->audioUrl);
+ /* set up global proxy, player is NULLed on songfinish */
+ if (settings.proxy != NULL) {
+ char tmpPath[2];
+ WaitressSplitUrl (settings.proxy,
+ player.waith.proxyHost,
+ sizeof (player.waith.proxyHost),
+ player.waith.proxyPort,
+ sizeof (player.waith.proxyPort), tmpPath,
+ sizeof (tmpPath));
+ }
+
player.gain = playlist->fileGain;
player.audioFormat = playlist->audioFormat;
diff --git a/src/pianobar.1 b/src/pianobar.1
index e89b0bc..94604b5 100644
--- a/src/pianobar.1
+++ b/src/pianobar.1
@@ -158,6 +158,11 @@ Keep a history of the last n songs (5, by default). You can rate these songs.
Your pandora.com password. Plain-text.
.TP
+.B proxy = http://host:port/
+Use a http proxy. Note that this setting overrides the http_proxy environment
+variable.
+
+.TP
.B user = your@user.name
Your pandora.com username.
diff --git a/src/settings.c b/src/settings.c
index 4ac2fea..1dee0ea 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -72,6 +72,7 @@ void BarSettingsInit (BarSettings_t *settings) {
*/
void BarSettingsDestroy (BarSettings_t *settings) {
free (settings->controlProxy);
+ free (settings->proxy);
free (settings->username);
free (settings->password);
free (settings->autostartStation);
@@ -130,6 +131,8 @@ void BarSettingsRead (BarSettings_t *settings) {
}
if (strcmp ("control_proxy", key) == 0) {
settings->controlProxy = strdup (val);
+ } else if (strcmp ("proxy", key) == 0) {
+ settings->proxy = strdup (val);
} else if (strcmp ("user", key) == 0) {
settings->username = strdup (val);
} else if (strcmp ("password", key) == 0) {
@@ -159,5 +162,13 @@ void BarSettingsRead (BarSettings_t *settings) {
}
}
+ /* check environment variable if proxy is not set explicitly */
+ if (settings->proxy == NULL) {
+ char *tmpProxy = getenv ("http_proxy");
+ if (tmpProxy != NULL && strlen (tmpProxy) > 0) {
+ settings->proxy = strdup (tmpProxy);
+ }
+ }
+
fclose (configfd);
}
diff --git a/src/settings.h b/src/settings.h
index 85ab71a..42443d7 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -68,6 +68,7 @@ typedef struct {
char *username;
char *password;
char *controlProxy; /* non-american listeners need this */
+ char *proxy;
char keys[BAR_KS_COUNT];
PianoAudioFormat_t audioFormat;
char *autostartStation;