options: add --http-proxy

Often requested, trivial.
This commit is contained in:
wm4 2018-05-22 18:59:59 +02:00 committed by Jan Ekström
parent 935846fc40
commit ca97239cb6
2 changed files with 11 additions and 0 deletions

View File

@ -3993,6 +3993,13 @@ Network
Field2: value2
Connection: close
``--http-proxy=<proxy>``
URL of the HTTP/HTTPS proxy. If this is set, the ``http_proxy`` environment
is ignored. The ``no_proxy`` environment variable is still respected. This
option is silently ignored if it does not start with ``http://``. Proxies
are not used for https URLs. Setting this option does not try to make the
ytdl script use the proxy.
``--tls-ca-file=<filename>``
Certificate authority database file for use with TLS. (Silently fails with
older FFmpeg or Libav versions.)

View File

@ -46,6 +46,7 @@ struct stream_lavf_params {
char *tls_cert_file;
char *tls_key_file;
double timeout;
char *http_proxy;
};
const struct m_sub_options stream_lavf_conf = {
@ -61,6 +62,7 @@ const struct m_sub_options stream_lavf_conf = {
OPT_STRING("tls-cert-file", tls_cert_file, M_OPT_FILE),
OPT_STRING("tls-key-file", tls_key_file, M_OPT_FILE),
OPT_DOUBLE("network-timeout", timeout, M_OPT_MIN, .min = 0),
OPT_STRING("http-proxy", http_proxy, 0),
{0}
},
.size = sizeof(struct stream_lavf_params),
@ -224,6 +226,8 @@ void mp_setup_av_network_options(AVDictionary **dict, struct mpv_global *global,
snprintf(buf, sizeof(buf), "%lld", (long long)(opts->timeout * 1e6));
av_dict_set(dict, "timeout", buf, 0);
}
if (opts->http_proxy && opts->http_proxy[0])
av_dict_set(dict, "http_proxy", opts->http_proxy, 0);
mp_set_avdict(dict, opts->avopts);