From 6514ed051d579972f21949be3900a48d8d62c647 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Fri, 2 Feb 2018 17:22:18 +0100 Subject: [PATCH] HTTP win32: use http-proxy options to setup the proxy Because win32/netconf is not ready --- modules/access/http.c | 15 --------------- src/libvlc-module.c | 22 ++++++++++++++++++++++ src/win32/netconf.c | 30 ++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/modules/access/http.c b/modules/access/http.c index 8d050bdec6..f5b4eacbd1 100644 --- a/modules/access/http.c +++ b/modules/access/http.c @@ -56,16 +56,6 @@ static int Open ( vlc_object_t * ); static void Close( vlc_object_t * ); -#define PROXY_TEXT N_("HTTP proxy") -#define PROXY_LONGTEXT N_( \ - "HTTP proxy to be used It must be of the form " \ - "http://[user@]myproxy.mydomain:myport/ ; " \ - "if empty, the http_proxy environment variable will be tried." ) - -#define PROXY_PASS_TEXT N_("HTTP proxy password") -#define PROXY_PASS_LONGTEXT N_( \ - "If your HTTP proxy requires a password, set it here." ) - #define RECONNECT_TEXT N_("Auto re-connect") #define RECONNECT_LONGTEXT N_( \ "Automatically try to reconnect to the stream in case of a sudden " \ @@ -78,11 +68,6 @@ vlc_module_begin () set_category( CAT_INPUT ) set_subcategory( SUBCAT_INPUT_ACCESS ) - add_string( "http-proxy", NULL, PROXY_TEXT, PROXY_LONGTEXT, - false ) - add_password( "http-proxy-pwd", NULL, - PROXY_PASS_TEXT, PROXY_PASS_LONGTEXT, false ) - add_obsolete_bool( "http-use-IE-proxy" ) add_bool( "http-reconnect", false, RECONNECT_TEXT, RECONNECT_LONGTEXT, true ) /* 'itpc' = iTunes Podcast */ diff --git a/src/libvlc-module.c b/src/libvlc-module.c index 9d29d24b4e..77ab8283ab 100644 --- a/src/libvlc-module.c +++ b/src/libvlc-module.c @@ -844,6 +844,16 @@ static const char *const ppsz_prefres[] = { #define KEY_LONGTEXT N_( \ "This private key file (PEM format) is used for server-side TLS.") +#define PROXY_TEXT N_("HTTP proxy") +#define PROXY_LONGTEXT N_( \ + "HTTP proxy to be used It must be of the form " \ + "http://[user@]myproxy.mydomain:myport/ ; " \ + "if empty, the http_proxy environment variable will be tried." ) + +#define PROXY_PASS_TEXT N_("HTTP proxy password") +#define PROXY_PASS_LONGTEXT N_( \ + "If your HTTP proxy requires a password, set it here." ) + #define SOCKS_SERVER_TEXT N_("SOCKS server") #define SOCKS_SERVER_LONGTEXT N_( \ "SOCKS proxy server to use. This must be of the form " \ @@ -1802,6 +1812,18 @@ vlc_module_begin () add_obsolete_string( "http-crl" ) /* since 3.0.0 */ add_obsolete_string( "sout-http-crl" ) /* since 2.0.0 */ +#ifdef _WIN32 + add_string( "http-proxy", NULL, PROXY_TEXT, PROXY_LONGTEXT, + false ) + add_password( "http-proxy-pwd", NULL, + PROXY_PASS_TEXT, PROXY_PASS_LONGTEXT, false ) +#else + add_obsolete_string( "http-proxy" ) + add_obsolete_string( "http-proxy-pwd" ) + +#endif + add_obsolete_bool( "http-use-IE-proxy" ) + set_section( N_( "Socks proxy") , NULL ) add_string( "socks", NULL, SOCKS_SERVER_TEXT, SOCKS_SERVER_LONGTEXT, true ) diff --git a/src/win32/netconf.c b/src/win32/netconf.c index accdddf2ce..3a6dcda1ea 100644 --- a/src/win32/netconf.c +++ b/src/win32/netconf.c @@ -27,10 +27,36 @@ #include #include +#include -char *vlc_getProxyUrl(const char *url) +char *vlc_getProxyUrl(const char *psz_url) { - char *proxy_url = NULL; + VLC_UNUSED(psz_url); + + char *proxy = config_GetPsz( (vlc_object_t *)(NULL), "http-proxy" ); + if (proxy == NULL) + return NULL; + + char *proxy_pwd = config_GetPsz( (vlc_object_t *)(NULL), "http-proxy-pwd" ); + if (proxy_pwd == NULL) + return proxy; + + vlc_url_t url; + if (vlc_UrlParse(&url, proxy) < 0) { + free (proxy); + free (proxy_pwd); + return NULL; + } + + if (url.psz_password == NULL ) + url.psz_password = vlc_uri_encode(proxy_pwd); + + char *proxy_url = vlc_uri_compose (&url); + vlc_UrlClean (&url); + + free (proxy_pwd); + free (proxy); + #if 0 /* Try to get the proxy server address from Windows internet settings. */ HKEY h_key; -- 2.11.4.GIT