1
0
mirror of https://github.com/coturn/coturn.git synced 2025-10-23 12:00:59 +02:00

Add new feature: keep-address-family

This commit is contained in:
Mészáros Mihály 2018-09-06 14:26:42 +02:00
parent 0964392b9f
commit 93c1103bb8
11 changed files with 70 additions and 16 deletions

View File

@ -8,7 +8,7 @@ Version 4.5.0.8 'dan Eider':
list all phony targets list all phony targets
- fix typo PR#253 (by Orsiris de Jong) - fix typo PR#253 (by Orsiris de Jong)
- Fix WebRTC client IPv6 stuck connection. (issue #217) - Fix WebRTC client IPv6 stuck connection. (issue #217)
THX toq damencho, vol4iniche THX to damencho, vol4iniche
- Spelling fixes. - Spelling fixes.
- Add a warning if --lt-cred-mech and --use-auth-secret both presents. - Add a warning if --lt-cred-mech and --use-auth-secret both presents.
- Revert "Add the realm parameter in the example config file (by Domenico)" - Revert "Add the realm parameter in the example config file (by Domenico)"
@ -23,6 +23,8 @@ Version 4.5.0.8 'dan Eider':
- Add a Warning if lines in config file ends with semicolon (by heyheyjc) - Add a Warning if lines in config file ends with semicolon (by heyheyjc)
- Fix --prod pointer bug - Fix --prod pointer bug
- Fix auth server thread detach race (by weishuyin) - Fix auth server thread detach race (by weishuyin)
- New Feature: Add -K --keep-address-family
Be aware if you enable it, then it breaks rfc6156 section-4.2 (default IPv4 family)
12/10/2017 Oleg Moskalenko <mom040267@gmail.com> 12/10/2017 Oleg Moskalenko <mom040267@gmail.com>
Version 4.5.0.7 'dan Eider': Version 4.5.0.7 'dan Eider':

View File

@ -532,7 +532,11 @@ Options with values:
--proc-group Group name to run the process. After the initialization, the turnserver process --proc-group Group name to run the process. After the initialization, the turnserver process
will make an attempt to change the current group ID to that group. will make an attempt to change the current group ID to that group.
-K, --keep-address-family TURN server allocates address family according TURN
Client <=> Server communication address family.
!! It breaks RFC6156 section-4.2 (violates default IPv4) !!
--cli-ip Local system IP address to be used for CLI management interface. --cli-ip Local system IP address to be used for CLI management interface.
The turnserver process can be accessed for management with telnet, The turnserver process can be accessed for management with telnet,
at this IP address and on the CLI port (see the next parameter). at this IP address and on the CLI port (see the next parameter).

View File

@ -612,6 +612,15 @@
# #
#mobility #mobility
# Allocate Address Family according
# If enabled then TURN server allocates address family according the TURN
# Client <=> Server communication address family.
# (By default coTURN works according RFC 6156.)
# !!Warning: Enabling this option breaks RFC6156 section-4.2 (violates use default IPv4)!!
#
#keep-address-family
# User name to run the process. After the initialization, the turnserver process # User name to run the process. After the initialization, the turnserver process
# will make an attempt to change the current user ID to that user. # will make an attempt to change the current user ID to that user.
# #

View File

@ -1,5 +1,5 @@
.\" Text automatically generated by txt2man .\" Text automatically generated by txt2man
.TH TURN 1 "15 August 2018" "" "" .TH TURN 1 "06 September 2018" "" ""
.SH GENERAL INFORMATION .SH GENERAL INFORMATION
\fIturnadmin\fP is a TURN administration tool. This tool can be used to manage \fIturnadmin\fP is a TURN administration tool. This tool can be used to manage

View File

@ -1,5 +1,5 @@
.\" Text automatically generated by txt2man .\" Text automatically generated by txt2man
.TH TURN 1 "15 August 2018" "" "" .TH TURN 1 "06 September 2018" "" ""
.SH GENERAL INFORMATION .SH GENERAL INFORMATION
The \fBTURN Server\fP project contains the source code of a TURN server and TURN client The \fBTURN Server\fP project contains the source code of a TURN server and TURN client
@ -768,6 +768,12 @@ Group name to run the process. After the initialization, the \fIturnserver\fP pr
will make an attempt to change the current group ID to that group. will make an attempt to change the current group ID to that group.
.TP .TP
.B .B
\fB\-K\fP, \fB\-\-keep\-address\-family\fP
TURN server allocates address family according TURN
Client <=> Server communication address family.
!! It breaks RFC6156 section\-4.2 (violates default IPv4) !!
.TP
.B
\fB\-\-cli\-ip\fP \fB\-\-cli\-ip\fP
Local system IP address to be used for CLI management interface. Local system IP address to be used for CLI management interface.
The \fIturnserver\fP process can be accessed for management with telnet, The \fIturnserver\fP process can be accessed for management with telnet,

View File

@ -1,5 +1,5 @@
.\" Text automatically generated by txt2man .\" Text automatically generated by txt2man
.TH TURN 1 "15 August 2018" "" "" .TH TURN 1 "06 September 2018" "" ""
.SH GENERAL INFORMATION .SH GENERAL INFORMATION
A set of turnutils_* programs provides some utility functionality to be used A set of turnutils_* programs provides some utility functionality to be used

View File

@ -155,7 +155,8 @@ DEFAULT_CPUS_NUMBER,
///////// Encryption ///////// ///////// Encryption /////////
"", /* secret_key_file */ "", /* secret_key_file */
"", /* secret_key */ "", /* secret_key */
0 /* allow_encoding */ 0, /* allow_encoding */
0 /* keep_address_family */
}; };
//////////////// OpenSSL Init ////////////////////// //////////////// OpenSSL Init //////////////////////
@ -616,6 +617,9 @@ static char Usage[] = "Usage: turnserver [options]\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-http Turn OFF the HTTP-Admin-Interface. By default it is always ON.\n"
" -K, --keep-address-family TURN server allocates address family according TURN\n"
" Client <=> Server communication address family. \n"
" !! It breaks RFC6156 section-4.2 (violates default IPv4) !!\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"
@ -696,7 +700,7 @@ static char AdminUsage[] = "Usage: turnadmin [command] [options]\n"
" Setting to zero value means removal of the option.\n" " Setting to zero value means removal of the option.\n"
" -h, --help Help\n"; " -h, --help Help\n";
#define OPTIONS "c:d:p:L:E:X:i:m:l:r:u:b:B:e:M:J:N:O:q:Q:s:C:vVofhznaAS" #define OPTIONS "c:d:p:L:E:X:i:m:l:r:u:b:B:e:M:J:N:O:q:Q:s:C:K:vVofhznaAS"
#define ADMIN_OPTIONS "PEgGORIHKYlLkaADSdb:e:M:J:N:u:r:p:s:X:o:h:x:v:f:" #define ADMIN_OPTIONS "PEgGORIHKYlLkaADSdb:e:M:J:N:u:r:p:s:X:o:h:x:v:f:"
@ -889,6 +893,7 @@ static const struct myoption long_options[] = {
{ "no-tlsv1_2", optional_argument, NULL, NO_TLSV1_2_OPT }, { "no-tlsv1_2", optional_argument, NULL, NO_TLSV1_2_OPT },
{ "secret-key-file", required_argument, NULL, SECRET_KEY_OPT }, { "secret-key-file", required_argument, NULL, SECRET_KEY_OPT },
{ "allow-encoding-with-aes", required_argument, NULL, ALLOW_ENCODING_OPT}, { "allow-encoding-with-aes", required_argument, NULL, ALLOW_ENCODING_OPT},
{ "keep-address-family", optional_argument, NULL, 'K' },
{ NULL, no_argument, NULL, 0 } { NULL, no_argument, NULL, 0 }
}; };
@ -1104,6 +1109,9 @@ static void set_option(int c, char *value)
} }
switch (c) { switch (c) {
case 'K':
turn_params.keep_address_family = get_bool_value(value);
break;
case SERVER_NAME_OPT: case SERVER_NAME_OPT:
STRCPY(turn_params.oauth_server_name,value); STRCPY(turn_params.oauth_server_name,value);
break; break;

View File

@ -318,6 +318,7 @@ typedef struct _turn_params_ {
char secret_key_file[1025]; char secret_key_file[1025];
unsigned char secret_key[1025]; unsigned char secret_key[1025];
int allow_encoding; int allow_encoding;
int keep_address_family;
} turn_params_t; } turn_params_t;

View File

@ -1667,7 +1667,10 @@ 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, use_http); turn_params.oauth,
turn_params.oauth_server_name,
use_http,
turn_params.keep_address_family);
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

