diff options
author | blmpl <blm@poczta.fm> | 2016-10-15 10:10:52 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2016-10-15 10:13:00 +0200 |
commit | 79844540a83d7acaf8166b3081913f1968ebf78c (patch) | |
tree | 86ac1a7ba990661b0f4a063d165431f89d82e5f9 | |
parent | 7c2d9ebb7f61cf04d75e28ca5cd6932002c4357b (diff) | |
download | pianobar-79844540a83d7acaf8166b3081913f1968ebf78c.tar.gz pianobar-79844540a83d7acaf8166b3081913f1968ebf78c.tar.bz2 pianobar-79844540a83d7acaf8166b3081913f1968ebf78c.zip |
Support binding to a specific network interface
Closes #597.
-rw-r--r-- | contrib/config-example | 1 | ||||
-rw-r--r-- | contrib/pianobar.1 | 11 | ||||
-rw-r--r-- | src/settings.c | 3 | ||||
-rw-r--r-- | src/settings.h | 1 | ||||
-rw-r--r-- | src/ui.c | 9 |
5 files changed, 25 insertions, 0 deletions
diff --git a/contrib/config-example b/contrib/config-example index 899ee39..070314b 100644 --- a/contrib/config-example +++ b/contrib/config-example @@ -10,6 +10,7 @@ # Proxy (for those who are not living in the USA) #control_proxy = http://127.0.0.1:9090/ +#bind_to = if!tun0 # Keybindings #act_help = ? diff --git a/contrib/pianobar.1 b/contrib/pianobar.1 index 375ec47..4fc09c3 100644 --- a/contrib/pianobar.1 +++ b/contrib/pianobar.1 @@ -208,6 +208,17 @@ Non-american users need a proxy to use pandora.com. Only the xmlrpc interface will use this proxy. The music is streamed directly. .TP +.B bind_to = {if!tunX,host!x.x.x.x,..} +This sets the interface name to use as outgoing network interface. The name can +be an interface name, an IP address, or a host name. (from CURLOPT_INTERFACE) + +It can be used as a replacement for +.B control_proxy +in conjunction with OpenVPN's +option +.B route-nopull. + +.TP .B decrypt_password = R=U!LH$O2B# .TP diff --git a/src/settings.c b/src/settings.c index f1aa707..115a71c 100644 --- a/src/settings.c +++ b/src/settings.c @@ -111,6 +111,7 @@ void BarSettingsInit (BarSettings_t *settings) { void BarSettingsDestroy (BarSettings_t *settings) { free (settings->controlProxy); free (settings->proxy); + free (settings->bindTo); free (settings->username); free (settings->password); free (settings->passwordCmd); @@ -269,6 +270,8 @@ void BarSettingsRead (BarSettings_t *settings) { settings->controlProxy = strdup (val); } else if (streq ("proxy", key)) { settings->proxy = strdup (val); + } else if (streq ("bind_to", key)) { + settings->bindTo = strdup (val); } else if (streq ("user", key)) { settings->username = strdup (val); } else if (streq ("password", key)) { diff --git a/src/settings.h b/src/settings.h index d35a64c..0b40113 100644 --- a/src/settings.h +++ b/src/settings.h @@ -93,6 +93,7 @@ typedef struct { char *password, *passwordCmd; char *controlProxy; /* non-american listeners need this */ char *proxy; + char *bindTo; char *autostartStation; char *eventCmd; char *loveIcon; @@ -209,6 +209,15 @@ static CURLcode BarPianoHttpRequest (CURL * const http, setAndCheck (CURLOPT_CAINFO, settings->caBundle); } + if (settings->bindTo!= NULL) { + if (curl_easy_setopt (http, CURLOPT_INTERFACE, + settings->bindTo) != CURLE_OK) { + /* if binding fails, notice about that */ + BarUiMsg (settings, MSG_ERR, "bindTo (%s) is invalid!\n", + settings->bindTo); + } + } + /* set up proxy (control proxy for non-us citizen or global proxy for poor * firewalled fellows) */ if (settings->controlProxy != NULL) { |