diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2011-11-09 21:10:12 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2011-11-09 21:10:12 +0100 |
commit | 937fdfb4ed8e55795902e8567e8624da06ea4f8a (patch) | |
tree | d45c74796571f17f05a4bea156597d5424e28239 /src/libwaitress/waitress.c | |
parent | b14463aa71755d086020b2f84f1f3d5009b5ade9 (diff) | |
download | pianobar-windows-937fdfb4ed8e55795902e8567e8624da06ea4f8a.tar.gz pianobar-windows-937fdfb4ed8e55795902e8567e8624da06ea4f8a.tar.bz2 pianobar-windows-937fdfb4ed8e55795902e8567e8624da06ea4f8a.zip |
waitress: Poor man's proxy support for TLS
Diffstat (limited to 'src/libwaitress/waitress.c')
-rw-r--r-- | src/libwaitress/waitress.c | 15 |
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; } |