diff --git a/README.turnutils b/README.turnutils index e0c7c8c8..17550fb4 100644 --- a/README.turnutils +++ b/README.turnutils @@ -113,6 +113,8 @@ Flags: -G Generate extra requests (create permissions, channel bind). +-B Random disconnect after a few initial packets. + Options with required values: -l Message length (Default: 100 Bytes). diff --git a/examples/scripts/selfloadbalance/secure_dos_attack.sh b/examples/scripts/selfloadbalance/secure_dos_attack.sh index 75189d66..4601348b 100755 --- a/examples/scripts/selfloadbalance/secure_dos_attack.sh +++ b/examples/scripts/selfloadbalance/secure_dos_attack.sh @@ -11,7 +11,7 @@ fi export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ -export SLEEP_TIME=9 +export SLEEP_TIME=11 while [ 0 ] ; do @@ -63,6 +63,50 @@ PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -G -t -S -k turn_cli ########################### +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -n 30 -m 10 -l 170 -g -u ninefingers -w youhavetoberealistic -y $@ ::1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -n 30 -m 10 -l 170 -e 127.0.0.1 -X -g -u ninefingers -w youhavetoberealistic $@ ::1 & + +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -B -N -R -G -S -k turn_client_pkey.pem -n 10 -m 10 -l 170 -e ::1 -x -g -u ninefingers -w youhavetoberealistic -s $@ 127.0.0.1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -t -n 50 -m 10 -l 170 -e 127.0.0.1 -X -g -u gorst -w hero $@ ::1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -T -n 30 -m 10 -l 170 -y -g -u gorst -w hero $@ ::1 & + +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -B -N -R -G -T -S -k turn_client_pkey.pem -n 30 -m 10 -l 170 -y -g -u gorst -w hero $@ ::1 & + +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -B -N -R -G -t -S -k turn_client_pkey.pem -n 30 -m 10 -l 170 -e 127.0.0.1 -X -g -u gorst -w hero $@ ::1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -n 30 -m 10 -l 170 -g -u ninefingers -w youhavetoberealistic -y -p 12345 $@ ::1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -n 30 -m 10 -l 170 -e 127.0.0.1 -X -g -u ninefingers -w youhavetoberealistic -p 12345 $@ ::1 & + +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -B -N -R -G -S -k turn_client_pkey.pem -n 30 -m 10 -l 170 -e ::1 -x -g -u ninefingers -w youhavetoberealistic -s -p 12345 $@ 127.0.0.1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -t -n 50 -m 10 -l 170 -e 127.0.0.1 -X -g -u gorst -w hero -p 12345 $@ ::1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -T -n 30 -m 10 -l 170 -y -g -u gorst -w hero -p 12345 $@ ::1 & + +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -B -N -R -G -T -S -k turn_client_pkey.pem -n 30 -m 10 -l 170 -y -g -u gorst -w hero -p 12345 $@ ::1 & + +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -B -N -R -G -t -S -k turn_client_pkey.pem -n 30 -m 10 -l 170 -e 127.0.0.1 -X -g -u gorst -w hero -p 12345 $@ ::1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -n 30 -m 10 -l 170 -g -u ninefingers -w youhavetoberealistic -y -p 12346 $@ ::1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -n 30 -m 10 -l 170 -e 127.0.0.1 -X -g -u ninefingers -w youhavetoberealistic -p 12346 $@ ::1 & + +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -B -N -R -G -S -k turn_client_pkey.pem -n 30 -m 10 -l 170 -e ::1 -x -g -u ninefingers -w youhavetoberealistic -s -p 12346 $@ 127.0.0.1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -t -n 50 -m 10 -l 170 -e 127.0.0.1 -X -g -u gorst -w hero -p 12346 $@ ::1 & + +PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -B -N -R -G -T -n 30 -m 10 -l 170 -y -g -u gorst -w hero -p 12346 $@ ::1 & + +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -B -N -R -G -T -S -k turn_client_pkey.pem -n 30 -m 10 -l 170 -y -g -u gorst -w hero -p 12346 $@ ::1 & + +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -B -N -R -G -t -S -k turn_client_pkey.pem -n 30 -m 10 -l 170 -e 127.0.0.1 -X -g -u gorst -w hero -p 12346 $@ ::1 & + +########################### + PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -O -N -R -G -n 30 -m 10 -l 170 -g -u ninefingers -w youhavetoberealistic -y $@ ::1 & PATH=examples/bin/:../bin/:./bin/:${PATH} turnutils_uclient -O -N -R -G -n 30 -m 10 -l 170 -e 127.0.0.1 -X -g -u ninefingers -w youhavetoberealistic $@ ::1 & diff --git a/man/man1/turnadmin.1 b/man/man1/turnadmin.1 index 7537c852..fbdac452 100644 --- a/man/man1/turnadmin.1 +++ b/man/man1/turnadmin.1 @@ -1,5 +1,5 @@ .\" Text automatically generated by txt2man -.TH TURN 1 "20 April 2014" "" "" +.TH TURN 1 "23 April 2014" "" "" .SH GENERAL INFORMATION \fIturnadmin\fP is a TURN administration tool. This tool can be used to manage diff --git a/man/man1/turnserver.1 b/man/man1/turnserver.1 index 238ba797..14008819 100644 --- a/man/man1/turnserver.1 +++ b/man/man1/turnserver.1 @@ -1,5 +1,5 @@ .\" Text automatically generated by txt2man -.TH TURN 1 "20 April 2014" "" "" +.TH TURN 1 "23 April 2014" "" "" .SH GENERAL INFORMATION The \fBTURN Server\fP project contains the source code of a TURN server and TURN client diff --git a/man/man1/turnutils.1 b/man/man1/turnutils.1 index 1e2c93d9..f72b9e68 100644 --- a/man/man1/turnutils.1 +++ b/man/man1/turnutils.1 @@ -1,5 +1,5 @@ .\" Text automatically generated by txt2man -.TH TURN 1 "20 April 2014" "" "" +.TH TURN 1 "23 April 2014" "" "" .SH GENERAL INFORMATION A set of turnutils_* programs provides some utility functionality to be used @@ -169,6 +169,10 @@ Do not set permissions on TURN relay endpoints Generate extra requests (create permissions, channel bind). .TP .B +\fB\-B\fP +Random disconnect after a few initial packets. +.TP +.B Options with required values: .TP .B diff --git a/src/apps/uclient/mainuclient.c b/src/apps/uclient/mainuclient.c index 01a37856..8d7e77bb 100644 --- a/src/apps/uclient/mainuclient.c +++ b/src/apps/uclient/mainuclient.c @@ -81,6 +81,7 @@ int mandatory_channel_padding = 0; int negative_test = 0; int negative_protocol_test = 0; int dos = 0; +int random_disconnect = 0; SHATYPE shatype = SHATYPE_SHA1; @@ -123,6 +124,7 @@ static char Usage[] = " -I Do not set permissions on TURN relay endpoints\n" " (for testing the non-standard server relay functionality).\n" " -G Generate extra requests (create permissions, channel bind).\n" + " -B Random disconnect after a few initial packets.\n" "Options:\n" " -l Message length (Default: 100 Bytes).\n" " -i Certificate file (for secure connections only, optional).\n" @@ -196,11 +198,14 @@ int main(int argc, char **argv) ns_bzero(local_addr, sizeof(local_addr)); - while ((c = getopt(argc, argv, "d:p:l:n:L:m:e:r:u:w:i:k:z:W:C:E:F:o:vsyhcxXgtTSAPDNOUHMRIG")) != -1) { + while ((c = getopt(argc, argv, "d:p:l:n:L:m:e:r:u:w:i:k:z:W:C:E:F:o:vsyhcxXgtTSAPDNOUHMRIGB")) != -1) { switch (c){ case 'o': STRCPY(origin,optarg); break; + case 'B': + random_disconnect = 1; + break; case 'G': extra_requests = 1; break; diff --git a/src/apps/uclient/uclient.c b/src/apps/uclient/uclient.c index 615488a3..bc27d38e 100644 --- a/src/apps/uclient/uclient.c +++ b/src/apps/uclient/uclient.c @@ -1180,13 +1180,13 @@ static void timer_handler(evutil_socket_t fd, short event, void *arg) int done = 0; for (i = 0; i < total_clients; ++i) { if (elems[i]) { - int finished = client_timer_handler(elems[i],&done); + int finished = client_timer_handler(elems[i], &done); if (finished) { elems[i] = NULL; } } } - if(done>5 && dos) { + if(done>5 && (dos || random_disconnect)) { for (i = 0; i < total_clients; ++i) { if (elems[i]) { close(elems[i]->pinfo.fd); diff --git a/src/apps/uclient/uclient.h b/src/apps/uclient/uclient.h index 00ffdc07..93e595b6 100644 --- a/src/apps/uclient/uclient.h +++ b/src/apps/uclient/uclient.h @@ -76,6 +76,7 @@ extern int mandatory_channel_padding; extern int negative_test; extern int negative_protocol_test; extern int dos; +extern int random_disconnect; extern SHATYPE shatype; extern int mobility; extern int no_permissions; diff --git a/src/server/ns_turn_server.c b/src/server/ns_turn_server.c index fa94532e..0fce1f8c 100644 --- a/src/server/ns_turn_server.c +++ b/src/server/ns_turn_server.c @@ -4258,7 +4258,7 @@ static void peer_input_handler(ioa_socket_handle s, int event_type, TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "session %018llu: client socket to be closed from peer handler: ss=0x%lx\n", (unsigned long long)(ss->id), (long)ss); } - set_ioa_socket_tobeclosed(s); + set_ioa_socket_tobeclosed(ss->client_session.s); } } }