2006-09-19 19:58:09 +00:00
/*
2006-03-25 23:50:09 +00:00
* Asterisk - - An open source telephony toolkit .
*
* Copyright ( C ) 1999 - 2006 , Digium , Inc .
*
* Mark Spencer < markster @ digium . com >
*
* See http : //www.asterisk.org for more information about
* the Asterisk project . Please do not directly contact
* any of the maintainers of this project for assistance ;
* the project provides a web site , mailing lists and IRC
* channels for your use .
*
* This program is free software , distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree .
*/
2006-03-26 16:48:47 +00:00
/*!
2006-09-19 19:58:09 +00:00
* \ file
2006-04-03 18:38:28 +00:00
* \ brief http server for AMI access
2006-03-26 16:48:47 +00:00
*
2006-04-03 18:38:28 +00:00
* \ author Mark Spencer < markster @ digium . com >
2007-04-06 21:16:38 +00:00
*
* This program implements a tiny http server
* and was inspired by micro - httpd by Jef Poskanzer
2006-09-19 19:58:09 +00:00
*
2006-04-03 18:38:28 +00:00
* \ ref AstHTTP - AMI over the http protocol
2006-03-26 16:48:47 +00:00
*/
2006-06-07 18:54:56 +00:00
# include "asterisk.h"
ASTERISK_FILE_VERSION ( __FILE__ , " $Revision$ " )
2006-03-25 23:50:09 +00:00
# include <time.h>
# include <sys/time.h>
2006-04-01 08:49:54 +00:00
# include <sys/stat.h>
2006-03-25 23:50:09 +00:00
# include <sys/signal.h>
# include <fcntl.h>
2006-03-26 16:48:47 +00:00
2008-03-18 22:32:26 +00:00
# include "asterisk/paths.h" /* use ast_config_AST_DATA_DIR */
# include "asterisk/network.h"
2006-03-26 16:48:47 +00:00
# include "asterisk/cli.h"
2008-01-18 22:04:33 +00:00
# include "asterisk/tcptls.h"
2006-03-26 16:48:47 +00:00
# include "asterisk/http.h"
# include "asterisk/utils.h"
# include "asterisk/strings.h"
2006-04-01 08:49:54 +00:00
# include "asterisk/config.h"
2006-12-23 20:13:14 +00:00
# include "asterisk/stringfields.h"
2008-02-26 20:02:14 +00:00
# include "asterisk/ast_version.h"
2007-04-06 21:16:38 +00:00
# include "asterisk/manager.h"
2008-03-18 22:32:26 +00:00
# include "asterisk/_private.h"
2006-03-25 23:50:09 +00:00
# define MAX_PREFIX 80
2007-01-24 09:31:26 +00:00
/* See http.h for more information about the SSL implementation */
2006-10-22 19:09:25 +00:00
# if defined(HAVE_OPENSSL) && (defined(HAVE_FUNOPEN) || defined(HAVE_FOPENCOOKIE))
# define DO_SSL /* comment in/out if you want to support ssl */
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
# endif
2008-01-18 22:04:33 +00:00
static struct ast_tls_config http_tls_cfg ;
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
2006-11-25 17:37:04 +00:00
static void * httpd_helper_thread ( void * arg ) ;
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
/*!
* we have up to two accepting threads , one for http , one for https
*/
static struct server_args http_desc = {
. accept_fd = - 1 ,
. master = AST_PTHREADT_NULL ,
2006-12-07 16:42:29 +00:00
. tls_cfg = NULL ,
2006-11-28 00:02:42 +00:00
. poll_timeout = - 1 ,
2006-11-25 17:37:04 +00:00
. name = " http server " ,
2008-03-04 22:23:21 +00:00
. accept_fn = ast_tcptls_server_root ,
2006-11-25 17:37:04 +00:00
. worker_fn = httpd_helper_thread ,
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
} ;
static struct server_args https_desc = {
. accept_fd = - 1 ,
. master = AST_PTHREADT_NULL ,
2006-12-07 16:42:29 +00:00
. tls_cfg = & http_tls_cfg ,
2006-11-28 00:02:42 +00:00
. poll_timeout = - 1 ,
2006-11-25 17:37:04 +00:00
. name = " https server " ,
2008-03-04 22:23:21 +00:00
. accept_fn = ast_tcptls_server_root ,
2006-11-25 17:37:04 +00:00
. worker_fn = httpd_helper_thread ,
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
} ;
2006-03-25 23:50:09 +00:00
2006-12-28 20:02:41 +00:00
static AST_RWLIST_HEAD_STATIC ( uris , ast_http_uri ) ; /*!< list of supported handlers */
2006-10-16 08:38:35 +00:00
/* all valid URIs must be prepended by the string in prefix. */
2006-03-25 23:50:09 +00:00
static char prefix [ MAX_PREFIX ] ;
2006-12-27 22:14:33 +00:00
static int enablestatic ;
2006-04-01 08:49:54 +00:00
2006-04-03 18:38:28 +00:00
/*! \brief Limit the kinds of files we're willing to serve up */
2006-04-01 08:49:54 +00:00
static struct {
2007-04-11 14:49:07 +00:00
const char * ext ;
const char * mtype ;
2006-04-01 08:49:54 +00:00
} mimetypes [ ] = {
{ " png " , " image/png " } ,
{ " jpg " , " image/jpeg " } ,
{ " js " , " application/x-javascript " } ,
{ " wav " , " audio/x-wav " } ,
{ " mp3 " , " audio/mpeg " } ,
2007-03-21 18:10:01 +00:00
{ " svg " , " image/svg+xml " } ,
2007-04-11 14:49:07 +00:00
{ " svgz " , " image/svg+xml " } ,
2007-04-05 15:48:17 +00:00
{ " gif " , " image/gif " } ,
2006-04-01 08:49:54 +00:00
} ;
2006-12-23 20:13:14 +00:00
struct http_uri_redirect {
AST_LIST_ENTRY ( http_uri_redirect ) entry ;
2006-12-24 03:29:42 +00:00
char * dest ;
char target [ 0 ] ;
2006-12-23 20:13:14 +00:00
} ;
2006-12-28 20:05:00 +00:00
static AST_RWLIST_HEAD_STATIC ( uri_redirects , http_uri_redirect ) ;
2006-12-23 20:13:14 +00:00
2007-04-11 14:49:07 +00:00
static const char * ftype2mtype ( const char * ftype , char * wkspace , int wkspacelen )
2006-04-01 08:49:54 +00:00
{
int x ;
2008-03-19 04:09:55 +00:00
2006-04-01 08:49:54 +00:00
if ( ftype ) {
2008-03-19 04:09:55 +00:00
for ( x = 0 ; x < ARRAY_LEN ( mimetypes ) ; x + + ) {
2008-03-19 15:41:54 +00:00
if ( ! strcasecmp ( ftype , mimetypes [ x ] . ext ) ) {
2006-04-01 08:49:54 +00:00
return mimetypes [ x ] . mtype ;
2008-03-19 15:41:54 +00:00
}
2006-04-01 08:49:54 +00:00
}
}
2008-03-19 04:09:55 +00:00
snprintf ( wkspace , wkspacelen , " text/%s " , S_OR ( ftype , " plain " ) ) ;
2006-04-01 08:49:54 +00:00
return wkspace ;
}
2008-05-23 21:19:42 +00:00
static uint32_t manid_from_vars ( struct ast_variable * sid ) {
uint32_t mngid ;
while ( sid & & strcmp ( sid - > name , " mansession_id " ) )
sid = sid - > next ;
if ( ! sid | | sscanf ( sid - > value , " %x " , & mngid ) ! = 1 )
return 0 ;
return mngid ;
}
2008-07-02 20:28:17 +00:00
void ast_http_prefix ( char * buf , int len )
{
if ( buf ) {
ast_copy_string ( buf , prefix , len ) ;
}
}
2008-04-02 15:25:48 +00:00
static struct ast_str * static_callback ( struct ast_tcptls_session_instance * ser , const struct ast_http_uri * urih , const char * uri , enum ast_http_method method , struct ast_variable * vars , struct ast_variable * headers , int * status , char * * title , int * contentlength )
2006-04-01 08:49:54 +00:00
{
char * path ;
2007-04-11 14:49:07 +00:00
char * ftype ;
const char * mtype ;
2006-04-01 08:49:54 +00:00
char wkspace [ 80 ] ;
struct stat st ;
int len ;
int fd ;
2007-07-18 19:47:20 +00:00
struct timeval tv = ast_tvnow ( ) ;
2007-06-29 20:35:09 +00:00
char buf [ 256 ] ;
2007-07-18 19:47:20 +00:00
struct ast_tm tm ;
2006-04-01 08:49:54 +00:00
2006-09-19 19:58:09 +00:00
/* Yuck. I'm not really sold on this, but if you don't deliver static content it makes your configuration
2006-04-01 08:49:54 +00:00
substantially more challenging , but this seems like a rather irritating feature creep on Asterisk . */
2008-03-19 15:41:54 +00:00
if ( ! enablestatic | | ast_strlen_zero ( uri ) ) {
2006-04-01 08:49:54 +00:00
goto out403 ;
2008-03-19 15:41:54 +00:00
}
2006-04-01 08:49:54 +00:00
/* Disallow any funny filenames at all */
2008-03-19 15:41:54 +00:00
if ( ( uri [ 0 ] < 33 ) | | strchr ( " ./|~@#$%^&*() \t " , uri [ 0 ] ) ) {
2006-04-01 08:49:54 +00:00
goto out403 ;
2008-03-19 15:41:54 +00:00
}
if ( strstr ( uri , " /.. " ) ) {
2006-04-01 08:49:54 +00:00
goto out403 ;
2008-03-19 15:41:54 +00:00
}
2006-09-19 19:58:09 +00:00
2008-03-19 15:41:54 +00:00
if ( ( ftype = strrchr ( uri , ' . ' ) ) ) {
2006-04-01 08:49:54 +00:00
ftype + + ;
2008-03-19 15:41:54 +00:00
}
2007-04-11 14:49:07 +00:00
mtype = ftype2mtype ( ftype , wkspace , sizeof ( wkspace ) ) ;
2006-09-19 19:58:09 +00:00
2006-04-01 08:49:54 +00:00
/* Cap maximum length */
2008-03-27 22:10:25 +00:00
if ( ( len = strlen ( uri ) + strlen ( ast_config_AST_DATA_DIR ) + strlen ( " /static-http/ " ) + 5 ) > 1024 ) {
2006-04-01 08:49:54 +00:00
goto out403 ;
2008-03-19 15:41:54 +00:00
}
2006-09-19 19:58:09 +00:00
2006-04-01 08:49:54 +00:00
path = alloca ( len ) ;
2006-04-15 22:53:53 +00:00
sprintf ( path , " %s/static-http/%s " , ast_config_AST_DATA_DIR , uri ) ;
2008-03-19 15:41:54 +00:00
if ( stat ( path , & st ) ) {
2006-04-01 08:49:54 +00:00
goto out404 ;
2008-03-19 15:41:54 +00:00
}
if ( S_ISDIR ( st . st_mode ) ) {
2006-04-01 08:49:54 +00:00
goto out404 ;
2008-05-23 21:19:42 +00:00
}
2008-03-19 15:41:54 +00:00
if ( ( fd = open ( path , O_RDONLY ) ) < 0 ) {
2006-04-01 08:49:54 +00:00
goto out403 ;
2008-03-19 15:41:54 +00:00
}
2006-12-16 09:33:31 +00:00
2008-05-23 21:19:42 +00:00
if ( strstr ( path , " /private/ " ) & & ! astman_is_authed ( manid_from_vars ( vars ) ) ) {
goto out403 ;
}
2007-07-18 19:47:20 +00:00
ast_strftime ( buf , sizeof ( buf ) , " %a, %d %b %Y %H:%M:%S %Z " , ast_localtime ( & tv , & tm , " GMT " ) ) ;
2007-06-29 20:35:09 +00:00
fprintf ( ser - > f , " HTTP/1.1 200 OK \r \n "
" Server: Asterisk/%s \r \n "
" Date: %s \r \n "
" Connection: close \r \n "
" Cache-Control: no-cache, no-store \r \n "
" Content-Length: %d \r \n "
" Content-type: %s \r \n \r \n " ,
Now that the version.h file was getting properly regenerated every time the svn
revision changed, every module that used the version was getting rebuilt after
every svn update. This severly annoyed me pretty quickly, so I have improved
the situation.
Now, instead of generating version.h, main/version.c is generated. version.c
includes the version information, as well as a couple of API calls for modules
to retrieve the version. So now, only version.c will get rebuilt, and the main
asterisk binary relinked, which is must faster than rebuilding http.c, manager.c,
asterisk.c, relinking the asterisk binary, chan_sip.c, func_version.c, res_agi ...
The only minor change in behavior here is that the version information reported by
chan_sip, for example, is the version of the Asterisk core, and not necessarily the
Asterisk version that the chan_sip module came from.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@96717 f38db490-d61c-443f-a65b-d21fe96a405b
2008-01-05 22:09:06 +00:00
ast_get_version ( ) , buf , ( int ) st . st_size , mtype ) ;
2007-06-29 20:35:09 +00:00
2008-03-19 15:41:54 +00:00
while ( ( len = read ( fd , buf , sizeof ( buf ) ) ) > 0 ) {
2007-06-29 21:24:40 +00:00
fwrite ( buf , 1 , len , ser - > f ) ;
2008-03-19 15:41:54 +00:00
}
2006-12-16 09:33:31 +00:00
2006-07-18 20:26:38 +00:00
close ( fd ) ;
2008-03-19 15:41:54 +00:00
2007-06-29 20:35:09 +00:00
return NULL ;
2006-04-01 08:49:54 +00:00
out404 :
2008-03-19 16:18:29 +00:00
return ast_http_error ( ( * status = 404 ) ,
( * title = ast_strdup ( " Not Found " ) ) ,
2008-07-31 22:28:42 +00:00
NULL , " The requested URL was not found on this server. " ) ;
2006-04-01 08:49:54 +00:00
out403 :
2008-03-19 16:18:29 +00:00
return ast_http_error ( ( * status = 403 ) ,
( * title = ast_strdup ( " Access Denied " ) ) ,
2008-07-31 22:28:42 +00:00
NULL , " You do not have permission to access the requested URL. " ) ;
2006-04-01 08:49:54 +00:00
}
2006-03-25 23:50:09 +00:00
2008-04-02 15:25:48 +00:00
static struct ast_str * httpstatus_callback ( struct ast_tcptls_session_instance * ser , const struct ast_http_uri * urih , const char * uri , enum ast_http_method method , struct ast_variable * vars , struct ast_variable * headers , int * status , char * * title , int * contentlength )
2006-03-25 23:50:09 +00:00
{
2006-12-16 09:33:31 +00:00
struct ast_str * out = ast_str_create ( 512 ) ;
2006-03-25 23:50:09 +00:00
struct ast_variable * v ;
2008-03-19 15:41:54 +00:00
if ( out = = NULL ) {
2006-12-16 09:33:31 +00:00
return out ;
2008-03-19 15:41:54 +00:00
}
2006-12-16 09:33:31 +00:00
ast_str_append ( & out , 0 ,
2008-03-19 15:41:54 +00:00
" \r \n "
" <title>Asterisk HTTP Status</title> \r \n "
" <body bgcolor= \" #ffffff \" > \r \n "
" <table bgcolor= \" #f1f1f1 \" align= \" center \" ><tr><td bgcolor= \" #e0e0ff \" colspan= \" 2 \" width= \" 500 \" > \r \n "
" <h2> Asterisk™ HTTP Status</h2></td></tr> \r \n " ) ;
2006-12-16 09:33:31 +00:00
ast_str_append ( & out , 0 , " <tr><td><i>Prefix</i></td><td><b>%s</b></td></tr> \r \n " , prefix ) ;
ast_str_append ( & out , 0 , " <tr><td><i>Bind Address</i></td><td><b>%s</b></td></tr> \r \n " ,
2008-03-19 15:41:54 +00:00
ast_inet_ntoa ( http_desc . oldsin . sin_addr ) ) ;
2006-12-16 09:33:31 +00:00
ast_str_append ( & out , 0 , " <tr><td><i>Bind Port</i></td><td><b>%d</b></td></tr> \r \n " ,
2008-03-19 15:41:54 +00:00
ntohs ( http_desc . oldsin . sin_port ) ) ;
if ( http_tls_cfg . enabled ) {
2006-12-16 09:33:31 +00:00
ast_str_append ( & out , 0 , " <tr><td><i>SSL Bind Port</i></td><td><b>%d</b></td></tr> \r \n " ,
2008-03-19 15:41:54 +00:00
ntohs ( https_desc . oldsin . sin_port ) ) ;
}
2006-12-16 09:33:31 +00:00
ast_str_append ( & out , 0 , " <tr><td colspan= \" 2 \" ><hr></td></tr> \r \n " ) ;
2008-03-19 15:41:54 +00:00
2006-12-16 09:33:31 +00:00
for ( v = vars ; v ; v = v - > next ) {
2008-03-19 15:41:54 +00:00
if ( strncasecmp ( v - > name , " cookie_ " , 7 ) ) {
2006-12-16 09:33:31 +00:00
ast_str_append ( & out , 0 , " <tr><td><i>Submitted Variable '%s'</i></td><td>%s</td></tr> \r \n " , v - > name , v - > value ) ;
2008-03-19 15:41:54 +00:00
}
2006-04-01 08:49:54 +00:00
}
2008-03-19 15:41:54 +00:00
2006-12-16 09:33:31 +00:00
ast_str_append ( & out , 0 , " <tr><td colspan= \" 2 \" ><hr></td></tr> \r \n " ) ;
2008-03-19 15:41:54 +00:00
2006-12-16 09:33:31 +00:00
for ( v = vars ; v ; v = v - > next ) {
2008-03-19 15:41:54 +00:00
if ( ! strncasecmp ( v - > name , " cookie_ " , 7 ) ) {
2006-12-16 09:33:31 +00:00
ast_str_append ( & out , 0 , " <tr><td><i>Cookie '%s'</i></td><td>%s</td></tr> \r \n " , v - > name , v - > value ) ;
2008-03-19 15:41:54 +00:00
}
2006-03-25 23:50:09 +00:00
}
2008-03-19 15:41:54 +00:00
2006-12-16 09:33:31 +00:00
ast_str_append ( & out , 0 , " </table><center><font size= \" -1 \" ><i>Asterisk and Digium are registered trademarks of Digium, Inc.</i></font></center></body> \r \n " ) ;
return out ;
2006-03-25 23:50:09 +00:00
}
static struct ast_http_uri statusuri = {
. callback = httpstatus_callback ,
. description = " Asterisk HTTP General Status " ,
. uri = " httpstatus " ,
2008-03-19 15:41:54 +00:00
. supports_get = 1 ,
2008-04-02 15:25:48 +00:00
. data = NULL ,
. key = __FILE__ ,
2006-03-25 23:50:09 +00:00
} ;
2006-09-19 19:58:09 +00:00
2006-04-01 08:49:54 +00:00
static struct ast_http_uri staticuri = {
. callback = static_callback ,
. description = " Asterisk HTTP Static Delivery " ,
. uri = " static " ,
. has_subtree = 1 ,
2007-04-30 15:30:02 +00:00
. static_content = 1 ,
2008-03-19 15:41:54 +00:00
. supports_get = 1 ,
2008-04-02 15:25:48 +00:00
. data = NULL ,
. key = __FILE__ ,
2006-04-01 08:49:54 +00:00
} ;
2006-09-19 19:58:09 +00:00
2006-12-16 09:33:31 +00:00
struct ast_str * ast_http_error ( int status , const char * title , const char * extra_header , const char * text )
2006-03-25 23:50:09 +00:00
{
2006-12-16 09:33:31 +00:00
struct ast_str * out = ast_str_create ( 512 ) ;
2008-03-19 15:41:54 +00:00
if ( out = = NULL ) {
2006-12-16 09:33:31 +00:00
return out ;
2008-03-19 15:41:54 +00:00
}
2006-12-16 09:33:31 +00:00
ast_str_set ( & out , 0 ,
2008-03-19 15:41:54 +00:00
" Content-type: text/html \r \n "
" %s "
" \r \n "
" <!DOCTYPE HTML PUBLIC \" -//IETF//DTD HTML 2.0//EN \" > \r \n "
" <html><head> \r \n "
" <title>%d %s</title> \r \n "
" </head><body> \r \n "
" <h1>%s</h1> \r \n "
" <p>%s</p> \r \n "
" <hr /> \r \n "
" <address>Asterisk Server</address> \r \n "
" </body></html> \r \n " ,
( extra_header ? extra_header : " " ) , status , title , title , text ) ;
2006-12-16 09:33:31 +00:00
return out ;
2006-03-25 23:50:09 +00:00
}
2006-10-16 08:38:35 +00:00
/*! \brief
2007-01-24 09:31:26 +00:00
* Link the new uri into the list .
*
* They are sorted by length of
2006-10-16 08:38:35 +00:00
* the string , not alphabetically . Duplicate entries are not replaced ,
* but the insertion order ( using < = and not just < ) makes sure that
* more recent insertions hide older ones .
* On a lookup , we just scan the list and stop at the first matching entry .
*/
2006-03-25 23:50:09 +00:00
int ast_http_uri_link ( struct ast_http_uri * urih )
{
2006-12-23 20:13:14 +00:00
struct ast_http_uri * uri ;
2006-10-16 08:38:35 +00:00
int len = strlen ( urih - > uri ) ;
2008-03-19 16:18:29 +00:00
if ( ! ( urih - > supports_get | | urih - > supports_post ) ) {
ast_log ( LOG_WARNING , " URI handler does not provide either GET or POST method: %s (%s) \n " , urih - > uri , urih - > description ) ;
return - 1 ;
}
2006-12-28 20:02:41 +00:00
AST_RWLIST_WRLOCK ( & uris ) ;
2006-12-23 20:13:14 +00:00
2008-03-19 15:41:54 +00:00
if ( AST_RWLIST_EMPTY ( & uris ) | | strlen ( AST_RWLIST_FIRST ( & uris ) - > uri ) < = len ) {
2006-12-28 20:02:41 +00:00
AST_RWLIST_INSERT_HEAD ( & uris , urih , entry ) ;
AST_RWLIST_UNLOCK ( & uris ) ;
2008-03-19 15:41:54 +00:00
2006-12-23 20:13:14 +00:00
return 0 ;
2006-03-25 23:50:09 +00:00
}
2006-12-23 20:13:14 +00:00
2006-12-28 20:02:41 +00:00
AST_RWLIST_TRAVERSE ( & uris , uri , entry ) {
2008-03-19 16:18:29 +00:00
if ( AST_RWLIST_NEXT ( uri , entry ) & &
strlen ( AST_RWLIST_NEXT ( uri , entry ) - > uri ) < = len ) {
2006-12-28 20:02:41 +00:00
AST_RWLIST_INSERT_AFTER ( & uris , uri , urih , entry ) ;
AST_RWLIST_UNLOCK ( & uris ) ;
2008-03-19 15:41:54 +00:00
2006-12-23 20:13:14 +00:00
return 0 ;
}
}
2006-12-28 20:02:41 +00:00
AST_RWLIST_INSERT_TAIL ( & uris , urih , entry ) ;
2006-12-23 20:13:14 +00:00
2006-12-28 20:02:41 +00:00
AST_RWLIST_UNLOCK ( & uris ) ;
2006-12-23 20:13:14 +00:00
2006-03-25 23:50:09 +00:00
return 0 ;
2006-09-19 19:58:09 +00:00
}
2006-03-25 23:50:09 +00:00
void ast_http_uri_unlink ( struct ast_http_uri * urih )
{
2006-12-28 20:02:41 +00:00
AST_RWLIST_WRLOCK ( & uris ) ;
AST_RWLIST_REMOVE ( & uris , urih , entry ) ;
AST_RWLIST_UNLOCK ( & uris ) ;
2006-03-25 23:50:09 +00:00
}
2008-04-02 15:25:48 +00:00
void ast_http_uri_unlink_all_with_key ( const char * key )
2007-04-06 21:16:38 +00:00
{
2008-04-02 15:25:48 +00:00
struct ast_http_uri * urih ;
AST_RWLIST_WRLOCK ( & uris ) ;
AST_RWLIST_TRAVERSE_SAFE_BEGIN ( & uris , urih , entry ) {
if ( ! strcmp ( urih - > key , key ) ) {
AST_RWLIST_REMOVE_CURRENT ( entry ) ;
2008-03-19 15:41:54 +00:00
}
2007-04-06 21:16:38 +00:00
}
2008-04-02 15:25:48 +00:00
AST_RWLIST_TRAVERSE_SAFE_END
2008-07-29 21:23:43 +00:00
AST_RWLIST_UNLOCK ( & uris ) ;
2007-04-06 21:16:38 +00:00
}
2008-05-20 17:48:43 +00:00
/*
* Decode special characters in http uri .
* We have ast_uri_decode to handle % XX sequences , but spaces
* are encoded as a ' + ' so we need to replace them beforehand .
*/
static void http_decode ( char * s )
{
2008-07-25 17:21:46 +00:00
char * t ;
for ( t = s ; * t ; t + + ) {
if ( * t = = ' + ' )
* t = ' ' ;
2008-05-20 17:48:43 +00:00
}
2008-07-25 17:21:46 +00:00
2008-05-20 17:48:43 +00:00
ast_uri_decode ( s ) ;
}
2008-03-19 16:18:29 +00:00
static struct ast_str * handle_uri ( struct ast_tcptls_session_instance * ser , char * uri , enum ast_http_method method ,
2008-04-02 15:25:48 +00:00
int * status , char * * title , int * contentlength , struct ast_variable * * cookies , struct ast_variable * headers ,
2008-03-19 15:41:54 +00:00
unsigned int * static_content )
2006-03-25 23:50:09 +00:00
{
char * c ;
2006-12-16 09:33:31 +00:00
struct ast_str * out = NULL ;
2006-10-18 04:05:56 +00:00
char * params = uri ;
2008-03-19 16:18:29 +00:00
struct ast_http_uri * urih = NULL ;
2006-10-18 04:05:56 +00:00
int l ;
2008-03-19 16:18:29 +00:00
struct ast_variable * vars = NULL , * v , * prev = NULL ;
2006-12-23 20:13:14 +00:00
struct http_uri_redirect * redirect ;
2008-03-19 16:18:29 +00:00
int saw_method = 0 ;
2006-10-16 08:38:35 +00:00
2008-03-19 16:18:29 +00:00
/* preserve previous behavior of only support URI parameters on GET requests */
if ( method = = AST_HTTP_GET ) {
strsep ( & params , " ? " ) ;
2008-05-20 17:48:43 +00:00
/* Extract arguments from the request and store them in variables.
* Note that a request can have multiple arguments with the same
* name , and we store them all in the list of variables .
* It is up to the application to handle multiple values .
*/
2008-03-19 16:18:29 +00:00
if ( params ) {
char * var , * val ;
while ( ( val = strsep ( & params , " & " ) ) ) {
var = strsep ( & val , " = " ) ;
if ( val ) {
2008-05-20 17:48:43 +00:00
http_decode ( val ) ;
2008-03-19 15:41:54 +00:00
} else {
2008-03-19 16:18:29 +00:00
val = " " ;
}
2008-05-20 17:48:43 +00:00
http_decode ( var ) ;
2008-03-19 16:18:29 +00:00
if ( ( v = ast_variable_new ( var , val , " " ) ) ) {
if ( vars ) {
prev - > next = v ;
} else {
vars = v ;
}
prev = v ;
2008-03-19 15:41:54 +00:00
}
2006-03-25 23:50:09 +00:00
}
}
}
2008-03-19 16:18:29 +00:00
2006-10-16 08:38:35 +00:00
/*
2008-05-20 17:48:43 +00:00
* Append the cookies to the list of variables .
* This saves a pass in the cookies list , but has the side effect
* that a variable might mask a cookie with the same name if the
* application stops at the first match .
* Note that this is the same behaviour as $ _REQUEST variables in PHP .
2006-10-16 08:38:35 +00:00
*/
2008-03-19 15:41:54 +00:00
if ( prev ) {
2006-04-01 08:49:54 +00:00
prev - > next = * cookies ;
2008-03-19 15:41:54 +00:00
} else {
2006-04-01 08:49:54 +00:00
vars = * cookies ;
2008-03-19 15:41:54 +00:00
}
2006-04-01 08:49:54 +00:00
* cookies = NULL ;
2008-03-19 15:41:54 +00:00
2008-05-20 17:48:43 +00:00
http_decode ( uri ) ;
2006-10-16 08:38:35 +00:00
2006-12-28 20:05:00 +00:00
AST_RWLIST_RDLOCK ( & uri_redirects ) ;
AST_RWLIST_TRAVERSE ( & uri_redirects , redirect , entry ) {
2006-12-23 20:13:14 +00:00
if ( ! strcasecmp ( uri , redirect - > target ) ) {
char buf [ 512 ] ;
2008-03-19 15:41:54 +00:00
2006-12-23 20:13:14 +00:00
snprintf ( buf , sizeof ( buf ) , " Location: %s \r \n " , redirect - > dest ) ;
2008-03-19 16:18:29 +00:00
out = ast_http_error ( ( * status = 302 ) ,
( * title = ast_strdup ( " Moved Temporarily " ) ) ,
2008-07-31 22:28:42 +00:00
buf , " Redirecting... " ) ;
2008-03-19 15:41:54 +00:00
2006-12-23 20:13:14 +00:00
break ;
}
}
2006-12-28 20:05:00 +00:00
AST_RWLIST_UNLOCK ( & uri_redirects ) ;
2008-03-19 15:41:54 +00:00
if ( redirect ) {
2006-12-23 20:13:14 +00:00
goto cleanup ;
2008-03-19 15:41:54 +00:00
}
2006-12-23 20:13:14 +00:00
2008-03-31 20:45:05 +00:00
/* We want requests to start with the (optional) prefix and '/' */
2008-03-31 21:01:59 +00:00
l = strlen ( prefix ) ;
if ( ! strncasecmp ( uri , prefix , l ) & & uri [ l ] = = ' / ' ) {
2006-10-18 04:05:56 +00:00
uri + = l + 1 ;
2006-10-16 08:38:35 +00:00
/* scan registered uris to see if we match one. */
2006-12-28 20:02:41 +00:00
AST_RWLIST_RDLOCK ( & uris ) ;
AST_RWLIST_TRAVERSE ( & uris , urih , entry ) {
2008-05-20 16:39:39 +00:00
ast_debug ( 2 , " match request [%s] with handler [%s] len %d \n " , uri , urih - > uri , l ) ;
2008-03-19 16:18:29 +00:00
if ( ! saw_method ) {
switch ( method ) {
case AST_HTTP_GET :
if ( urih - > supports_get ) {
saw_method = 1 ;
}
break ;
case AST_HTTP_POST :
if ( urih - > supports_post ) {
saw_method = 1 ;
}
break ;
}
}
2006-10-18 04:05:56 +00:00
l = strlen ( urih - > uri ) ;
c = uri + l ; /* candidate */
2008-03-19 15:41:54 +00:00
2008-03-19 16:18:29 +00:00
if ( strncasecmp ( urih - > uri , uri , l ) | | /* no match */
( * c & & * c ! = ' / ' ) ) { /* substring */
2006-10-18 04:05:56 +00:00
continue ;
2008-03-19 15:41:54 +00:00
}
if ( * c = = ' / ' ) {
2006-10-18 04:05:56 +00:00
c + + ;
2008-03-19 15:41:54 +00:00
}
2006-10-18 04:05:56 +00:00
if ( ! * c | | urih - > has_subtree ) {
2008-03-19 16:18:29 +00:00
if ( ( ( method = = AST_HTTP_GET ) & & urih - > supports_get ) | |
( ( method = = AST_HTTP_POST ) & & urih - > supports_post ) ) {
uri = c ;
2008-03-19 15:41:54 +00:00
2008-03-19 16:18:29 +00:00
break ;
}
2006-03-25 23:50:09 +00:00
}
}
2008-03-19 16:18:29 +00:00
2008-03-19 15:41:54 +00:00
if ( ! urih ) {
2006-12-28 20:02:41 +00:00
AST_RWLIST_UNLOCK ( & uris ) ;
2008-03-19 15:41:54 +00:00
}
2006-03-25 23:50:09 +00:00
}
2008-03-19 16:18:29 +00:00
2008-05-23 21:19:42 +00:00
if ( method = = AST_HTTP_POST & & ! astman_is_authed ( manid_from_vars ( vars ) ) ) {
out = ast_http_error ( ( * status = 403 ) ,
( * title = ast_strdup ( " Access Denied " ) ) ,
2008-07-31 22:28:42 +00:00
NULL , " You do not have permission to access the requested URL. " ) ;
2008-05-23 21:19:42 +00:00
} else if ( urih ) {
2008-03-19 15:41:54 +00:00
* static_content = urih - > static_content ;
2008-04-02 15:25:48 +00:00
out = urih - > callback ( ser , urih , uri , method , vars , headers , status , title , contentlength ) ;
2006-12-28 20:02:41 +00:00
AST_RWLIST_UNLOCK ( & uris ) ;
2008-03-19 16:18:29 +00:00
} else if ( saw_method ) {
out = ast_http_error ( ( * status = 404 ) ,
( * title = ast_strdup ( " Not Found " ) ) , NULL ,
" The requested URL was not found on this server. " ) ;
2006-03-25 23:50:09 +00:00
} else {
2008-03-19 16:18:29 +00:00
out = ast_http_error ( ( * status = 501 ) ,
( * title = ast_strdup ( " Not Implemented " ) ) , NULL ,
" Attempt to use unimplemented / unsupported method " ) ;
2006-03-25 23:50:09 +00:00
}
2006-12-23 20:13:14 +00:00
cleanup :
2006-10-18 04:05:56 +00:00
ast_variables_destroy ( vars ) ;
2008-03-19 15:41:54 +00:00
2006-12-16 09:33:31 +00:00
return out ;
2006-03-25 23:50:09 +00:00
}
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
# ifdef DO_SSL
2006-10-22 19:09:25 +00:00
# if defined(HAVE_FUNOPEN)
# define HOOK_T int
# define LEN_T int
# else
# define HOOK_T ssize_t
# define LEN_T size_t
# endif
2008-03-19 15:41:54 +00:00
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
/*!
* replacement read / write functions for SSL support .
* We use wrappers rather than SSL_read / SSL_write directly so
* we can put in some debugging .
*/
2008-01-18 22:04:33 +00:00
/*static HOOK_T ssl_read(void *cookie, char *buf, LEN_T len)
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
{
2006-10-22 19:09:25 +00:00
int i = SSL_read ( cookie , buf , len - 1 ) ;
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
#if 0
if ( i > = 0 )
buf [ i ] = ' \0 ' ;
2006-10-22 19:09:25 +00:00
ast_verbose ( " ssl read size %d returns %d <%s> \n " , ( int ) len , i , buf ) ;
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
# endif
return i ;
}
2006-10-22 19:09:25 +00:00
static HOOK_T ssl_write ( void * cookie , const char * buf , LEN_T len )
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
{
#if 0
char * s = alloca ( len + 1 ) ;
strncpy ( s , buf , len ) ;
s [ len ] = ' \0 ' ;
2006-10-22 19:09:25 +00:00
ast_verbose ( " ssl write size %d <%s> \n " , ( int ) len , s ) ;
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
# endif
return SSL_write ( cookie , buf , len ) ;
}
static int ssl_close ( void * cookie )
{
close ( SSL_get_fd ( cookie ) ) ;
SSL_shutdown ( cookie ) ;
SSL_free ( cookie ) ;
return 0 ;
2008-01-18 22:04:33 +00:00
} */
2006-10-22 19:09:25 +00:00
# endif /* DO_SSL */
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
2008-04-23 22:53:20 +00:00
static struct ast_variable * parse_cookies ( char * cookies )
{
char * cur ;
struct ast_variable * vars = NULL , * var ;
/* Skip Cookie: */
cookies + = 8 ;
while ( ( cur = strsep ( & cookies , " ; " ) ) ) {
char * name , * val ;
name = val = cur ;
strsep ( & val , " = " ) ;
if ( ast_strlen_zero ( name ) | | ast_strlen_zero ( val ) ) {
continue ;
}
name = ast_strip ( name ) ;
val = ast_strip_quoted ( val , " \" " , " \" " ) ;
if ( ast_strlen_zero ( name ) | | ast_strlen_zero ( val ) ) {
continue ;
}
if ( option_debug ) {
ast_log ( LOG_DEBUG , " mmm ... cookie! Name: '%s' Value: '%s' \n " , name , val ) ;
}
var = ast_variable_new ( name , val , __FILE__ ) ;
var - > next = vars ;
vars = var ;
}
return vars ;
}
2006-11-27 19:19:48 +00:00
static void * httpd_helper_thread ( void * data )
{
char buf [ 4096 ] ;
char cookie [ 4096 ] ;
2008-03-12 22:13:18 +00:00
struct ast_tcptls_session_instance * ser = data ;
2008-04-23 22:53:20 +00:00
struct ast_variable * vars = NULL , * headers = NULL ;
2006-12-16 09:33:31 +00:00
char * uri , * title = NULL ;
2006-11-27 19:19:48 +00:00
int status = 200 , contentlength = 0 ;
2006-12-16 09:33:31 +00:00
struct ast_str * out = NULL ;
2007-04-30 15:30:02 +00:00
unsigned int static_content = 0 ;
2008-08-01 21:56:07 +00:00
struct ast_variable * tail = headers ;
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
2008-03-19 15:41:54 +00:00
if ( ! fgets ( buf , sizeof ( buf ) , ser - > f ) ) {
2006-10-18 04:05:56 +00:00
goto done ;
2008-03-19 15:41:54 +00:00
}
2006-03-25 23:50:09 +00:00
2006-10-18 04:05:56 +00:00
uri = ast_skip_nonblanks ( buf ) ; /* Skip method */
2008-03-19 15:41:54 +00:00
if ( * uri ) {
2006-10-18 04:05:56 +00:00
* uri + + = ' \0 ' ;
2008-03-19 15:41:54 +00:00
}
2006-03-25 23:50:09 +00:00
2006-10-18 04:05:56 +00:00
uri = ast_skip_blanks ( uri ) ; /* Skip white space */
2006-04-01 08:49:54 +00:00
2006-10-18 04:05:56 +00:00
if ( * uri ) { /* terminate at the first blank */
2006-12-16 09:33:31 +00:00
char * c = ast_skip_nonblanks ( uri ) ;
2008-03-19 15:41:54 +00:00
if ( * c ) {
2006-10-18 04:05:56 +00:00
* c = ' \0 ' ;
2008-03-19 15:41:54 +00:00
}
2006-10-18 04:05:56 +00:00
}
/* process "Cookie: " lines */
while ( fgets ( cookie , sizeof ( cookie ) , ser - > f ) ) {
/* Trim trailing characters */
ast_trim_blanks ( cookie ) ;
2008-03-19 15:41:54 +00:00
if ( ast_strlen_zero ( cookie ) ) {
2006-10-18 04:05:56 +00:00
break ;
2008-03-19 15:41:54 +00:00
}
2008-05-20 16:39:39 +00:00
if ( ! strncasecmp ( cookie , " Cookie: " , 8 ) ) {
vars = parse_cookies ( cookie ) ;
2008-08-01 21:56:07 +00:00
} else {
char * name , * val ;
val = cookie ;
name = strsep ( & val , " : " ) ;
if ( ast_strlen_zero ( name ) | | ast_strlen_zero ( val ) ) {
continue ;
}
ast_trim_blanks ( name ) ;
val = ast_skip_blanks ( val ) ;
if ( ! headers ) {
headers = ast_variable_new ( name , val , __FILE__ ) ;
tail = headers ;
} else {
tail - > next = ast_variable_new ( name , val , __FILE__ ) ;
tail = tail - > next ;
}
2006-03-25 23:50:09 +00:00
}
}
2006-10-18 04:05:56 +00:00
2008-03-17 22:10:06 +00:00
if ( ! * uri ) {
2006-12-16 09:33:31 +00:00
out = ast_http_error ( 400 , " Bad Request " , NULL , " Invalid Request " ) ;
2008-03-19 16:18:29 +00:00
} else if ( strcasecmp ( buf , " post " ) & & strcasecmp ( buf , " get " ) ) {
2006-12-16 09:33:31 +00:00
out = ast_http_error ( 501 , " Not Implemented " , NULL ,
2008-03-19 16:18:29 +00:00
" Attempt to use unimplemented / unsupported method " ) ;
2008-03-17 22:10:06 +00:00
} else { /* try to serve it */
2008-03-26 21:23:29 +00:00
out = handle_uri ( ser , uri , ( ! strcasecmp ( buf , " get " ) ) ? AST_HTTP_GET : AST_HTTP_POST ,
2008-04-02 15:25:48 +00:00
& status , & title , & contentlength , & vars , headers , & static_content ) ;
2008-03-17 22:10:06 +00:00
}
2006-10-18 04:05:56 +00:00
/* If they aren't mopped up already, clean up the cookies */
2008-03-19 15:41:54 +00:00
if ( vars ) {
2006-10-18 04:05:56 +00:00
ast_variables_destroy ( vars ) ;
2008-03-19 15:41:54 +00:00
}
2007-09-17 14:58:19 +00:00
/* Clean up all the header information pulled as well */
2008-03-19 15:41:54 +00:00
if ( headers ) {
2007-09-17 14:58:19 +00:00
ast_variables_destroy ( headers ) ;
2008-03-19 15:41:54 +00:00
}
2006-10-18 04:05:56 +00:00
2006-12-16 09:33:31 +00:00
if ( out ) {
2007-07-18 19:47:20 +00:00
struct timeval tv = ast_tvnow ( ) ;
2006-10-18 04:05:56 +00:00
char timebuf [ 256 ] ;
2007-07-18 19:47:20 +00:00
struct ast_tm tm ;
2006-10-18 04:05:56 +00:00
2007-07-18 19:47:20 +00:00
ast_strftime ( timebuf , sizeof ( timebuf ) , " %a, %d %b %Y %H:%M:%S %Z " , ast_localtime ( & tv , & tm , " GMT " ) ) ;
2008-03-19 15:41:54 +00:00
fprintf ( ser - > f ,
" HTTP/1.1 %d %s \r \n "
" Server: Asterisk/%s \r \n "
" Date: %s \r \n "
" Connection: close \r \n "
" %s " ,
Now that the version.h file was getting properly regenerated every time the svn
revision changed, every module that used the version was getting rebuilt after
every svn update. This severly annoyed me pretty quickly, so I have improved
the situation.
Now, instead of generating version.h, main/version.c is generated. version.c
includes the version information, as well as a couple of API calls for modules
to retrieve the version. So now, only version.c will get rebuilt, and the main
asterisk binary relinked, which is must faster than rebuilding http.c, manager.c,
asterisk.c, relinking the asterisk binary, chan_sip.c, func_version.c, res_agi ...
The only minor change in behavior here is that the version information reported by
chan_sip, for example, is the version of the Asterisk core, and not necessarily the
Asterisk version that the chan_sip module came from.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@96717 f38db490-d61c-443f-a65b-d21fe96a405b
2008-01-05 22:09:06 +00:00
status , title ? title : " OK " , ast_get_version ( ) , timebuf ,
2007-04-30 15:30:02 +00:00
static_content ? " " : " Cache-Control: no-cache, no-store \r \n " ) ;
2008-01-12 05:13:04 +00:00
/* We set the no-cache headers only for dynamic content.
* If you want to make sure the static file you requested is not from cache ,
* append a random variable to your GET request . Ex : ' something . html ? r = 109987734 '
*/
2006-10-22 08:28:16 +00:00
if ( ! contentlength ) { /* opaque body ? just dump it hoping it is properly formatted */
2006-12-16 09:33:31 +00:00
fprintf ( ser - > f , " %s " , out - > str ) ;
2006-10-22 08:28:16 +00:00
} else {
2006-12-16 09:33:31 +00:00
char * tmp = strstr ( out - > str , " \r \n \r \n " ) ;
2006-10-18 04:05:56 +00:00
if ( tmp ) {
2006-10-22 08:28:16 +00:00
fprintf ( ser - > f , " Content-length: %d \r \n " , contentlength ) ;
2006-10-18 04:05:56 +00:00
/* first write the header, then the body */
2006-12-16 09:33:31 +00:00
fwrite ( out - > str , 1 , ( tmp + 4 - out - > str ) , ser - > f ) ;
2006-10-22 08:28:16 +00:00
fwrite ( tmp + 4 , 1 , contentlength , ser - > f ) ;
2006-10-18 04:05:56 +00:00
}
2006-10-22 08:28:16 +00:00
}
2007-06-06 21:20:11 +00:00
ast_free ( out ) ;
2006-10-18 04:05:56 +00:00
}
2008-03-19 15:41:54 +00:00
if ( title ) {
2007-06-06 21:20:11 +00:00
ast_free ( title ) ;
2008-03-19 15:41:54 +00:00
}
2006-10-18 04:05:56 +00:00
done :
2007-03-08 13:27:02 +00:00
fclose ( ser - > f ) ;
2008-06-17 21:46:57 +00:00
ao2_ref ( ser , - 1 ) ;
ser = NULL ;
2008-03-19 15:41:54 +00:00
2006-03-25 23:50:09 +00:00
return NULL ;
}
2006-12-23 20:13:14 +00:00
/*!
* \ brief Add a new URI redirect
* The entries in the redirect list are sorted by length , just like the list
* of URI handlers .
*/
static void add_redirect ( const char * value )
{
char * target , * dest ;
struct http_uri_redirect * redirect , * cur ;
2006-12-24 03:29:42 +00:00
unsigned int target_len ;
unsigned int total_len ;
2006-12-23 20:13:14 +00:00
dest = ast_strdupa ( value ) ;
2006-12-24 21:01:02 +00:00
dest = ast_skip_blanks ( dest ) ;
target = strsep ( & dest , " " ) ;
target = ast_skip_blanks ( target ) ;
target = strsep ( & target , " " ) ; /* trim trailing whitespace */
2006-12-23 20:13:14 +00:00
if ( ! dest ) {
ast_log ( LOG_WARNING , " Invalid redirect '%s' \n " , value ) ;
return ;
}
2006-12-24 03:29:42 +00:00
target_len = strlen ( target ) + 1 ;
total_len = sizeof ( * redirect ) + target_len + strlen ( dest ) + 1 ;
2006-12-23 20:13:14 +00:00
2008-03-19 15:41:54 +00:00
if ( ! ( redirect = ast_calloc ( 1 , total_len ) ) ) {
2006-12-23 20:13:14 +00:00
return ;
2008-03-19 15:41:54 +00:00
}
2006-12-23 20:13:14 +00:00
2006-12-24 03:29:42 +00:00
redirect - > dest = redirect - > target + target_len ;
strcpy ( redirect - > target , target ) ;
strcpy ( redirect - > dest , dest ) ;
2006-12-23 20:13:14 +00:00
2006-12-28 20:05:00 +00:00
AST_RWLIST_WRLOCK ( & uri_redirects ) ;
2006-12-23 20:13:14 +00:00
2006-12-24 03:29:42 +00:00
target_len - - ; /* So we can compare directly with strlen() */
2008-03-19 15:41:54 +00:00
if ( AST_RWLIST_EMPTY ( & uri_redirects )
| | strlen ( AST_RWLIST_FIRST ( & uri_redirects ) - > target ) < = target_len ) {
2006-12-28 20:05:00 +00:00
AST_RWLIST_INSERT_HEAD ( & uri_redirects , redirect , entry ) ;
AST_RWLIST_UNLOCK ( & uri_redirects ) ;
2008-03-19 15:41:54 +00:00
2006-12-23 20:13:14 +00:00
return ;
}
2006-12-28 20:05:00 +00:00
AST_RWLIST_TRAVERSE ( & uri_redirects , cur , entry ) {
2008-03-19 15:41:54 +00:00
if ( AST_RWLIST_NEXT ( cur , entry )
& & strlen ( AST_RWLIST_NEXT ( cur , entry ) - > target ) < = target_len ) {
2006-12-28 20:05:00 +00:00
AST_RWLIST_INSERT_AFTER ( & uri_redirects , cur , redirect , entry ) ;
AST_RWLIST_UNLOCK ( & uri_redirects ) ;
2008-03-19 15:41:54 +00:00
2006-12-23 20:13:14 +00:00
return ;
}
}
2006-12-28 20:05:00 +00:00
AST_RWLIST_INSERT_TAIL ( & uri_redirects , redirect , entry ) ;
2006-12-23 20:13:14 +00:00
2006-12-28 20:05:00 +00:00
AST_RWLIST_UNLOCK ( & uri_redirects ) ;
2006-12-23 20:13:14 +00:00
}
2006-03-25 23:50:09 +00:00
static int __ast_http_load ( int reload )
{
struct ast_config * cfg ;
struct ast_variable * v ;
int enabled = 0 ;
2006-04-01 08:49:54 +00:00
int newenablestatic = 0 ;
2006-03-25 23:50:09 +00:00
struct hostent * hp ;
struct ast_hostent ahp ;
2008-03-12 22:49:26 +00:00
char newprefix [ MAX_PREFIX ] = " " ;
2006-11-27 20:21:40 +00:00
int have_sslbindaddr = 0 ;
2006-12-23 20:13:14 +00:00
struct http_uri_redirect * redirect ;
2007-08-16 21:09:46 +00:00
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 } ;
2008-03-26 18:39:06 +00:00
if ( ( cfg = ast_config_load2 ( " http.conf " , " http " , config_flags ) ) = = CONFIG_STATUS_FILEUNCHANGED ) {
2007-08-16 21:09:46 +00:00
return 0 ;
2008-03-19 15:41:54 +00:00
}
2006-04-03 18:38:28 +00:00
2006-11-25 17:37:04 +00:00
/* default values */
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
memset ( & http_desc . sin , 0 , sizeof ( http_desc . sin ) ) ;
http_desc . sin . sin_port = htons ( 8088 ) ;
2006-11-25 17:37:04 +00:00
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
memset ( & https_desc . sin , 0 , sizeof ( https_desc . sin ) ) ;
https_desc . sin . sin_port = htons ( 8089 ) ;
2007-04-06 21:16:38 +00:00
2006-12-07 16:42:29 +00:00
http_tls_cfg . enabled = 0 ;
2008-03-19 15:41:54 +00:00
if ( http_tls_cfg . certfile ) {
2007-06-06 21:20:11 +00:00
ast_free ( http_tls_cfg . certfile ) ;
2008-03-19 15:41:54 +00:00
}
2006-12-07 16:42:29 +00:00
http_tls_cfg . certfile = ast_strdup ( AST_CERTFILE ) ;
2008-03-19 15:41:54 +00:00
if ( http_tls_cfg . cipher ) {
2007-06-06 21:20:11 +00:00
ast_free ( http_tls_cfg . cipher ) ;
2008-03-19 15:41:54 +00:00
}
2006-12-07 16:42:29 +00:00
http_tls_cfg . cipher = ast_strdup ( " " ) ;
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
2006-12-28 20:05:00 +00:00
AST_RWLIST_WRLOCK ( & uri_redirects ) ;
2008-03-19 15:41:54 +00:00
while ( ( redirect = AST_RWLIST_REMOVE_HEAD ( & uri_redirects , entry ) ) ) {
2007-06-06 21:20:11 +00:00
ast_free ( redirect ) ;
2008-03-19 15:41:54 +00:00
}
2006-12-28 20:05:00 +00:00
AST_RWLIST_UNLOCK ( & uri_redirects ) ;
2006-12-23 20:13:14 +00:00
2006-03-25 23:50:09 +00:00
if ( cfg ) {
v = ast_variable_browse ( cfg , " general " ) ;
2006-12-23 20:13:14 +00:00
for ( ; v ; v = v - > next ) {
2008-03-19 15:41:54 +00:00
if ( ! strcasecmp ( v - > name , " enabled " ) ) {
2006-03-25 23:50:09 +00:00
enabled = ast_true ( v - > value ) ;
2008-03-19 15:41:54 +00:00
} else if ( ! strcasecmp ( v - > name , " sslenable " ) ) {
2006-12-07 16:42:29 +00:00
http_tls_cfg . enabled = ast_true ( v - > value ) ;
2008-03-19 15:41:54 +00:00
} else if ( ! strcasecmp ( v - > name , " sslbindport " ) ) {
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
https_desc . sin . sin_port = htons ( atoi ( v - > value ) ) ;
2008-03-19 15:41:54 +00:00
} else if ( ! strcasecmp ( v - > name , " sslcert " ) ) {
2007-06-06 21:20:11 +00:00
ast_free ( http_tls_cfg . certfile ) ;
2006-12-07 16:42:29 +00:00
http_tls_cfg . certfile = ast_strdup ( v - > value ) ;
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
} else if ( ! strcasecmp ( v - > name , " sslcipher " ) ) {
2007-06-06 21:20:11 +00:00
ast_free ( http_tls_cfg . cipher ) ;
2006-12-07 16:42:29 +00:00
http_tls_cfg . cipher = ast_strdup ( v - > value ) ;
2008-03-19 15:41:54 +00:00
} else if ( ! strcasecmp ( v - > name , " enablestatic " ) ) {
2006-04-01 08:49:54 +00:00
newenablestatic = ast_true ( v - > value ) ;
2008-03-19 15:41:54 +00:00
} else if ( ! strcasecmp ( v - > name , " bindport " ) ) {
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
http_desc . sin . sin_port = htons ( atoi ( v - > value ) ) ;
2008-03-19 15:41:54 +00:00
} else if ( ! strcasecmp ( v - > name , " sslbindaddr " ) ) {
2006-03-25 23:50:09 +00:00
if ( ( hp = ast_gethostbyname ( v - > value , & ahp ) ) ) {
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
memcpy ( & https_desc . sin . sin_addr , hp - > h_addr , sizeof ( https_desc . sin . sin_addr ) ) ;
2006-11-27 20:21:40 +00:00
have_sslbindaddr = 1 ;
} else {
ast_log ( LOG_WARNING , " Invalid bind address '%s' \n " , v - > value ) ;
}
} else if ( ! strcasecmp ( v - > name , " bindaddr " ) ) {
if ( ( hp = ast_gethostbyname ( v - > value , & ahp ) ) ) {
memcpy ( & http_desc . sin . sin_addr , hp - > h_addr , sizeof ( http_desc . sin . sin_addr ) ) ;
2006-03-25 23:50:09 +00:00
} else {
ast_log ( LOG_WARNING , " Invalid bind address '%s' \n " , v - > value ) ;
}
2006-04-02 09:10:43 +00:00
} else if ( ! strcasecmp ( v - > name , " prefix " ) ) {
if ( ! ast_strlen_zero ( v - > value ) ) {
newprefix [ 0 ] = ' / ' ;
ast_copy_string ( newprefix + 1 , v - > value , sizeof ( newprefix ) - 1 ) ;
} else {
newprefix [ 0 ] = ' \0 ' ;
}
2006-12-23 20:13:14 +00:00
} else if ( ! strcasecmp ( v - > name , " redirect " ) ) {
add_redirect ( v - > value ) ;
} else {
ast_log ( LOG_WARNING , " Ignoring unknown option '%s' in http.conf \n " , v - > name ) ;
2006-04-02 09:10:43 +00:00
}
2006-03-25 23:50:09 +00:00
}
2007-04-06 21:16:38 +00:00
2006-03-25 23:50:09 +00:00
ast_config_destroy ( cfg ) ;
}
2008-03-19 15:41:54 +00:00
if ( ! have_sslbindaddr ) {
2006-11-27 20:21:40 +00:00
https_desc . sin . sin_addr = http_desc . sin . sin_addr ;
2008-03-19 15:41:54 +00:00
}
if ( enabled ) {
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
http_desc . sin . sin_family = https_desc . sin . sin_family = AF_INET ;
2008-03-19 15:41:54 +00:00
}
if ( strcmp ( prefix , newprefix ) ) {
2006-03-25 23:50:09 +00:00
ast_copy_string ( prefix , newprefix , sizeof ( prefix ) ) ;
2008-03-19 15:41:54 +00:00
}
2006-04-01 08:49:54 +00:00
enablestatic = newenablestatic ;
2008-03-04 22:23:21 +00:00
ast_tcptls_server_start ( & http_desc ) ;
2008-03-19 15:41:54 +00:00
if ( ast_ssl_setup ( https_desc . tls_cfg ) ) {
2008-03-04 22:23:21 +00:00
ast_tcptls_server_start ( & https_desc ) ;
2008-03-19 15:41:54 +00:00
}
2007-04-06 21:16:38 +00:00
2006-03-25 23:50:09 +00:00
return 0 ;
}
2007-09-18 22:43:45 +00:00
static char * handle_show_http ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
2006-03-25 23:50:09 +00:00
{
struct ast_http_uri * urih ;
2006-12-23 20:13:14 +00:00
struct http_uri_redirect * redirect ;
2008-03-17 22:10:06 +00:00
2007-09-18 22:43:45 +00:00
switch ( cmd ) {
case CLI_INIT :
e - > command = " http show status " ;
e - > usage =
" Usage: http show status \n "
" Lists status of internal HTTP engine \n " ;
return NULL ;
case CLI_GENERATE :
return NULL ;
}
2008-03-19 15:41:54 +00:00
if ( a - > argc ! = 3 ) {
2007-09-18 22:43:45 +00:00
return CLI_SHOWUSAGE ;
2008-03-19 15:41:54 +00:00
}
2007-09-18 22:43:45 +00:00
ast_cli ( a - > fd , " HTTP Server Status: \n " ) ;
ast_cli ( a - > fd , " Prefix: %s \n " , prefix ) ;
2008-03-19 15:41:54 +00:00
if ( ! http_desc . oldsin . sin_family ) {
2007-09-18 22:43:45 +00:00
ast_cli ( a - > fd , " Server Disabled \n \n " ) ;
2008-03-19 15:41:54 +00:00
} else {
2007-09-18 22:43:45 +00:00
ast_cli ( a - > fd , " Server Enabled and Bound to %s:%d \n \n " ,
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
ast_inet_ntoa ( http_desc . oldsin . sin_addr ) ,
ntohs ( http_desc . oldsin . sin_port ) ) ;
2008-03-19 15:41:54 +00:00
if ( http_tls_cfg . enabled ) {
2007-09-18 22:43:45 +00:00
ast_cli ( a - > fd , " HTTPS Server Enabled and Bound to %s:%d \n \n " ,
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
ast_inet_ntoa ( https_desc . oldsin . sin_addr ) ,
ntohs ( https_desc . oldsin . sin_port ) ) ;
2008-03-19 15:41:54 +00:00
}
Implement https support.
The changes are not large. Most of the diff comes from putting the
global variables describing an accept session into a structure, so
we can reuse the existing code for running multiple accept threads
on different ports.
Once this is done, and if your system has the funopen() library
function (and ssl, of course), it is just a matter of calling
the appropriate functions to set up the ssl connection on the
existing socket, and everything works on the secure channel now.
At the moment, the code is disabled because i have not implemented yet
the autoconf code to detect the presence of funopen(), and add -lssl
to main/Makefile if ssl libraries are present. And a bit of documentation
on the http.conf arguments, too.
If you want to manually enable https support, that is very simple
(step 0 1 2 will be eventually detected by ./configure, the
rest is something you will have to do anyways).
0. make sure your system has funopen(3). FreeBSD does, linux probably
does too, not sure about other systems.
1. uncomment the following line in main/http.c
// #define DO_SSL /* comment in/out if you want to support ssl */
2. add -lssl to AST_LIBS in main/Makefile
3. add the following options to http.conf
sslenable=yes
sslbindport=4433 ; pick one you like
sslcert=/tmp/foo.pem ; path to your certificate file.
4. generate a suitable certificate e.g. (example from mini_httpd's Makefile:
openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem
and here you go:
https://localhost:4433/asterisk/manager
now works.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45869 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-22 12:02:35 +00:00
}
2006-12-23 20:13:14 +00:00
2007-09-18 22:43:45 +00:00
ast_cli ( a - > fd , " Enabled URI's: \n " ) ;
2006-12-28 20:02:41 +00:00
AST_RWLIST_RDLOCK ( & uris ) ;
if ( AST_RWLIST_EMPTY ( & uris ) ) {
2007-09-18 22:43:45 +00:00
ast_cli ( a - > fd , " None. \n " ) ;
2006-12-28 20:02:41 +00:00
} else {
2008-03-19 15:41:54 +00:00
AST_RWLIST_TRAVERSE ( & uris , urih , entry ) {
ast_cli ( a - > fd , " %s/%s%s => %s \n " , prefix , urih - > uri , ( urih - > has_subtree ? " /... " : " " ) , urih - > description ) ;
}
2006-12-28 20:02:41 +00:00
}
AST_RWLIST_UNLOCK ( & uris ) ;
2006-12-23 20:13:14 +00:00
2007-09-18 22:43:45 +00:00
ast_cli ( a - > fd , " \n Enabled Redirects: \n " ) ;
2006-12-28 20:05:00 +00:00
AST_RWLIST_RDLOCK ( & uri_redirects ) ;
2008-03-19 15:41:54 +00:00
AST_RWLIST_TRAVERSE ( & uri_redirects , redirect , entry ) {
2007-09-18 22:43:45 +00:00
ast_cli ( a - > fd , " %s => %s \n " , redirect - > target , redirect - > dest ) ;
2008-03-19 15:41:54 +00:00
}
if ( AST_RWLIST_EMPTY ( & uri_redirects ) ) {
2007-09-18 22:43:45 +00:00
ast_cli ( a - > fd , " None. \n " ) ;
2008-03-19 15:41:54 +00:00
}
2006-12-28 20:05:00 +00:00
AST_RWLIST_UNLOCK ( & uri_redirects ) ;
2006-12-23 20:13:14 +00:00
2007-09-18 22:43:45 +00:00
return CLI_SUCCESS ;
2006-03-25 23:50:09 +00:00
}
int ast_http_reload ( void )
{
return __ast_http_load ( 1 ) ;
}
2006-09-18 19:54:18 +00:00
static struct ast_cli_entry cli_http [ ] = {
2007-10-22 20:05:18 +00:00
AST_CLI_DEFINE ( handle_show_http , " Display HTTP server status " ) ,
2006-03-25 23:50:09 +00:00
} ;
int ast_http_init ( void )
{
ast_http_uri_link ( & statusuri ) ;
2006-04-01 08:49:54 +00:00
ast_http_uri_link ( & staticuri ) ;
2006-09-18 19:54:18 +00:00
ast_cli_register_multiple ( cli_http , sizeof ( cli_http ) / sizeof ( struct ast_cli_entry ) ) ;
2007-04-06 21:16:38 +00:00
2006-03-25 23:50:09 +00:00
return __ast_http_load ( 0 ) ;
}