|
@@ -4543,32 +4543,34 @@ static int read_client_connection(turn_turnserver *server,
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- SOCKET_TYPE st = get_ioa_socket_type(ss->client_socket);
|
|
|
- if(is_stream_socket(st)) {
|
|
|
- if(is_http((char*)ioa_network_buffer_data(in_buffer->nbh), ioa_network_buffer_get_size(in_buffer->nbh))) {
|
|
|
- const char *proto = "HTTP";
|
|
|
- ioa_network_buffer_data(in_buffer->nbh)[ioa_network_buffer_get_size(in_buffer->nbh)] = 0;
|
|
|
- if(st==TLS_SOCKET) {
|
|
|
- proto = "HTTPS";
|
|
|
- set_ioa_socket_app_type(ss->client_socket,HTTPS_CLIENT_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));
|
|
|
- if(server->send_https_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));
|
|
|
- ioa_socket_handle new_s = detach_ioa_socket(ss->client_socket);
|
|
|
- if(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);
|
|
|
+ if (server->use_http) {
|
|
|
+ SOCKET_TYPE st = get_ioa_socket_type(ss->client_socket);
|
|
|
+ if(is_stream_socket(st)) {
|
|
|
+ if(is_http((char*)ioa_network_buffer_data(in_buffer->nbh), ioa_network_buffer_get_size(in_buffer->nbh))) {
|
|
|
+ const char *proto = "HTTP";
|
|
|
+ ioa_network_buffer_data(in_buffer->nbh)[ioa_network_buffer_get_size(in_buffer->nbh)] = 0;
|
|
|
+ if(st==TLS_SOCKET) {
|
|
|
+ proto = "HTTPS";
|
|
|
+ set_ioa_socket_app_type(ss->client_socket,HTTPS_CLIENT_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));
|
|
|
+ if(server->send_https_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));
|
|
|
+ ioa_socket_handle new_s = detach_ioa_socket(ss->client_socket);
|
|
|
+ if(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));
|
|
|
+ } 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);
|
|
|
}
|
|
|
- handle_http_echo(ss->client_socket);
|
|
|
+ return 0;
|
|
|
}
|
|
|
- return 0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -4825,7 +4827,7 @@ void init_turn_server(turn_turnserver* server,
|
|
|
send_turn_session_info_cb send_turn_session_info,
|
|
|
send_https_socket_cb send_https_socket,
|
|
|
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)
|
|
|
return;
|
|
@@ -4892,6 +4894,8 @@ void init_turn_server(turn_turnserver* server,
|
|
|
|
|
|
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");
|
|
|
}
|
|
|
|