mirror of
				https://github.com/coturn/coturn.git
				synced 2025-10-30 22:40:59 +01:00 
			
		
		
		
	working on https
This commit is contained in:
		
							parent
							
								
									e8394a8f01
								
							
						
					
					
						commit
						8d5ccfa445
					
				| @ -1,5 +1,5 @@ | ||||
| /*
 | ||||
|  * Copyright (C) 2011, 2012, 2013 Citrix Systems | ||||
|  * Copyright (C) 2011, 2012, 2013, 2014 Citrix Systems | ||||
|  * | ||||
|  * All rights reserved. | ||||
|  * | ||||
| @ -51,6 +51,6 @@ static void write_http_echo(ioa_socket_handle s) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void handle_http(ioa_socket_handle s) { | ||||
| void handle_http_echo(ioa_socket_handle s) { | ||||
| 	write_http_echo(s); | ||||
| } | ||||
|  | ||||
							
								
								
									
										57
									
								
								src/apps/relay/http_server.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								src/apps/relay/http_server.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | ||||
| /*
 | ||||
|  * Copyright (C) 2011, 2012, 2013, 2014 Citrix Systems | ||||
|  * | ||||
|  * All rights reserved. | ||||
|  * | ||||
|  * Redistribution and use in source and binary forms, with or without | ||||
|  * modification, are permitted provided that the following conditions | ||||
|  * are met: | ||||
|  * 1. Redistributions of source code must retain the above copyright | ||||
|  *    notice, this list of conditions and the following disclaimer. | ||||
|  * 2. Redistributions in binary form must reproduce the above copyright | ||||
|  *    notice, this list of conditions and the following disclaimer in the | ||||
|  *    documentation and/or other materials provided with the distribution. | ||||
|  * 3. Neither the name of the project nor the names of its contributors | ||||
|  *    may be used to endorse or promote products derived from this software | ||||
|  *    without specific prior written permission. | ||||
|  * | ||||
|  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | ||||
|  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
|  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
|  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | ||||
|  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
|  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
|  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
|  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
|  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
|  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
|  * SUCH DAMAGE. | ||||
|  */ | ||||
| 
 | ||||
| #ifndef __TURN_HTTP_SERVER__ | ||||
| #define __TURN_HTTP_SERVER__ | ||||
| 
 | ||||
| #include <stdlib.h> | ||||
| #include <stdio.h> | ||||
| 
 | ||||
| #include "ns_turn_utils.h" | ||||
| #include "ns_turn_server.h" | ||||
| #include "apputils.h" | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| ////////////////////////////////////////////
 | ||||
| 
 | ||||
| void handle_http_echo(ioa_socket_handle s); | ||||
| 
 | ||||
| ////////////////////////////////////////////
 | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| #endif | ||||
| /// __TURN_HTTP_SERVER__///
 | ||||
| 
 | ||||
| @ -122,7 +122,9 @@ LOW_DEFAULT_PORTS_BOUNDARY,HIGH_DEFAULT_PORTS_BOUNDARY,0,0,0,"", | ||||
| ///////////// Users DB //////////////
 | ||||
| { (TURN_USERDB_TYPE)0, {"\0"}, {0,NULL,NULL, {NULL,0}} }, | ||||
| ///////////// CPUs //////////////////
 | ||||
| DEFAULT_CPUS_NUMBER | ||||
| DEFAULT_CPUS_NUMBER, | ||||
| ///////////// HTTPS ADMIN SERVER ////
 | ||||
| "123" | ||||
| }; | ||||
| 
 | ||||
| //////////////// OpenSSL Init //////////////////////
 | ||||
|  | ||||
| @ -310,6 +310,10 @@ typedef struct _turn_params_ { | ||||
| 
 | ||||
|   unsigned long cpus; | ||||
| 
 | ||||
| /////// HTTPS SERVER /////
 | ||||
| 
 | ||||
|   char https_admin_pwd[129]; | ||||
| 
 | ||||
| } turn_params_t; | ||||
| 
 | ||||
| extern turn_params_t turn_params; | ||||
|  | ||||
| @ -66,6 +66,8 @@ | ||||
| 
 | ||||
| #include "turn_admin_server.h" | ||||
| 
 | ||||
| #include "http_server.h" | ||||
| 
 | ||||
| ///////////////////////////////
 | ||||
| 
 | ||||
| struct cli_server cliserver; | ||||
| @ -1358,6 +1360,7 @@ int send_turn_session_info(struct turn_session_info* tsi) | ||||
| static void write_https_default_page(ioa_socket_handle s) | ||||
| { | ||||
| 	if(s && !ioa_socket_tobeclosed(s)) { | ||||
| 		//TODO
 | ||||
| 		ioa_network_buffer_handle nbh_http = ioa_network_buffer_allocate(s->e); | ||||
| 		size_t len_http = ioa_network_buffer_get_size(nbh_http); | ||||
| 		u08bits *data = ioa_network_buffer_data(nbh_http); | ||||
| @ -1383,11 +1386,14 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh) { | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if(!turn_params.https_admin_pwd[0]) { | ||||
| 		handle_http_echo(s); | ||||
| 	} else { | ||||
| 		if(nbh) { | ||||
| 			//TODO
 | ||||
| 		} | ||||
| 
 | ||||
| 		write_https_default_page(s); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| static void https_input_handler(ioa_socket_handle s, int event_type, ioa_net_data *data, void *arg, int can_resume) { | ||||
| @ -1419,7 +1425,7 @@ void https_cli_server_receive_message(struct bufferevent *bev, void *ptr) | ||||
| 
 | ||||
| 		register_callback_on_ioa_socket(cliserver.e, s, IOA_EV_READ, https_input_handler, NULL, 0); | ||||
| 
 | ||||
| 		write_https_default_page(s); | ||||
| 		handle_https(s,NULL); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -278,7 +278,7 @@ int get_default_protocol_port(const char* scheme, size_t slen); | ||||
| 
 | ||||
| ///////////// HTTP ////////////////////
 | ||||
| 
 | ||||
| void handle_http(ioa_socket_handle s); | ||||
| void handle_http_echo(ioa_socket_handle s); | ||||
| 
 | ||||
| ///////////////////////////////////////
 | ||||
| 
 | ||||
|  | ||||
| @ -4445,7 +4445,7 @@ static int read_client_connection(turn_turnserver *server, | ||||
| 			TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: HTTP connection input: %s\n", __FUNCTION__, (char*)ioa_network_buffer_data(in_buffer->nbh)); | ||||
| 		} | ||||
| 
 | ||||
| 		handle_http(ss->client_socket); | ||||
| 		handle_http_echo(ss->client_socket); | ||||
| 
 | ||||
| 	} else if(sat == HTTPS_CLIENT_SOCKET) { | ||||
| 
 | ||||
| @ -4558,7 +4558,7 @@ static int read_client_connection(turn_turnserver *server, | ||||
| 					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(ss->client_socket); | ||||
| 					handle_http_echo(ss->client_socket); | ||||
| 				} | ||||
| 				return 0; | ||||
| 			} | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user