@@ -77,6 +77,7 @@ version <next>:
- OpenEXR image encoder
- Simbiosis IMX decoder
- Simbiosis IMX demuxer
+- gophers protocol
version 4.3:
@@ -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"
@@ -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
@@ -75,19 +75,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,
@@ -120,3 +124,14 @@ const URLProtocol ff_gopher_protocol = {
.flags = URL_PROTOCOL_FLAG_NETWORK,
.default_whitelist = "gopher,tcp"
};
+
+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"
+};
@@ -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;
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). Signed-off-by: parazyd <parazyd@dyne.org> --- Changelog | 1 + configure | 1 + libavformat/Makefile | 1 + libavformat/gopher.c | 23 +++++++++++++++++++---- libavformat/protocols.c | 1 + 5 files changed, 23 insertions(+), 4 deletions(-)