@ -1260,13 +1260,25 @@ static int handle_turn_allocate(turn_turnserver *server,
if(!(*err_code)) { if(!(*err_code)) {
if(!af4 && !af6) { if(!af4 && !af6) {
int a_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT; int a_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT;
if(get_ioa_socket_address_family(ss->client_socket) == AF_INET6) if (server->keep_address_family) {
a_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6; switch(get_ioa_socket_address_family(ss->client_socket)) {
case AF_INET6 :
a_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
break;
case AF_INET :
a_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4;
break;
}
if(get_ioa_socket_address_family(ss->client_socket) == AF_INET6)
a_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
}
int res = create_relay_connection(server, ss, lifetime, int res = create_relay_connection(server, ss, lifetime,
a_family, transport, a_family, transport,
even_port, in_reservation_token, &out_reservation_token, even_port, in_reservation_token, &out_reservation_token,
err_code, reason, err_code, reason,
tcp_peer_accept_connection); tcp_peer_accept_connection);
if(res<0) { if(res<0) {
set_relay_session_failure(alloc,AF_INET); set_relay_session_failure(alloc,AF_INET);
if(!(*err_code)) { if(!(*err_code)) {
@ -4839,7 +4851,10 @@ 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 use_http) { int oauth,
const char* oauth_server_name,
int use_http,
int keep_address_family) {
if (!server) if (!server)
return; return;
@ -4908,6 +4923,8 @@ void init_turn_server(turn_turnserver* server,
server->use_http = use_http; server->use_http = use_http;
server->keep_address_family = keep_address_family;
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

@ -172,6 +172,9 @@ struct _turn_turnserver {
/* HTTP-Admin-Server: */ /* HTTP-Admin-Server: */
int use_http; int use_http;
/* Keep Address Family */
int keep_address_family;
}; };
const char * get_version(turn_turnserver *server); const char * get_version(turn_turnserver *server);
@ -216,7 +219,8 @@ void init_turn_server(turn_turnserver* server,
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); int use_http,
int keep_address_family);
ioa_engine_handle turn_server_get_engine(turn_turnserver *s); ioa_engine_handle turn_server_get_engine(turn_turnserver *s);