1
0
mirror of https://github.com/coturn/coturn.git synced 2025-10-28 21:41:29 +01:00

Enhancement: Add option to disable Web-Management-Interface

This commit is contained in:
Carsten Bock 2017-04-10 14:49:55 +02:00
parent 6aa8b7685b
commit c48835e230
6 changed files with 46 additions and 29 deletions

View File

@ -598,6 +598,7 @@ static char Usage[] = "Usage: turnserver [options]\n"
" After the initialization, the turnserver process\n" " After the initialization, the turnserver process\n"
" will make an attempt to change the current group ID to that group.\n" " will make an attempt to change the current group ID to that group.\n"
" --mobility Mobility with ICE (MICE) specs support.\n" " --mobility Mobility with ICE (MICE) specs support.\n"
" --no-http Turn OFF the HTTP-Admin-Interface. By default it is always ON.\n"
" --no-cli Turn OFF the CLI support. By default it is always ON.\n" " --no-cli Turn OFF the CLI support. By default it is always ON.\n"
" --cli-ip=<IP> Local system IP address to be used for CLI server endpoint. Default value\n" " --cli-ip=<IP> Local system IP address to be used for CLI server endpoint. Default value\n"
" is 127.0.0.1.\n" " is 127.0.0.1.\n"
@ -742,7 +743,8 @@ enum EXTRA_OPTS {
ADMIN_USER_QUOTA_OPT, ADMIN_USER_QUOTA_OPT,
SERVER_NAME_OPT, SERVER_NAME_OPT,
OAUTH_OPT, OAUTH_OPT,
PROD_OPT PROD_OPT,
NO_HTTP_OPT
}; };
struct myoption { struct myoption {
@ -849,6 +851,7 @@ static const struct myoption long_options[] = {
{ "cli-ip", required_argument, NULL, CLI_IP_OPT }, { "cli-ip", required_argument, NULL, CLI_IP_OPT },
{ "cli-port", required_argument, NULL, CLI_PORT_OPT }, { "cli-port", required_argument, NULL, CLI_PORT_OPT },
{ "cli-password", required_argument, NULL, CLI_PASSWORD_OPT }, { "cli-password", required_argument, NULL, CLI_PASSWORD_OPT },
{ "no-http", optional_argument, NULL, NO_HTTP_OPT },
{ "server-relay", optional_argument, NULL, SERVER_RELAY_OPT }, { "server-relay", optional_argument, NULL, SERVER_RELAY_OPT },
{ "cli-max-output-sessions", required_argument, NULL, CLI_MAX_SESSIONS_OPT }, { "cli-max-output-sessions", required_argument, NULL, CLI_MAX_SESSIONS_OPT },
{ "ec-curve-name", required_argument, NULL, EC_CURVE_NAME_OPT }, { "ec-curve-name", required_argument, NULL, EC_CURVE_NAME_OPT },
@ -992,6 +995,9 @@ static void set_option(int c, char *value)
case NO_CLI_OPT: case NO_CLI_OPT:
use_cli = !get_bool_value(value); use_cli = !get_bool_value(value);
break; break;
case NO_HTTP_OPT:
use_http = !get_bool_value(value);
break;
case CLI_IP_OPT: case CLI_IP_OPT:
if(make_ioa_addr((const u08bits*)value,0,&cli_addr)<0) { if(make_ioa_addr((const u08bits*)value,0,&cli_addr)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot set cli address: %s\n",value); TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot set cli address: %s\n",value);

View File

@ -1651,7 +1651,7 @@ static void setup_relay_server(struct relay_server *rs, ioa_engine_handle e, int
send_turn_session_info, send_turn_session_info,
send_https_socket, send_https_socket,
allocate_bps, allocate_bps,
turn_params.oauth, turn_params.oauth_server_name); turn_params.oauth, turn_params.oauth_server_name, use_http);
if(to_set_rfc5780) { if(to_set_rfc5780) {
set_rfc5780(&(rs->server), get_alt_addr, send_message_from_listener_to_client); set_rfc5780(&(rs->server), get_alt_addr, send_message_from_listener_to_client);

View File

@ -77,6 +77,8 @@ struct admin_server adminserver;
int use_cli = 1; int use_cli = 1;
int use_http = 1;
ioa_addr cli_addr; ioa_addr cli_addr;
int cli_addr_set = 0; int cli_addr_set = 0;
@ -1210,8 +1212,7 @@ void setup_admin_thread(void)
bufferevent_setcb(adminserver.in_buf, admin_server_receive_message, NULL, NULL, &adminserver); bufferevent_setcb(adminserver.in_buf, admin_server_receive_message, NULL, NULL, &adminserver);
bufferevent_enable(adminserver.in_buf, EV_READ); bufferevent_enable(adminserver.in_buf, EV_READ);
} }
if (use_http) {
{
struct bufferevent *pair[2]; struct bufferevent *pair[2];
bufferevent_pair_new(adminserver.event_base, TURN_BUFFEREVENTS_OPTIONS, pair); bufferevent_pair_new(adminserver.event_base, TURN_BUFFEREVENTS_OPTIONS, pair);

View File

@ -81,6 +81,8 @@ extern struct admin_server adminserver;
extern int use_cli; extern int use_cli;
extern int use_http;
#define CLI_DEFAULT_IP ("127.0.0.1") #define CLI_DEFAULT_IP ("127.0.0.1")
extern ioa_addr cli_addr; extern ioa_addr cli_addr;
extern int cli_addr_set; extern int cli_addr_set;

View File

@ -4543,32 +4543,34 @@ static int read_client_connection(turn_turnserver *server,
} }
} else { } else {
SOCKET_TYPE st = get_ioa_socket_type(ss->client_socket); if (server->use_http) {
if(is_stream_socket(st)) { SOCKET_TYPE st = get_ioa_socket_type(ss->client_socket);
if(is_http((char*)ioa_network_buffer_data(in_buffer->nbh), ioa_network_buffer_get_size(in_buffer->nbh))) { if(is_stream_socket(st)) {
const char *proto = "HTTP"; if(is_http((char*)ioa_network_buffer_data(in_buffer->nbh), ioa_network_buffer_get_size(in_buffer->nbh))) {
ioa_network_buffer_data(in_buffer->nbh)[ioa_network_buffer_get_size(in_buffer->nbh)] = 0; const char *proto = "HTTP";
if(st==TLS_SOCKET) { ioa_network_buffer_data(in_buffer->nbh)[ioa_network_buffer_get_size(in_buffer->nbh)] = 0;
proto = "HTTPS"; if(st==TLS_SOCKET) {
set_ioa_socket_app_type(ss->client_socket,HTTPS_CLIENT_SOCKET); proto = "HTTPS";
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: %s (%s %s) request: %s\n", __FUNCTION__, proto, get_ioa_socket_cipher(ss->client_socket), get_ioa_socket_ssl_method(ss->client_socket), (char*)ioa_network_buffer_data(in_buffer->nbh)); set_ioa_socket_app_type(ss->client_socket,HTTPS_CLIENT_SOCKET);
if(server->send_https_socket) { TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: %s (%s %s) request: %s\n", __FUNCTION__, proto, get_ioa_socket_cipher(ss->client_socket), get_ioa_socket_ssl_method(ss->client_socket), (char*)ioa_network_buffer_data(in_buffer->nbh));
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s socket to be detached: 0x%lx, st=%d, sat=%d\n", __FUNCTION__,(long)ss->client_socket, get_ioa_socket_type(ss->client_socket), get_ioa_socket_app_type(ss->client_socket)); if(server->send_https_socket) {
ioa_socket_handle new_s = detach_ioa_socket(ss->client_socket); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s socket to be detached: 0x%lx, st=%d, sat=%d\n", __FUNCTION__,(long)ss->client_socket, get_ioa_socket_type(ss->client_socket), get_ioa_socket_app_type(ss->client_socket));
if(new_s) { ioa_socket_handle new_s = detach_ioa_socket(ss->client_socket);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s new detached socket: 0x%lx, st=%d, sat=%d\n", __FUNCTION__,(long)new_s, get_ioa_socket_type(new_s), get_ioa_socket_app_type(new_s)); if(new_s) {
server->send_https_socket(new_s); TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s new detached socket: 0x%lx, st=%d, sat=%d\n", __FUNCTION__,(long)new_s, get_ioa_socket_type(new_s), get_ioa_socket_app_type(new_s));
server->send_https_socket(new_s);
}
ss->to_be_closed = 1;
} }
ss->to_be_closed = 1; } else {
set_ioa_socket_app_type(ss->client_socket,HTTP_CLIENT_SOCKET);
if(server->verbose) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: %s request: %s\n", __FUNCTION__, proto, (char*)ioa_network_buffer_data(in_buffer->nbh));
}
handle_http_echo(ss->client_socket);
} }
} else { return 0;
set_ioa_socket_app_type(ss->client_socket,HTTP_CLIENT_SOCKET);
if(server->verbose) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: %s request: %s\n", __FUNCTION__, proto, (char*)ioa_network_buffer_data(in_buffer->nbh));
}
handle_http_echo(ss->client_socket);
} }
return 0;
} }
} }
} }
@ -4825,7 +4827,7 @@ void init_turn_server(turn_turnserver* server,
send_turn_session_info_cb send_turn_session_info, send_turn_session_info_cb send_turn_session_info,
send_https_socket_cb send_https_socket, send_https_socket_cb send_https_socket,
allocate_bps_cb allocate_bps_func, allocate_bps_cb allocate_bps_func,
int oauth, const char* oauth_server_name) { int oauth, const char* oauth_server_name, int use_http) {
if (!server) if (!server)
return; return;
@ -4892,6 +4894,8 @@ void init_turn_server(turn_turnserver* server,
server->allocate_bps_func = allocate_bps_func; server->allocate_bps_func = allocate_bps_func;
server->use_http = use_http;
set_ioa_timer(server->e, 1, 0, timer_timeout_handler, server, 1, "timer_timeout_handler"); set_ioa_timer(server->e, 1, 0, timer_timeout_handler, server, 1, "timer_timeout_handler");
} }

View File

@ -169,6 +169,9 @@ struct _turn_turnserver {
/* oAuth: */ /* oAuth: */
int oauth; int oauth;
const char* oauth_server_name; const char* oauth_server_name;
/* HTTP-Admin-Server: */
int use_http;
}; };
const char * get_version(turn_turnserver *server); const char * get_version(turn_turnserver *server);
@ -212,7 +215,8 @@ void init_turn_server(turn_turnserver* server,
send_https_socket_cb send_https_socket, send_https_socket_cb send_https_socket,
allocate_bps_cb allocate_bps_func, allocate_bps_cb allocate_bps_func,
int oauth, int oauth,
const char* oauth_server_name); const char* oauth_server_name,
int use_http);
ioa_engine_handle turn_server_get_engine(turn_turnserver *s); ioa_engine_handle turn_server_get_engine(turn_turnserver *s);