[vlc-devel] [PATCH] HTTP win32: use http-proxy options to setup the proxy

Rémi Denis-Courmont remi at remlab.net
Sat Feb 3 11:30:51 CET 2018


Le vendredi 2 février 2018, 18:27:29 EET Jean-Baptiste Kempf a écrit :
> Because win32/netconf is not ready
> ---
>  modules/access/http.c | 15 ---------------
>  src/libvlc-module.c   | 22 ++++++++++++++++++++++
>  src/win32/netconf.c   | 24 +++++++++++++++++++++++-
>  3 files changed, 45 insertions(+), 16 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..0827376132 100644
> --- a/src/win32/netconf.c
> +++ b/src/win32/netconf.c
> @@ -27,10 +27,32 @@
> 
>  #include <vlc_common.h>
>  #include <vlc_network.h>
> +#include <vlc_url.h>
> 
>  char *vlc_getProxyUrl(const char *url)
>  {
> -    char *proxy_url = NULL;
> +    VLC_UNUSED(url);
> +    char *proxy = config_GetPsz( (vlc_object_t *)(NULL), "http-proxy" );
> +    char *proxy_pwd = config_GetPsz( (vlc_object_t *)(NULL),
> "http-proxy-pwd" );
> +
> +    if (proxy == NULL)
> +        return NULL;

Leak.

> +
> +    if (proxy_pwd == NULL)
> +        return proxy;
> +
> +    vlc_url_t p_url;
> +    if (vlc_UrlParse(&p_url, proxy) < 0)
> +        return NULL;

Leaks.

> +
> +    if (p_url.psz_password == NULL )
> +        p_url.psz_password = proxy_pwd;

Missing encode.

> +    else
> +        free (proxy_pwd);
> +
> +    char *proxy_url = vlc_uri_compose (&p_url);
> +    vlc_UrlClean (&p_url);
> +

More leaks.

>  #if 0
>      /* Try to get the proxy server address from Windows internet settings.
> */ HKEY h_key;


-- 
Rémi Denis-Courmont


More information about the vlc-devel mailing list