@ -139,7 +139,8 @@ static AST_RWLIST_HEAD_STATIC(uris, ast_http_uri); /*!< list of supported handle
/* all valid URIs must be prepended by the string in prefix. */
/* all valid URIs must be prepended by the string in prefix. */
static char prefix [ MAX_PREFIX ] ;
static char prefix [ MAX_PREFIX ] ;
static int enablestatic ;
static int static_uri_enabled ;
static int status_uri_enabled ;
/*! \brief Limit the kinds of files we're willing to serve up */
/*! \brief Limit the kinds of files we're willing to serve up */
static struct {
static struct {
@ -260,9 +261,13 @@ static int static_callback(struct ast_tcptls_session_instance *ser,
return 0 ;
return 0 ;
}
}
/* Yuck. I'm not really sold on this, but if you don't deliver static content it makes your configuration
/* Yuck. I'm not really sold on this, but if you don't deliver static content it
substantially more challenging , but this seems like a rather irritating feature creep on Asterisk . */
* makes your configuration substantially more challenging , but this seems like a
if ( ! enablestatic | | ast_strlen_zero ( uri ) ) {
* rather irritating feature creep on Asterisk .
*
* XXX : It is not clear to me what this comment means or if it is any longer
* relevant . */
if ( ast_strlen_zero ( uri ) ) {
goto out403 ;
goto out403 ;
}
}
@ -413,7 +418,7 @@ static int httpstatus_callback(struct ast_tcptls_session_instance *ser,
return 0 ;
return 0 ;
}
}
static struct ast_http_uri status uri = {
static struct ast_http_uri status _ uri = {
. callback = httpstatus_callback ,
. callback = httpstatus_callback ,
. description = " Asterisk HTTP General Status " ,
. description = " Asterisk HTTP General Status " ,
. uri = " httpstatus " ,
. uri = " httpstatus " ,
@ -422,7 +427,7 @@ static struct ast_http_uri statusuri = {
. key = __FILE__ ,
. key = __FILE__ ,
} ;
} ;
static struct ast_http_uri static uri = {
static struct ast_http_uri static _ uri = {
. callback = static_callback ,
. callback = static_callback ,
. description = " Asterisk HTTP Static Delivery " ,
. description = " Asterisk HTTP Static Delivery " ,
. uri = " static " ,
. uri = " static " ,
@ -2071,8 +2076,9 @@ static int __ast_http_load(int reload)
{
{
struct ast_config * cfg ;
struct ast_config * cfg ;
struct ast_variable * v ;
struct ast_variable * v ;
int enabled = 0 ;
int enabled = 0 ;
int newenablestatic = 0 ;
int new_static_uri_enabled = 0 ;
int new_status_uri_enabled = 1 ; /* Default to enabled for BC */
char newprefix [ MAX_PREFIX ] = " " ;
char newprefix [ MAX_PREFIX ] = " " ;
char server_name [ MAX_SERVER_NAME_LENGTH ] ;
char server_name [ MAX_SERVER_NAME_LENGTH ] ;
struct http_uri_redirect * redirect ;
struct http_uri_redirect * redirect ;
@ -2150,8 +2156,10 @@ static int __ast_http_load(int reload)
}
}
} else if ( ! strcasecmp ( v - > name , " enabled " ) ) {
} else if ( ! strcasecmp ( v - > name , " enabled " ) ) {
enabled = ast_true ( v - > value ) ;
enabled = ast_true ( v - > value ) ;
} else if ( ! strcasecmp ( v - > name , " enablestatic " ) ) {
} else if ( ! strcasecmp ( v - > name , " enablestatic " ) | | ! strcasecmp ( v - > name , " enable_static " ) ) {
newenablestatic = ast_true ( v - > value ) ;
new_static_uri_enabled = ast_true ( v - > value ) ;
} else if ( ! strcasecmp ( v - > name , " enable_status " ) ) {
new_status_uri_enabled = ast_true ( v - > value ) ;
} else if ( ! strcasecmp ( v - > name , " bindport " ) ) {
} else if ( ! strcasecmp ( v - > name , " bindport " ) ) {
if ( ast_parse_arg ( v - > value , PARSE_UINT32 | PARSE_IN_RANGE | PARSE_DEFAULT ,
if ( ast_parse_arg ( v - > value , PARSE_UINT32 | PARSE_IN_RANGE | PARSE_DEFAULT ,
& bindport , DEFAULT_PORT , 0 , 65535 ) ) {
& bindport , DEFAULT_PORT , 0 , 65535 ) ) {
@ -2202,7 +2210,6 @@ static int __ast_http_load(int reload)
}
}
ast_copy_string ( http_server_name , server_name , sizeof ( http_server_name ) ) ;
ast_copy_string ( http_server_name , server_name , sizeof ( http_server_name ) ) ;
enablestatic = newenablestatic ;
if ( num_addrs & & enabled ) {
if ( num_addrs & & enabled ) {
int i ;
int i ;
@ -2248,6 +2255,22 @@ static int __ast_http_load(int reload)
}
}
}
}
if ( static_uri_enabled & & ! new_static_uri_enabled ) {
ast_http_uri_unlink ( & static_uri ) ;
} else if ( ! static_uri_enabled & & new_static_uri_enabled ) {
ast_http_uri_link ( & static_uri ) ;
}
static_uri_enabled = new_static_uri_enabled ;
if ( status_uri_enabled & & ! new_status_uri_enabled ) {
ast_http_uri_unlink ( & status_uri ) ;
} else if ( ! status_uri_enabled & & new_status_uri_enabled ) {
ast_http_uri_link ( & status_uri ) ;
}
status_uri_enabled = new_status_uri_enabled ;
return 0 ;
return 0 ;
}
}
@ -2329,8 +2352,13 @@ static int unload_module(void)
ast_free ( http_tls_cfg . pvtfile ) ;
ast_free ( http_tls_cfg . pvtfile ) ;
ast_free ( http_tls_cfg . cipher ) ;
ast_free ( http_tls_cfg . cipher ) ;
ast_http_uri_unlink ( & statusuri ) ;
if ( status_uri_enabled ) {
ast_http_uri_unlink ( & staticuri ) ;
ast_http_uri_unlink ( & status_uri ) ;
}
if ( static_uri_enabled ) {
ast_http_uri_unlink ( & static_uri ) ;
}
AST_RWLIST_WRLOCK ( & uri_redirects ) ;
AST_RWLIST_WRLOCK ( & uri_redirects ) ;
while ( ( redirect = AST_RWLIST_REMOVE_HEAD ( & uri_redirects , entry ) ) ) {
while ( ( redirect = AST_RWLIST_REMOVE_HEAD ( & uri_redirects , entry ) ) ) {
@ -2343,8 +2371,6 @@ static int unload_module(void)
static int load_module ( void )
static int load_module ( void )
{
{
ast_http_uri_link ( & statusuri ) ;
ast_http_uri_link ( & staticuri ) ;
ast_cli_register_multiple ( cli_http , ARRAY_LEN ( cli_http ) ) ;
ast_cli_register_multiple ( cli_http , ARRAY_LEN ( cli_http ) ) ;
return __ast_http_load ( 0 ) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS ;
return __ast_http_load ( 0 ) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS ;