Skip to content
Browse files

Add force_tls setting

Use TLS for all actions when requested. Closes #234
  • Loading branch information...
1 parent ed6d013 commit 35763dea799c96361e288a10eab0fbd16c36e880 @PromyLOPh committed Apr 14, 2012
Showing with 13 additions and 3 deletions.
  1. +5 −0 contrib/pianobar.1
  2. +3 −0 src/settings.c
  3. +1 −0 src/settings.h
  4. +4 −3 src/ui.c
View
5 contrib/pianobar.1
@@ -195,6 +195,11 @@ usually the value above). See section
.B REMOTE CONTROL
.TP
+.B force_tls = {0,1}
+Use TLS for all actions (not just sending login credentials). Use if you are on
+an untrusted network or to get around GeoIP restrictions.
+
+.TP
.B format_list_song = %i) %a - %t%r
Available format characters:
View
3 src/settings.c
@@ -121,6 +121,7 @@ void BarSettingsRead (BarSettings_t *settings) {
#endif
#endif
settings->autoselect = true;
+ settings->forceTls = false;
settings->history = 5;
settings->volume = 0;
settings->sortOrder = BAR_SORT_NAME_AZ;
@@ -245,6 +246,8 @@ void BarSettingsRead (BarSettings_t *settings) {
settings->fifo = strdup (val);
} else if (streq ("autoselect", key)) {
settings->autoselect = atoi (val);
+ } else if (streq ("force_tls", key)) {
+ settings->forceTls = atoi (val);
} else if (streq ("tls_fingerprint", key)) {
/* expects 40 byte hex-encoded sha1 */
if (strlen (val) == 40) {
View
1 src/settings.h
@@ -81,6 +81,7 @@ typedef struct {
typedef struct {
bool autoselect;
+ bool forceTls;
unsigned int history;
int volume;
BarStationSorting_t sortOrder;
View
7 src/ui.c
@@ -134,14 +134,15 @@ void BarUiMsg (const BarSettings_t *settings, const BarUiMsg_t type,
/* fetch http resource (post request)
* @param waitress handle
* @param piano request (initialized by PianoRequest())
+ * @param ignore libpiano TLS hint and use it always
*/
static WaitressReturn_t BarPianoHttpRequest (WaitressHandle_t *waith,
- PianoRequest_t *req) {
+ PianoRequest_t *req, bool forceTls) {
waith->extraHeaders = "Content-Type: text/xml\r\n";
waith->postData = req->postData;
waith->method = WAITRESS_METHOD_POST;
waith->url.path = req->urlPath;
- waith->url.tls = req->secure;
+ waith->url.tls = req->secure || forceTls;
return WaitressFetchBuf (waith, &req->responseData);
}
@@ -172,7 +173,7 @@ int BarUiPianoCall (BarApp_t * const app, PianoRequestType_t type,
return 0;
}
- *wRet = BarPianoHttpRequest (&app->waith, &req);
+ *wRet = BarPianoHttpRequest (&app->waith, &req, app->settings.forceTls);
if (*wRet != WAITRESS_RET_OK) {
BarUiMsg (&app->settings, MSG_NONE, "Network error: %s\n", WaitressErrorToStr (*wRet));
if (req.responseData != NULL) {

0 comments on commit 35763de

Please sign in to comment.
Something went wrong with that request. Please try again.