From 06192d9c879cf70171139597b8f722a41fb88a37 Mon Sep 17 00:00:00 2001
From: blmpl <blm@poczta.fm>
Date: Sat, 15 Oct 2016 10:10:52 +0200
Subject: Support binding to a specific network interface

Closes #597.

# Conflicts:
#	src/ui.c
---
 contrib/config-example |  1 +
 contrib/pianobar.1     | 11 +++++++++++
 src/settings.c         |  3 +++
 src/settings.h         |  1 +
 4 files changed, 16 insertions(+)

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 ee09c41..910af9a 100644
--- a/contrib/pianobar.1
+++ b/contrib/pianobar.1
@@ -209,6 +209,17 @@ required to validate Pandora’s SSL certificate.
 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#
 
diff --git a/src/settings.c b/src/settings.c
index 6ba2e91..36245de 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -119,6 +119,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);
@@ -236,6 +237,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 78d0e45..e6067f3 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;
-- 
cgit v1.2.3