Commit 3b35c87a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

https: HTTPS through HTTP proxy support (fixes #16165)

parent 1674b861
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <assert.h> #include <assert.h>
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_access.h> #include <vlc_access.h>
...@@ -160,10 +162,13 @@ static int Open(vlc_object_t *obj) ...@@ -160,10 +162,13 @@ static int Open(vlc_object_t *obj)
{ {
access_t *access = (access_t *)obj; access_t *access = (access_t *)obj;
char *proxy = vlc_getProxyUrl(access->psz_url); if (!strcasecmp(access->psz_access, "http"))
free(proxy); {
if (proxy != NULL) char *proxy = vlc_getProxyUrl(access->psz_url);
return VLC_EGENERIC; /* FIXME not implemented yet */ free(proxy);
if (proxy != NULL)
return VLC_EGENERIC; /* FIXME not implemented yet */
}
access_sys_t *sys = malloc(sizeof (*sys)); access_sys_t *sys = malloc(sizeof (*sys));
int ret = VLC_ENOMEM; int ret = VLC_ENOMEM;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <assert.h> #include <assert.h>
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_network.h>
#include <vlc_tls.h> #include <vlc_tls.h>
#include <vlc_interrupt.h> #include <vlc_interrupt.h>
#include "transport.h" #include "transport.h"
...@@ -42,12 +43,40 @@ struct vlc_https_connecting ...@@ -42,12 +43,40 @@ struct vlc_https_connecting
vlc_sem_t done; vlc_sem_t done;
}; };
static char *vlc_https_proxy_find(const char *hostname, unsigned port)
{
const char *fmt;
char *url, *proxy = NULL;
int canc = vlc_savecancel();
if (strchr(hostname, ':') != NULL)
fmt = port ? "https://[%s]:%u" : "https://[%s]";
else
fmt = port ? "https://%s:%u" : "https://%s";
if (likely(asprintf(&url, fmt, hostname, port) >= 0))
{
proxy = vlc_getProxyUrl(url);
free(url);
}
vlc_restorecancel(canc);
return proxy;
}
static void *vlc_https_connect_thread(void *data) static void *vlc_https_connect_thread(void *data)
{ {
struct vlc_https_connecting *c = data; struct vlc_https_connecting *c = data;
vlc_tls_t *tls; vlc_tls_t *tls;
tls = vlc_https_connect(c->creds, c->host, c->port, &c->http2); char *proxy = vlc_https_proxy_find(c->host, c->port);
if (proxy != NULL)
{
tls = vlc_https_connect_proxy(c->creds, c->host, c->port, &c->http2,
proxy);
free(proxy);
}
else
tls = vlc_https_connect(c->creds, c->host, c->port, &c->http2);
vlc_sem_post(&c->done); vlc_sem_post(&c->done);
return tls; return tls;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment