[vlc-commits] https: HTTPS through HTTP proxy support (fixes #16165)
Rémi Denis-Courmont
git at videolan.org
Tue Jan 5 17:11:19 CET 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jan 5 17:50:08 2016 +0200| [3b35c87a3e001e51ff1436e5a46cfcd2fd6f00a2] | committer: Rémi Denis-Courmont
https: HTTPS through HTTP proxy support (fixes #16165)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3b35c87a3e001e51ff1436e5a46cfcd2fd6f00a2
---
modules/access/http/access.c | 13 +++++++++----
modules/access/http/connmgr.c | 31 ++++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/modules/access/http/access.c b/modules/access/http/access.c
index 0a9851d..28d4d09 100644
--- a/modules/access/http/access.c
+++ b/modules/access/http/access.c
@@ -24,6 +24,8 @@
#include <assert.h>
#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
#include <vlc_common.h>
#include <vlc_access.h>
@@ -160,10 +162,13 @@ static int Open(vlc_object_t *obj)
{
access_t *access = (access_t *)obj;
- char *proxy = vlc_getProxyUrl(access->psz_url);
- free(proxy);
- if (proxy != NULL)
- return VLC_EGENERIC; /* FIXME not implemented yet */
+ if (!strcasecmp(access->psz_access, "http"))
+ {
+ char *proxy = vlc_getProxyUrl(access->psz_url);
+ free(proxy);
+ if (proxy != NULL)
+ return VLC_EGENERIC; /* FIXME not implemented yet */
+ }
access_sys_t *sys = malloc(sizeof (*sys));
int ret = VLC_ENOMEM;
diff --git a/modules/access/http/connmgr.c b/modules/access/http/connmgr.c
index d21503a..59af37f 100644
--- a/modules/access/http/connmgr.c
+++ b/modules/access/http/connmgr.c
@@ -24,6 +24,7 @@
#include <assert.h>
#include <vlc_common.h>
+#include <vlc_network.h>
#include <vlc_tls.h>
#include <vlc_interrupt.h>
#include "transport.h"
@@ -42,12 +43,40 @@ struct vlc_https_connecting
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)
{
struct vlc_https_connecting *c = data;
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);
return tls;
}
More information about the vlc-commits
mailing list