From 99d4c95ad390a7f8e0195decc8753cef80e15470 Mon Sep 17 00:00:00 2001 From: Ted Hess Date: Tue, 24 Mar 2015 09:10:35 -0400 Subject: [PATCH] pianod: Sync patches with upstream. Fix SNI support Signed-off-by: Ted Hess --- sound/pianod/Makefile | 4 +- .../005-Fix_IPV6_socket_handling.patch | 74 +++++++++++++++---- ...Use_package_config_h_for_all_modules.patch | 2 +- .../030-Waitress_add_polarssl_variant.patch | 23 ++---- 4 files changed, 69 insertions(+), 34 deletions(-) diff --git a/sound/pianod/Makefile b/sound/pianod/Makefile index 758805c708..bb2d509282 100644 --- a/sound/pianod/Makefile +++ b/sound/pianod/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=pianod PKG_VERSION:=173 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://deviousfish.com/Downloads/pianod/ @@ -63,7 +63,7 @@ CONFIGURE_ARGS+= --with-polarssl PIANOD_CLIENT:=pianod-client-compiled-51.tar.gz define Download/pianod-client - URL:=$(PKG_SOURCE_URL)/Devel + URL:=$(PKG_SOURCE_URL) FILE:=$(PIANOD_CLIENT) MD5SUM:=abbdee5627bcee6a00c8304da8b4e2e7 endef diff --git a/sound/pianod/patches/005-Fix_IPV6_socket_handling.patch b/sound/pianod/patches/005-Fix_IPV6_socket_handling.patch index 68f7c365da..883495a1a4 100644 --- a/sound/pianod/patches/005-Fix_IPV6_socket_handling.patch +++ b/sound/pianod/patches/005-Fix_IPV6_socket_handling.patch @@ -1,21 +1,67 @@ --- a/src/libwaitress/waitress.c +++ b/src/libwaitress/waitress.c -@@ -813,7 +813,14 @@ static WaitressReturn_t WaitressConnect - sizeof (sockopt)); +@@ -805,34 +805,37 @@ static WaitressReturn_t WaitressConnect + int pollres; - /* non-blocking connect will return immediately */ -- connect (sock, gacurr->ai_addr, gacurr->ai_addrlen); -+ if (connect (sock, gacurr->ai_addr, gacurr->ai_addrlen) == -1) { -+ // Error if not in-progress or immediate success -+ if (errno != EINPROGRESS) { -+ // Close socket and try alternatives -+ close (sock); -+ continue; -+ } -+ } + /* we need shorter timeouts for connect() */ +- fcntl (sock, F_SETFL, O_NONBLOCK); ++ pollres = fcntl (sock, F_SETFL, O_NONBLOCK); ++ assert (pollres != -1); - pollres = WaitressPollLoop (sock, POLLOUT, waith->timeout); - if (pollres == 0) { +- /* increase socket receive buffer */ +- const int sockopt = 256*1024; +- setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &sockopt, +- sizeof (sockopt)); +- +- /* non-blocking connect will return immediately */ +- connect (sock, gacurr->ai_addr, gacurr->ai_addrlen); +- +- pollres = WaitressPollLoop (sock, POLLOUT, waith->timeout); +- if (pollres == 0) { +- ret = WAITRESS_RET_TIMEOUT; +- } else if (pollres == -1) { +- ret = WAITRESS_RET_ERR; +- } else { +- /* check connect () return value */ +- socklen_t pollresSize = sizeof (pollres); +- getsockopt (sock, SOL_SOCKET, SO_ERROR, &pollres, +- &pollresSize); +- if (pollres != 0) { +- ret = WAITRESS_RET_CONNECT_REFUSED; ++ if (connect (sock, gacurr->ai_addr, gacurr->ai_addrlen) != -1) { ++ /* working */ ++ waith->request.sockfd = sock; ++ break; ++ } else if (errno == EINPROGRESS) { ++ /* wait for connect to succeed */ ++ pollres = WaitressPollLoop (sock, POLLOUT, waith->timeout); ++ if (pollres == 0) { ++ ret = WAITRESS_RET_TIMEOUT; ++ } else if (pollres == -1) { ++ ret = WAITRESS_RET_ERR; + } else { +- /* this one is working */ +- waith->request.sockfd = sock; +- break; ++ /* check connect () return value */ ++ socklen_t pollresSize = sizeof (pollres); ++ getsockopt (sock, SOL_SOCKET, SO_ERROR, &pollres, ++ &pollresSize); ++ if (pollres != 0) { ++ ret = WAITRESS_RET_CONNECT_REFUSED; ++ } else { ++ /* this one is working */ ++ waith->request.sockfd = sock; ++ break; ++ } + } ++ } else { ++ ret = WAITRESS_RET_ERR; + } ++ + close (sock); + } + } --- a/src/libfootball/fb_service.c +++ b/src/libfootball/fb_service.c @@ -111,6 +111,8 @@ static bool fb_setup_socket (FB_SERVICE diff --git a/sound/pianod/patches/020-Use_package_config_h_for_all_modules.patch b/sound/pianod/patches/020-Use_package_config_h_for_all_modules.patch index 25569ccc22..228710b056 100644 --- a/sound/pianod/patches/020-Use_package_config_h_for_all_modules.patch +++ b/sound/pianod/patches/020-Use_package_config_h_for_all_modules.patch @@ -19,7 +19,7 @@ --- a/src/libwaitress/waitress.c +++ b/src/libwaitress/waitress.c -@@ -922,14 +922,14 @@ static WaitressReturn_t WaitressSendRequ +@@ -918,14 +918,14 @@ static WaitressReturn_t WaitressSendRequ if (WaitressProxyEnabled (waith) && !waith->url.tls) { snprintf (buf, WAITRESS_BUFFER_SIZE, "%s http://%s:%s/%s HTTP/" WAITRESS_HTTP_VERSION "\r\n" diff --git a/sound/pianod/patches/030-Waitress_add_polarssl_variant.patch b/sound/pianod/patches/030-Waitress_add_polarssl_variant.patch index de40b35c96..b2a657645b 100644 --- a/sound/pianod/patches/030-Waitress_add_polarssl_variant.patch +++ b/sound/pianod/patches/030-Waitress_add_polarssl_variant.patch @@ -247,23 +247,12 @@ return WAITRESS_RET_OK; } -@@ -807,11 +878,6 @@ static WaitressReturn_t WaitressConnect - /* we need shorter timeouts for connect() */ - fcntl (sock, F_SETFL, O_NONBLOCK); - -- /* increase socket receive buffer */ -- const int sockopt = 256*1024; -- setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &sockopt, -- sizeof (sockopt)); -- - /* non-blocking connect will return immediately */ - if (connect (sock, gacurr->ai_addr, gacurr->ai_addrlen) == -1) { - // Error if not in-progress or immediate success -@@ -880,6 +946,11 @@ static WaitressReturn_t WaitressConnect +@@ -876,6 +947,12 @@ static WaitressReturn_t WaitressConnect } } +#if defined(USE_POLARSSL) ++ ssl_set_hostname (&waith->request.sslCtx->ssl, waith->url.host); + if (ssl_handshake (&waith->request.sslCtx->ssl) != 0) { + return WAITRESS_RET_TLS_HANDSHAKE_ERR; + } @@ -271,7 +260,7 @@ /* Ignore return code as connection will likely still succeed */ gnutls_server_name_set (waith->request.tlsSession, GNUTLS_NAME_DNS, waith->url.host, strlen (waith->url.host)); -@@ -887,14 +958,15 @@ static WaitressReturn_t WaitressConnect +@@ -883,14 +960,15 @@ static WaitressReturn_t WaitressConnect if (gnutls_handshake (waith->request.tlsSession) != GNUTLS_E_SUCCESS) { return WAITRESS_RET_TLS_HANDSHAKE_ERR; } @@ -289,7 +278,7 @@ } return WAITRESS_RET_OK; -@@ -1120,6 +1192,21 @@ WaitressReturn_t WaitressFetchCall (Wait +@@ -1116,6 +1194,21 @@ WaitressReturn_t WaitressFetchCall (Wait waith->request.contentLengthKnown = false; if (waith->url.tls) { @@ -311,7 +300,7 @@ gnutls_init (&waith->request.tlsSession, GNUTLS_CLIENT); gnutls_set_default_priority (waith->request.tlsSession); -@@ -1137,6 +1224,7 @@ WaitressReturn_t WaitressFetchCall (Wait +@@ -1133,6 +1226,7 @@ WaitressReturn_t WaitressFetchCall (Wait WaitressPollRead); gnutls_transport_set_push_function (waith->request.tlsSession, WaitressPollWrite); @@ -319,7 +308,7 @@ } /* buffer is required for connect already */ -@@ -1148,15 +1236,22 @@ WaitressReturn_t WaitressFetchCall (Wait +@@ -1144,15 +1238,22 @@ WaitressReturn_t WaitressFetchCall (Wait if ((wRet = WaitressSendRequest (waith)) == WAITRESS_RET_OK) { wRet = WaitressReceiveResponse (waith); } -- 2.30.2