summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-11-09 21:10:12 +0100
committerLars-Dominik Braun <lars@6xq.net>2011-11-09 21:10:12 +0100
commit937fdfb4ed8e55795902e8567e8624da06ea4f8a (patch)
treed45c74796571f17f05a4bea156597d5424e28239
parentb14463aa71755d086020b2f84f1f3d5009b5ade9 (diff)
downloadpianobar-windows-937fdfb4ed8e55795902e8567e8624da06ea4f8a.tar.gz
pianobar-windows-937fdfb4ed8e55795902e8567e8624da06ea4f8a.tar.bz2
pianobar-windows-937fdfb4ed8e55795902e8567e8624da06ea4f8a.zip
waitress: Poor man's proxy support for TLS
-rw-r--r--src/libwaitress/waitress.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libwaitress/waitress.c b/src/libwaitress/waitress.c
index 1a6d4cd..d4081ef 100644
--- a/src/libwaitress/waitress.c
+++ b/src/libwaitress/waitress.c
@@ -815,6 +815,21 @@ static WaitressReturn_t WaitressConnect (WaitressHandle_t *waith) {
#ifdef ENABLE_TLS
if (waith->url.tls) {
+ /* set up proxy tunnel */
+ if (WaitressProxyEnabled (waith)) {
+ char buf[256];
+ size_t size;
+ snprintf (buf, sizeof (buf), "CONNECT %s:%s HTTP/1.1\r\n\r\n",
+ waith->url.host, WaitressDefaultPort (&waith->url));
+ WaitressOrdinaryWrite (waith, buf, strlen (buf));
+
+ WaitressOrdinaryRead (waith, buf, sizeof (buf)-1, &size);
+ buf[size] = 0;
+ if (WaitressParseStatusline (buf) != 200) {
+ return WAITRESS_RET_CONNECT_REFUSED;
+ }
+ }
+
if (gnutls_handshake (waith->request.tlsSession) != GNUTLS_E_SUCCESS) {
return WAITRESS_RET_TLS_HANDSHAKE_ERR;
}