diff options
-rw-r--r-- | DONATORS | 6 | ||||
-rw-r--r-- | auto_tests/tox_test.c | 34 | ||||
-rw-r--r-- | super_donators/grencez_tok5.c | 41 | ||||
-rwxr-xr-x | super_donators/sir@cmpwn.com | 21 | ||||
-rw-r--r-- | toxcore/onion_client.c | 28 | ||||
-rw-r--r-- | toxcore/onion_client.h | 3 |
6 files changed, 105 insertions, 28 deletions
diff --git a/DONATORS b/DONATORS new file mode 100644 index 00000000..fc7ee419 --- /dev/null +++ b/DONATORS | |||
@@ -0,0 +1,6 @@ | |||
1 | Minnesota > Florida | ||
2 | vdo <vdo@greyfaze.net> | ||
3 | Spitfire is best technicolor horse. | ||
4 | if bad people don't hate you, you're doing something wrong | ||
5 | Pinkie Pie is best pony. | ||
6 | JRS was here | ||
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 682cdb54..648230f0 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -806,7 +806,7 @@ START_TEST(test_few_clients) | |||
806 | } | 806 | } |
807 | END_TEST | 807 | END_TEST |
808 | 808 | ||
809 | #define NUM_TOXES 66 | 809 | #define NUM_TOXES 90 |
810 | #define NUM_FRIENDS 50 | 810 | #define NUM_FRIENDS 50 |
811 | 811 | ||
812 | START_TEST(test_many_clients) | 812 | START_TEST(test_many_clients) |
@@ -899,16 +899,17 @@ loop_top: | |||
899 | } | 899 | } |
900 | END_TEST | 900 | END_TEST |
901 | 901 | ||
902 | #define NUM_TOXES_TCP 40 | ||
902 | #define TCP_RELAY_PORT 33448 | 903 | #define TCP_RELAY_PORT 33448 |
903 | 904 | ||
904 | START_TEST(test_many_clients_tcp) | 905 | START_TEST(test_many_clients_tcp) |
905 | { | 906 | { |
906 | long long unsigned int cur_time = time(NULL); | 907 | long long unsigned int cur_time = time(NULL); |
907 | Tox *toxes[NUM_TOXES]; | 908 | Tox *toxes[NUM_TOXES_TCP]; |
908 | uint32_t i, j; | 909 | uint32_t i, j; |
909 | uint32_t to_comp = 974536; | 910 | uint32_t to_comp = 974536; |
910 | 911 | ||
911 | for (i = 0; i < NUM_TOXES; ++i) { | 912 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
912 | struct Tox_Options opts; | 913 | struct Tox_Options opts; |
913 | tox_options_default(&opts); | 914 | tox_options_default(&opts); |
914 | 915 | ||
@@ -945,8 +946,8 @@ START_TEST(test_many_clients_tcp) | |||
945 | 946 | ||
946 | for (i = 0; i < NUM_FRIENDS; ++i) { | 947 | for (i = 0; i < NUM_FRIENDS; ++i) { |
947 | loop_top: | 948 | loop_top: |
948 | pairs[i].tox1 = rand() % NUM_TOXES; | 949 | pairs[i].tox1 = rand() % NUM_TOXES_TCP; |
949 | pairs[i].tox2 = (pairs[i].tox1 + rand() % (NUM_TOXES - 1) + 1) % NUM_TOXES; | 950 | pairs[i].tox2 = (pairs[i].tox1 + rand() % (NUM_TOXES_TCP - 1) + 1) % NUM_TOXES_TCP; |
950 | 951 | ||
951 | for (j = 0; j < i; ++j) { | 952 | for (j = 0; j < i; ++j) { |
952 | if (pairs[j].tox2 == pairs[i].tox1 && pairs[j].tox1 == pairs[i].tox2) | 953 | if (pairs[j].tox2 == pairs[i].tox1 && pairs[j].tox1 == pairs[i].tox2) |
@@ -966,26 +967,27 @@ loop_top: | |||
966 | } | 967 | } |
967 | 968 | ||
968 | while (1) { | 969 | while (1) { |
969 | uint16_t counter = 0; | 970 | uint16_t counter = 0, cc = 0; |
970 | 971 | ||
971 | for (i = 0; i < NUM_TOXES; ++i) { | 972 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
972 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) | 973 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) |
973 | if (tox_friend_get_connection_status(toxes[i], j, 0) == TOX_CONNECTION_TCP) | 974 | if (tox_friend_get_connection_status(toxes[i], j, 0) == TOX_CONNECTION_TCP) |
974 | ++counter; | 975 | ++counter; |
976 | |||
975 | } | 977 | } |
976 | 978 | ||
977 | if (counter == NUM_FRIENDS * 2) { | 979 | if (counter == NUM_FRIENDS * 2) { |
978 | break; | 980 | break; |
979 | } | 981 | } |
980 | 982 | ||
981 | for (i = 0; i < NUM_TOXES; ++i) { | 983 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
982 | tox_iterate(toxes[i]); | 984 | tox_iterate(toxes[i]); |
983 | } | 985 | } |
984 | 986 | ||
985 | c_sleep(50); | 987 | c_sleep(50); |
986 | } | 988 | } |
987 | 989 | ||
988 | for (i = 0; i < NUM_TOXES; ++i) { | 990 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
989 | tox_kill(toxes[i]); | 991 | tox_kill(toxes[i]); |
990 | } | 992 | } |
991 | 993 | ||
@@ -998,11 +1000,11 @@ END_TEST | |||
998 | START_TEST(test_many_clients_tcp_b) | 1000 | START_TEST(test_many_clients_tcp_b) |
999 | { | 1001 | { |
1000 | long long unsigned int cur_time = time(NULL); | 1002 | long long unsigned int cur_time = time(NULL); |
1001 | Tox *toxes[NUM_TOXES]; | 1003 | Tox *toxes[NUM_TOXES_TCP]; |
1002 | uint32_t i, j; | 1004 | uint32_t i, j; |
1003 | uint32_t to_comp = 974536; | 1005 | uint32_t to_comp = 974536; |
1004 | 1006 | ||
1005 | for (i = 0; i < NUM_TOXES; ++i) { | 1007 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
1006 | struct Tox_Options opts; | 1008 | struct Tox_Options opts; |
1007 | tox_options_default(&opts); | 1009 | tox_options_default(&opts); |
1008 | 1010 | ||
@@ -1040,8 +1042,8 @@ START_TEST(test_many_clients_tcp_b) | |||
1040 | 1042 | ||
1041 | for (i = 0; i < NUM_FRIENDS; ++i) { | 1043 | for (i = 0; i < NUM_FRIENDS; ++i) { |
1042 | loop_top: | 1044 | loop_top: |
1043 | pairs[i].tox1 = rand() % NUM_TOXES; | 1045 | pairs[i].tox1 = rand() % NUM_TOXES_TCP; |
1044 | pairs[i].tox2 = (pairs[i].tox1 + rand() % (NUM_TOXES - 1) + 1) % NUM_TOXES; | 1046 | pairs[i].tox2 = (pairs[i].tox1 + rand() % (NUM_TOXES_TCP - 1) + 1) % NUM_TOXES_TCP; |
1045 | 1047 | ||
1046 | for (j = 0; j < i; ++j) { | 1048 | for (j = 0; j < i; ++j) { |
1047 | if (pairs[j].tox2 == pairs[i].tox1 && pairs[j].tox1 == pairs[i].tox2) | 1049 | if (pairs[j].tox2 == pairs[i].tox1 && pairs[j].tox1 == pairs[i].tox2) |
@@ -1063,7 +1065,7 @@ loop_top: | |||
1063 | while (1) { | 1065 | while (1) { |
1064 | uint16_t counter = 0; | 1066 | uint16_t counter = 0; |
1065 | 1067 | ||
1066 | for (i = 0; i < NUM_TOXES; ++i) { | 1068 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
1067 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) | 1069 | for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j) |
1068 | if (tox_friend_get_connection_status(toxes[i], j, 0) == TOX_CONNECTION_TCP) | 1070 | if (tox_friend_get_connection_status(toxes[i], j, 0) == TOX_CONNECTION_TCP) |
1069 | ++counter; | 1071 | ++counter; |
@@ -1073,14 +1075,14 @@ loop_top: | |||
1073 | break; | 1075 | break; |
1074 | } | 1076 | } |
1075 | 1077 | ||
1076 | for (i = 0; i < NUM_TOXES; ++i) { | 1078 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
1077 | tox_iterate(toxes[i]); | 1079 | tox_iterate(toxes[i]); |
1078 | } | 1080 | } |
1079 | 1081 | ||
1080 | c_sleep(50); | 1082 | c_sleep(50); |
1081 | } | 1083 | } |
1082 | 1084 | ||
1083 | for (i = 0; i < NUM_TOXES; ++i) { | 1085 | for (i = 0; i < NUM_TOXES_TCP; ++i) { |
1084 | tox_kill(toxes[i]); | 1086 | tox_kill(toxes[i]); |
1085 | } | 1087 | } |
1086 | 1088 | ||
diff --git a/super_donators/grencez_tok5.c b/super_donators/grencez_tok5.c new file mode 100644 index 00000000..5c5be83c --- /dev/null +++ b/super_donators/grencez_tok5.c | |||
@@ -0,0 +1,41 @@ | |||
1 | /* Though it may look bleak at times, | ||
2 | * this ring will stabilize to have one token, | ||
3 | * and Tox will be the one true chat protocol! | ||
4 | * -- Alex P. Klinkhamer (grencez) | ||
5 | */ | ||
6 | #include <unistd.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <stdio.h> | ||
9 | int main(int i, char** msg) | ||
10 | { | ||
11 | int j, fd[4], xpd, xid; | ||
12 | if (--i<1) return 1; | ||
13 | srand(getpid()); | ||
14 | pipe(fd); | ||
15 | while (xid=rand()%5, --i>0) { | ||
16 | pipe(&fd[2]); | ||
17 | j = (0==fork() ? 0 : 1); | ||
18 | close(fd[j]); | ||
19 | fd[j] = fd[j+2]; | ||
20 | close(fd[3-j]); | ||
21 | if (j==0) break; | ||
22 | } | ||
23 | #define SendSc() write(fd[1], &xid, sizeof(xid)) | ||
24 | #define RecvPd() read(fd[0], &xpd, sizeof(xpd)) | ||
25 | #define A(g,v) if (g) {xid=v; puts(msg[i+1]); fflush(stdout); SendSc();} | ||
26 | SendSc(); | ||
27 | while (RecvPd(), 1) { | ||
28 | sleep(1); | ||
29 | if (i==0) { | ||
30 | A( xpd==0 && xid==0 , 1 ); | ||
31 | A( xpd==1 && xid<=1 , 2 ); | ||
32 | A( xpd> 1 && xid> 1 , 0 ); | ||
33 | continue; | ||
34 | } | ||
35 | A( xpd==0 && xid> 1 , xid/4 ); | ||
36 | A( xpd==1 && xid!=1 , 1 ); | ||
37 | A( xpd==2 && xid<=1 , 2+xid ); | ||
38 | A( xpd>=3 && xid<=1 , 4 ); | ||
39 | } | ||
40 | return 0; | ||
41 | } | ||
diff --git a/super_donators/sir@cmpwn.com b/super_donators/sir@cmpwn.com new file mode 100755 index 00000000..cfa989b0 --- /dev/null +++ b/super_donators/sir@cmpwn.com | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/bin/bash | ||
2 | # Run ./sir@cmpwn.com | ||
3 | # Arrow keys or wasd to move | ||
4 | |||
5 | c=`tput cols`;L=`tput lines` | ||
6 | let x=$c/2;let y=$L/2;d=0;le=3;t="$y;$x";i=0;j=0;S=0 | ||
7 | A(){ let i=($RANDOM%$c);let j=($RANDOM%$L);};A | ||
8 | B(){ printf $*;};C(){ B "\x1B[$1";};D(){ C "$1H";} | ||
9 | F(){ D "0;0";C 2J;C "?25h";printf "GAME OVER\nSCORE: $S\n";exit;};trap F INT | ||
10 | C ?25l;C 2J;da(){ D "$j;$i";echo "$1";} | ||
11 | G() { for n in $t; do D "$n";echo "$1";done;} | ||
12 | mt(){ t=`echo "$t"|cut -d' ' -f2-`;} | ||
13 | sc(){ D "0;0";echo "Score: $S"; } | ||
14 | gt() { t+=" $y;$x";};ct() { for n in $t; do [ "$y;$x" == "$n" ]&&F;done;} | ||
15 | M() { case $d in 0)let y--;;1)let x--;;2)let y++;;3)let x++;;esac | ||
16 | let x%=$c;let y%=$L;ct;[ "$y$x" == "$j$i" ]&&{ let le++;A;let S++;} | ||
17 | l=`tr -dc ' '<<<"$t"|wc -c`;gt;[ $l -gt $le ]&&mt;} | ||
18 | ky() { k=$1;read -sN1 -t 0.01 k1;read -sN1 -t 0.01 k2;read -sN1 -t 0.01 k3 | ||
19 | k+=${k1}${k2}${k3};case $k in w|$'\e[A'|$'\e0A')d=0;;a|$'\e[D'|$'\e0D')d=1;; | ||
20 | s|$'\e[B'|$'\e0B')d=2;;d|$'\e[C'|$'\e0C')d=3;;esac;} | ||
21 | while :;do da ' ';G ' ';M;da "@";G "#";sc;read -s -n 1 -t 0.1 k && ky "$k";done | ||
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 8609c6b6..61378fd0 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c | |||
@@ -477,10 +477,12 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t | |||
477 | 477 | ||
478 | Onion_Node *list_nodes = NULL; | 478 | Onion_Node *list_nodes = NULL; |
479 | uint8_t *reference_id = NULL; | 479 | uint8_t *reference_id = NULL; |
480 | unsigned int list_length; | ||
480 | 481 | ||
481 | if (num == 0) { | 482 | if (num == 0) { |
482 | list_nodes = onion_c->clients_announce_list; | 483 | list_nodes = onion_c->clients_announce_list; |
483 | reference_id = onion_c->c->self_public_key; | 484 | reference_id = onion_c->c->self_public_key; |
485 | list_length = MAX_ONION_CLIENTS_ANNOUNCE; | ||
484 | 486 | ||
485 | if (is_stored == 1 && memcmp(pingid_or_key, onion_c->temp_public_key, crypto_box_PUBLICKEYBYTES) != 0) { | 487 | if (is_stored == 1 && memcmp(pingid_or_key, onion_c->temp_public_key, crypto_box_PUBLICKEYBYTES) != 0) { |
486 | is_stored = 0; | 488 | is_stored = 0; |
@@ -492,10 +494,11 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t | |||
492 | 494 | ||
493 | list_nodes = onion_c->friends_list[num - 1].clients_list; | 495 | list_nodes = onion_c->friends_list[num - 1].clients_list; |
494 | reference_id = onion_c->friends_list[num - 1].real_public_key; | 496 | reference_id = onion_c->friends_list[num - 1].real_public_key; |
497 | list_length = MAX_ONION_CLIENTS; | ||
495 | } | 498 | } |
496 | 499 | ||
497 | memcpy(cmp_public_key, reference_id, crypto_box_PUBLICKEYBYTES); | 500 | memcpy(cmp_public_key, reference_id, crypto_box_PUBLICKEYBYTES); |
498 | qsort(list_nodes, MAX_ONION_CLIENTS, sizeof(Onion_Node), cmp_entry); | 501 | qsort(list_nodes, list_length, sizeof(Onion_Node), cmp_entry); |
499 | 502 | ||
500 | int index = -1, stored = 0; | 503 | int index = -1, stored = 0; |
501 | unsigned int i; | 504 | unsigned int i; |
@@ -505,7 +508,7 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t | |||
505 | index = 0; | 508 | index = 0; |
506 | } | 509 | } |
507 | 510 | ||
508 | for (i = 0; i < MAX_ONION_CLIENTS; ++i) { | 511 | for (i = 0; i < list_length; ++i) { |
509 | if (memcmp(list_nodes[i].public_key, public_key, crypto_box_PUBLICKEYBYTES) == 0) { | 512 | if (memcmp(list_nodes[i].public_key, public_key, crypto_box_PUBLICKEYBYTES) == 0) { |
510 | index = i; | 513 | index = i; |
511 | stored = 1; | 514 | stored = 1; |
@@ -565,6 +568,7 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, const Node_for | |||
565 | 568 | ||
566 | Onion_Node *list_nodes = NULL; | 569 | Onion_Node *list_nodes = NULL; |
567 | uint8_t *reference_id = NULL; | 570 | uint8_t *reference_id = NULL; |
571 | unsigned int list_length; | ||
568 | 572 | ||
569 | Last_Pinged *last_pinged = NULL; | 573 | Last_Pinged *last_pinged = NULL; |
570 | uint8_t *last_pinged_index = NULL; | 574 | uint8_t *last_pinged_index = NULL; |
@@ -572,11 +576,13 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, const Node_for | |||
572 | if (num == 0) { | 576 | if (num == 0) { |
573 | list_nodes = onion_c->clients_announce_list; | 577 | list_nodes = onion_c->clients_announce_list; |
574 | reference_id = onion_c->c->self_public_key; | 578 | reference_id = onion_c->c->self_public_key; |
579 | list_length = MAX_ONION_CLIENTS_ANNOUNCE; | ||
575 | last_pinged = onion_c->last_pinged; | 580 | last_pinged = onion_c->last_pinged; |
576 | last_pinged_index = &onion_c->last_pinged_index; | 581 | last_pinged_index = &onion_c->last_pinged_index; |
577 | } else { | 582 | } else { |
578 | list_nodes = onion_c->friends_list[num - 1].clients_list; | 583 | list_nodes = onion_c->friends_list[num - 1].clients_list; |
579 | reference_id = onion_c->friends_list[num - 1].real_public_key; | 584 | reference_id = onion_c->friends_list[num - 1].real_public_key; |
585 | list_length = MAX_ONION_CLIENTS; | ||
580 | last_pinged = onion_c->friends_list[num - 1].last_pinged; | 586 | last_pinged = onion_c->friends_list[num - 1].last_pinged; |
581 | last_pinged_index = &onion_c->friends_list[num - 1].last_pinged_index; | 587 | last_pinged_index = &onion_c->friends_list[num - 1].last_pinged_index; |
582 | } | 588 | } |
@@ -593,13 +599,13 @@ static int client_ping_nodes(Onion_Client *onion_c, uint32_t num, const Node_for | |||
593 | if (is_timeout(list_nodes[0].timestamp, ONION_NODE_TIMEOUT) | 599 | if (is_timeout(list_nodes[0].timestamp, ONION_NODE_TIMEOUT) |
594 | || id_closest(reference_id, list_nodes[0].public_key, nodes[i].public_key) == 2) { | 600 | || id_closest(reference_id, list_nodes[0].public_key, nodes[i].public_key) == 2) { |
595 | /* check if node is already in list. */ | 601 | /* check if node is already in list. */ |
596 | for (j = 0; j < MAX_ONION_CLIENTS; ++j) { | 602 | for (j = 0; j < list_length; ++j) { |
597 | if (memcmp(list_nodes[j].public_key, nodes[i].public_key, crypto_box_PUBLICKEYBYTES) == 0) { | 603 | if (memcmp(list_nodes[j].public_key, nodes[i].public_key, crypto_box_PUBLICKEYBYTES) == 0) { |
598 | break; | 604 | break; |
599 | } | 605 | } |
600 | } | 606 | } |
601 | 607 | ||
602 | if (j == MAX_ONION_CLIENTS && good_to_ping(last_pinged, last_pinged_index, nodes[i].public_key)) { | 608 | if (j == list_length && good_to_ping(last_pinged, last_pinged_index, nodes[i].public_key)) { |
603 | client_send_announce_request(onion_c, num, nodes[i].ip_port, nodes[i].public_key, NULL, ~0); | 609 | client_send_announce_request(onion_c, num, nodes[i].ip_port, nodes[i].public_key, NULL, ~0); |
604 | } | 610 | } |
605 | } | 611 | } |
@@ -1321,7 +1327,7 @@ static void do_announce(Onion_Client *onion_c) | |||
1321 | unsigned int i, count = 0; | 1327 | unsigned int i, count = 0; |
1322 | Onion_Node *list_nodes = onion_c->clients_announce_list; | 1328 | Onion_Node *list_nodes = onion_c->clients_announce_list; |
1323 | 1329 | ||
1324 | for (i = 0; i < MAX_ONION_CLIENTS; ++i) { | 1330 | for (i = 0; i < MAX_ONION_CLIENTS_ANNOUNCE; ++i) { |
1325 | if (is_timeout(list_nodes[i].timestamp, ONION_NODE_TIMEOUT)) | 1331 | if (is_timeout(list_nodes[i].timestamp, ONION_NODE_TIMEOUT)) |
1326 | continue; | 1332 | continue; |
1327 | 1333 | ||
@@ -1347,7 +1353,7 @@ static void do_announce(Onion_Client *onion_c) | |||
1347 | } | 1353 | } |
1348 | } | 1354 | } |
1349 | 1355 | ||
1350 | if (count != MAX_ONION_CLIENTS) { | 1356 | if (count != MAX_ONION_CLIENTS_ANNOUNCE) { |
1351 | unsigned int num_nodes; | 1357 | unsigned int num_nodes; |
1352 | Node_format *path_nodes; | 1358 | Node_format *path_nodes; |
1353 | 1359 | ||
@@ -1359,9 +1365,9 @@ static void do_announce(Onion_Client *onion_c) | |||
1359 | path_nodes = onion_c->path_nodes; | 1365 | path_nodes = onion_c->path_nodes; |
1360 | } | 1366 | } |
1361 | 1367 | ||
1362 | if (count < (uint32_t)rand() % MAX_ONION_CLIENTS) { | 1368 | if (count < (uint32_t)rand() % MAX_ONION_CLIENTS_ANNOUNCE) { |
1363 | if (num_nodes != 0) { | 1369 | if (num_nodes != 0) { |
1364 | for (i = 0; i < (MAX_ONION_CLIENTS / 2); ++i) { | 1370 | for (i = 0; i < (MAX_ONION_CLIENTS_ANNOUNCE / 2); ++i) { |
1365 | unsigned int num = rand() % num_nodes; | 1371 | unsigned int num = rand() % num_nodes; |
1366 | client_send_announce_request(onion_c, 0, path_nodes[num].ip_port, path_nodes[num].public_key, 0, ~0); | 1372 | client_send_announce_request(onion_c, 0, path_nodes[num].ip_port, path_nodes[num].public_key, 0, ~0); |
1367 | } | 1373 | } |
@@ -1383,7 +1389,7 @@ static int onion_isconnected(const Onion_Client *onion_c) | |||
1383 | if (onion_c->path_nodes_index == 0) | 1389 | if (onion_c->path_nodes_index == 0) |
1384 | return 0; | 1390 | return 0; |
1385 | 1391 | ||
1386 | for (i = 0; i < MAX_ONION_CLIENTS; ++i) { | 1392 | for (i = 0; i < MAX_ONION_CLIENTS_ANNOUNCE; ++i) { |
1387 | if (!is_timeout(onion_c->clients_announce_list[i].timestamp, ONION_NODE_TIMEOUT)) { | 1393 | if (!is_timeout(onion_c->clients_announce_list[i].timestamp, ONION_NODE_TIMEOUT)) { |
1388 | ++num; | 1394 | ++num; |
1389 | 1395 | ||
@@ -1395,8 +1401,8 @@ static int onion_isconnected(const Onion_Client *onion_c) | |||
1395 | 1401 | ||
1396 | unsigned int pnodes = onion_c->path_nodes_index; | 1402 | unsigned int pnodes = onion_c->path_nodes_index; |
1397 | 1403 | ||
1398 | if (pnodes > MAX_ONION_CLIENTS) { | 1404 | if (pnodes > MAX_ONION_CLIENTS_ANNOUNCE) { |
1399 | pnodes = MAX_ONION_CLIENTS; | 1405 | pnodes = MAX_ONION_CLIENTS_ANNOUNCE; |
1400 | } | 1406 | } |
1401 | 1407 | ||
1402 | /* Consider ourselves online if we are announced to half or more nodes | 1408 | /* Consider ourselves online if we are announced to half or more nodes |
diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h index 416d593a..91056a09 100644 --- a/toxcore/onion_client.h +++ b/toxcore/onion_client.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "ping_array.h" | 29 | #include "ping_array.h" |
30 | 30 | ||
31 | #define MAX_ONION_CLIENTS 8 | 31 | #define MAX_ONION_CLIENTS 8 |
32 | #define MAX_ONION_CLIENTS_ANNOUNCE 12 /* Number of nodes to announce ourselves to. */ | ||
32 | #define ONION_NODE_PING_INTERVAL 15 | 33 | #define ONION_NODE_PING_INTERVAL 15 |
33 | #define ONION_NODE_TIMEOUT (ONION_NODE_PING_INTERVAL * 3) | 34 | #define ONION_NODE_TIMEOUT (ONION_NODE_PING_INTERVAL * 3) |
34 | 35 | ||
@@ -130,7 +131,7 @@ typedef struct { | |||
130 | Onion_Friend *friends_list; | 131 | Onion_Friend *friends_list; |
131 | uint16_t num_friends; | 132 | uint16_t num_friends; |
132 | 133 | ||
133 | Onion_Node clients_announce_list[MAX_ONION_CLIENTS]; | 134 | Onion_Node clients_announce_list[MAX_ONION_CLIENTS_ANNOUNCE]; |
134 | 135 | ||
135 | Onion_Client_Paths onion_paths_self; | 136 | Onion_Client_Paths onion_paths_self; |
136 | Onion_Client_Paths onion_paths_friends; | 137 | Onion_Client_Paths onion_paths_friends; |