Browse Source

avformat/http,tls: honor http_proxy command line variable for HTTPS

Add the "http_proxy" option and its handling to the "tls" protocol,
pass the option from the "https" protocol.

The "https" protocol already defines the "http_proxy" command line
option, like the "http" protocol does. The "http" protocol properly
honors that command line option in addition to the environment
variable. The "https" protocol doesn't, because the proxy is
evaluated in the underlying "tls" protocol, which doesn't have this
option, and thus only handles the environment variable, which it
has access to.

Fixes #7223.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Signed-off-by: Marton Balint <cus@passwd.hu>
tags/n4.4
Moritz Barsnick Marton Balint 4 years ago
parent
commit
94b63e8ae8
4 changed files with 14 additions and 2 deletions
  1. +4
    -0
      doc/protocols.texi
  2. +6
    -0
      libavformat/http.c
  3. +1
    -1
      libavformat/tls.c
  4. +3
    -1
      libavformat/tls.h

+ 4
- 0
doc/protocols.texi View File

@@ -1772,6 +1772,10 @@ A file containing the private key for the certificate.
If enabled, listen for connections on the provided port, and assume If enabled, listen for connections on the provided port, and assume
the server role in the handshake instead of the client role. the server role in the handshake instead of the client role.


@item http_proxy
The HTTP proxy to tunnel through, e.g. @code{http://example.com:1234}.
The proxy must support the CONNECT method.

@end table @end table


Example command lines: Example command lines:


+ 6
- 0
libavformat/http.c View File

@@ -214,6 +214,12 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
use_proxy = 0; use_proxy = 0;
if (port < 0) if (port < 0)
port = 443; port = 443;
/* pass http_proxy to underlying protocol */
if (s->http_proxy) {
err = av_dict_set(options, "http_proxy", s->http_proxy, 0);
if (err < 0)
return err;
}
} }
if (port < 0) if (port < 0)
port = 80; port = 80;


+ 1
- 1
libavformat/tls.c View File

@@ -89,7 +89,7 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV
if (!c->host && !(c->host = av_strdup(c->underlying_host))) if (!c->host && !(c->host = av_strdup(c->underlying_host)))
return AVERROR(ENOMEM); return AVERROR(ENOMEM);


proxy_path = getenv("http_proxy");
proxy_path = c->http_proxy ? c->http_proxy : getenv("http_proxy");
use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), c->underlying_host) && use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), c->underlying_host) &&
proxy_path && av_strstart(proxy_path, "http://", NULL); proxy_path && av_strstart(proxy_path, "http://", NULL);




+ 3
- 1
libavformat/tls.h View File

@@ -34,6 +34,7 @@ typedef struct TLSShared {
int listen; int listen;


char *host; char *host;
char *http_proxy;


char underlying_host[200]; char underlying_host[200];
int numerichost; int numerichost;
@@ -49,7 +50,8 @@ typedef struct TLSShared {
{"cert_file", "Certificate file", offsetof(pstruct, options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \ {"cert_file", "Certificate file", offsetof(pstruct, options_field . cert_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"key_file", "Private key file", offsetof(pstruct, options_field . key_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \ {"key_file", "Private key file", offsetof(pstruct, options_field . key_file), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"listen", "Listen for incoming connections", offsetof(pstruct, options_field . listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \ {"listen", "Listen for incoming connections", offsetof(pstruct, options_field . listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = TLS_OPTFL }, \
{"verifyhost", "Verify against a specific hostname", offsetof(pstruct, options_field . host), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }
{"verifyhost", "Verify against a specific hostname", offsetof(pstruct, options_field . host), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }, \
{"http_proxy", "Set proxy to tunnel through", offsetof(pstruct, options_field . http_proxy), AV_OPT_TYPE_STRING, .flags = TLS_OPTFL }


int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options); int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options);




Loading…
Cancel
Save