From patchwork Sun Feb 28 22:47:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ivan J." X-Patchwork-Id: 26037 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 3627E449EFF for ; Mon, 1 Mar 2021 00:47:41 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08A6568A91B; Mon, 1 Mar 2021 00:47:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vm6.ganeti.dyne.org (vm6.ganeti.dyne.org [195.169.149.119]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7204368A779 for ; Mon, 1 Mar 2021 00:47:34 +0200 (EET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: parazyd@dyne.org) with ESMTPSA id DFCDAF60B6D From: parazyd To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Feb 2021 23:47:03 +0100 Message-Id: <20210228224703.1527-1-parazyd@dyne.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=disabled version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tupac3.dyne.org Subject: [FFmpeg-devel] [PATCH v4 1/2] avformat/gopher: Add default_whitelist to ff_gopher_protocol X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: parazyd Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: parazyd --- configure | 2 +- libavformat/gopher.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 98daa1a64a..380fca5245 100755 --- a/configure +++ b/configure @@ -3450,7 +3450,7 @@ ffrtmpcrypt_protocol_select="tcp_protocol" ffrtmphttp_protocol_conflict="librtmp_protocol" ffrtmphttp_protocol_select="http_protocol" ftp_protocol_select="tcp_protocol" -gopher_protocol_select="network" +gopher_protocol_select="tcp_protocol" http_protocol_select="tcp_protocol" http_protocol_suggest="zlib" httpproxy_protocol_select="tcp_protocol" diff --git a/libavformat/gopher.c b/libavformat/gopher.c index 8b6d14a1f7..7c88ab01a8 100644 --- a/libavformat/gopher.c +++ b/libavformat/gopher.c @@ -110,13 +110,13 @@ static int gopher_read(URLContext *h, uint8_t *buf, int size) return len; } - const URLProtocol ff_gopher_protocol = { - .name = "gopher", - .url_open = gopher_open, - .url_read = gopher_read, - .url_write = gopher_write, - .url_close = gopher_close, - .priv_data_size = sizeof(GopherContext), - .flags = URL_PROTOCOL_FLAG_NETWORK, + .name = "gopher", + .url_open = gopher_open, + .url_read = gopher_read, + .url_write = gopher_write, + .url_close = gopher_close, + .priv_data_size = sizeof(GopherContext), + .flags = URL_PROTOCOL_FLAG_NETWORK, + .default_whitelist = "gopher,tcp" }; From patchwork Sun Feb 28 22:47:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ivan J." X-Patchwork-Id: 26038 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 862F9449EFF for ; Mon, 1 Mar 2021 00:48:02 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6A9E568A8F3; Mon, 1 Mar 2021 00:48:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vm6.ganeti.dyne.org (vm6.ganeti.dyne.org [195.169.149.119]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7D52D68A779 for ; Mon, 1 Mar 2021 00:47:55 +0200 (EET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: parazyd@dyne.org) with ESMTPSA id 77449F60B6D From: parazyd To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Feb 2021 23:47:05 +0100 Message-Id: <20210228224703.1527-2-parazyd@dyne.org> In-Reply-To: <20210228224703.1527-1-parazyd@dyne.org> References: <20210228224703.1527-1-parazyd@dyne.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=disabled version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tupac3.dyne.org Subject: [FFmpeg-devel] [PATCH v4 2/2] avformat/gopher: Add support for Gopher over TLS. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: parazyd Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This commit adds a "gophers" handler to the gopher protocol. gophers is a community-adopted protocol that acts the same way like normal gopher with the added TLS encapsulation. The gophers protocol is supported by gopher servers like geomydae(8), and clients like curl(1), clic(1), and hurl(1). This commit also adds compilation guards to both gopher and gophers, since now there are two protocols in the file it makes sense to have this addition. Signed-off-by: parazyd --- Changelog | 1 + configure | 1 + doc/general_contents.texi | 1 + doc/protocols.texi | 6 ++++++ libavformat/Makefile | 1 + libavformat/gopher.c | 30 ++++++++++++++++++++++++++---- libavformat/protocols.c | 1 + libavformat/version.h | 2 +- 8 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index ba5aebf79d..5a7e007647 100644 --- a/Changelog +++ b/Changelog @@ -77,6 +77,7 @@ version : - OpenEXR image encoder - Simbiosis IMX decoder - Simbiosis IMX demuxer +- gophers protocol version 4.3: diff --git a/configure b/configure index 380fca5245..cbce2b0f69 100755 --- a/configure +++ b/configure @@ -3451,6 +3451,7 @@ ffrtmphttp_protocol_conflict="librtmp_protocol" ffrtmphttp_protocol_select="http_protocol" ftp_protocol_select="tcp_protocol" gopher_protocol_select="tcp_protocol" +gophers_protocol_select="tls_protocol" http_protocol_select="tcp_protocol" http_protocol_suggest="zlib" httpproxy_protocol_select="tcp_protocol" diff --git a/doc/general_contents.texi b/doc/general_contents.texi index 6acdf441d6..b6513a6178 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -1370,6 +1370,7 @@ performance on systems without hardware floating point support). @item file @tab X @item FTP @tab X @item Gopher @tab X +@item Gophers @tab X @item HLS @tab X @item HTTP @tab X @item HTTPS @tab X diff --git a/doc/protocols.texi b/doc/protocols.texi index c0b511b7a4..2b2fab8752 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -341,6 +341,12 @@ operation. ff* tools may produce incomplete content due to server limitations. Gopher protocol. +@section gophers + +Gophers protocol. + +The Gopher protocol with TLS encapsulation. + @section hls Read Apple HTTP Live Streaming compliant segmented stream as diff --git a/libavformat/Makefile b/libavformat/Makefile index fcb39ce133..09038e40c3 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -619,6 +619,7 @@ OBJS-$(CONFIG_FFRTMPHTTP_PROTOCOL) += rtmphttp.o OBJS-$(CONFIG_FILE_PROTOCOL) += file.o OBJS-$(CONFIG_FTP_PROTOCOL) += ftp.o urldecode.o OBJS-$(CONFIG_GOPHER_PROTOCOL) += gopher.o +OBJS-$(CONFIG_GOPHERS_PROTOCOL) += gopher.o OBJS-$(CONFIG_HLS_PROTOCOL) += hlsproto.o OBJS-$(CONFIG_HTTP_PROTOCOL) += http.o httpauth.o urldecode.o OBJS-$(CONFIG_HTTPPROXY_PROTOCOL) += http.o httpauth.o urldecode.o diff --git a/libavformat/gopher.c b/libavformat/gopher.c index 7c88ab01a8..9bbe171640 100644 --- a/libavformat/gopher.c +++ b/libavformat/gopher.c @@ -2,6 +2,7 @@ * Gopher protocol * * Copyright (c) 2009 Toshimitsu Kimura + * Copyright (c) 2021 parazyd * * based on libavformat/http.c, Copyright (c) 2000, 2001 Fabrice Bellard * @@ -22,6 +23,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include "libavutil/avstring.h" #include "avformat.h" #include "internal.h" @@ -75,19 +78,23 @@ static int gopher_close(URLContext *h) static int gopher_open(URLContext *h, const char *uri, int flags) { GopherContext *s = h->priv_data; - char hostname[1024], auth[1024], path[1024], buf[1024]; + char proto[10], hostname[1024], auth[1024], path[1024], buf[1024]; int port, err; + const char *lower_proto = "tcp"; h->is_streamed = 1; /* needed in any case to build the host string */ - av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, - path, sizeof(path), uri); + av_url_split(proto, sizeof(proto), auth, sizeof(auth), + hostname, sizeof(hostname), &port, path, sizeof(path), uri); if (port < 0) port = 70; - ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL); + if (!strcmp(proto, "gophers")) + lower_proto = "tls"; + + ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL); s->hd = NULL; err = ffurl_open_whitelist(&s->hd, buf, AVIO_FLAG_READ_WRITE, @@ -110,6 +117,7 @@ static int gopher_read(URLContext *h, uint8_t *buf, int size) return len; } +#if CONFIG_GOPHER_PROTOCOL const URLProtocol ff_gopher_protocol = { .name = "gopher", .url_open = gopher_open, @@ -120,3 +128,17 @@ const URLProtocol ff_gopher_protocol = { .flags = URL_PROTOCOL_FLAG_NETWORK, .default_whitelist = "gopher,tcp" }; +#endif /* CONFIG_GOPHER_PROTOCOL */ + +#if CONFIG_GOPHERS_PROTOCOL +const URLProtocol ff_gophers_protocol = { + .name = "gophers", + .url_open = gopher_open, + .url_read = gopher_read, + .url_write = gopher_write, + .url_close = gopher_close, + .priv_data_size = sizeof(GopherContext), + .flags = URL_PROTOCOL_FLAG_NETWORK, + .default_whitelist = "gopher,gophers,tcp,tls" +}; +#endif /* CONFIG_GOPHERS_PROTOCOL */ diff --git a/libavformat/protocols.c b/libavformat/protocols.c index 7df18fbb3b..9e77dc2506 100644 --- a/libavformat/protocols.c +++ b/libavformat/protocols.c @@ -34,6 +34,7 @@ extern const URLProtocol ff_ffrtmphttp_protocol; extern const URLProtocol ff_file_protocol; extern const URLProtocol ff_ftp_protocol; extern const URLProtocol ff_gopher_protocol; +extern const URLProtocol ff_gophers_protocol; extern const URLProtocol ff_hls_protocol; extern const URLProtocol ff_http_protocol; extern const URLProtocol ff_httpproxy_protocol; diff --git a/libavformat/version.h b/libavformat/version.h index c11d885b83..6ce2135ee1 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 68 +#define LIBAVFORMAT_VERSION_MINOR 69 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \