Commit 774c9875 authored by Pierre Ynard's avatar Pierre Ynard

httpd: URL-parse --http-host and --rtsp-host

This deals gracefully with and warns about the legacy
--http-host <host>:<port> and --rtsp-host <host>:<port>/<path> syntaxes
(cherry picked from commit 37eb636261b66b1a8d5cff1b247096a946ff4f65)
Signed-off-by: default avatarPierre Ynard <linkfanel@yahoo.fr>
parent 73eeb8ab
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <vlc_strings.h> #include <vlc_strings.h>
#include <vlc_rand.h> #include <vlc_rand.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_url.h>
#include "../libvlc.h" #include "../libvlc.h"
#include <string.h> #include <string.h>
...@@ -1032,8 +1033,19 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this, ...@@ -1032,8 +1033,19 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
vlc_tls_creds_t *p_tls ) vlc_tls_creds_t *p_tls )
{ {
httpd_host_t *host; httpd_host_t *host;
char *hostname = var_InheritString( p_this, hostvar );
unsigned port = var_InheritInteger( p_this, portvar ); unsigned port = var_InheritInteger( p_this, portvar );
vlc_url_t url;
vlc_UrlParse( &url, hostname, 0 );
free( hostname );
if( url.i_port != 0 )
{
msg_Err( p_this, "Ignoring port %d (using %d)", url.i_port, port );
msg_Info( p_this, "Specify port %d separately with the "
"%s option instead.", url.i_port, portvar );
}
/* to be sure to avoid multiple creation */ /* to be sure to avoid multiple creation */
vlc_mutex_lock( &httpd.mutex ); vlc_mutex_lock( &httpd.mutex );
...@@ -1056,6 +1068,7 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this, ...@@ -1056,6 +1068,7 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
vlc_mutex_unlock( &host->lock ); vlc_mutex_unlock( &host->lock );
vlc_mutex_unlock( &httpd.mutex ); vlc_mutex_unlock( &httpd.mutex );
vlc_UrlClean( &url );
if( p_tls != NULL ) if( p_tls != NULL )
vlc_tls_ServerDelete( p_tls ); vlc_tls_ServerDelete( p_tls );
return host; return host;
...@@ -1073,9 +1086,7 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this, ...@@ -1073,9 +1086,7 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
vlc_cond_init( &host->wait ); vlc_cond_init( &host->wait );
host->i_ref = 1; host->i_ref = 1;
char *hostname = var_InheritString( p_this, hostvar ); host->fds = net_ListenTCP( p_this, url.psz_host, port );
host->fds = net_ListenTCP( p_this, hostname, port );
free( hostname );
if( host->fds == NULL ) if( host->fds == NULL )
{ {
msg_Err( p_this, "cannot create socket(s) for HTTP host" ); msg_Err( p_this, "cannot create socket(s) for HTTP host" );
...@@ -1108,6 +1119,8 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this, ...@@ -1108,6 +1119,8 @@ static httpd_host_t *httpd_HostCreate( vlc_object_t *p_this,
TAB_APPEND( httpd.i_host, httpd.host, host ); TAB_APPEND( httpd.i_host, httpd.host, host );
vlc_mutex_unlock( &httpd.mutex ); vlc_mutex_unlock( &httpd.mutex );
vlc_UrlClean( &url );
return host; return host;
error: error:
...@@ -1121,6 +1134,8 @@ error: ...@@ -1121,6 +1134,8 @@ error:
vlc_object_release( host ); vlc_object_release( host );
} }
vlc_UrlClean( &url );
if( p_tls != NULL ) if( p_tls != NULL )
vlc_tls_ServerDelete( p_tls ); vlc_tls_ServerDelete( p_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