From 993f3bfa51bf7e5e6dbaced304aae9afce2600d9 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Thu, 8 Jan 2015 21:23:37 -0500 Subject: [PATCH] Speed up connection to network on TCP only. Assume nodes we manage to connect to with TCP are good to use for the onion. --- toxcore/onion_client.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 9153216d6..b02b7c240 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c @@ -1188,6 +1188,18 @@ static void populate_path_nodes(Onion_Client *onion_c) } } +static void populate_path_nodes_tcp(Onion_Client *onion_c) +{ + Node_format nodes_list[MAX_SENT_NODES]; + + unsigned int num_nodes = copy_connected_tcp_relays(onion_c->c, nodes_list, MAX_SENT_NODES);; + unsigned int i; + + for (i = 0; i < num_nodes; ++i) { + onion_add_path_node(onion_c, nodes_list[i].ip_port, nodes_list[i].client_id); + } +} + #define ANNOUNCE_FRIEND (ONION_NODE_PING_INTERVAL * 6) #define ANNOUNCE_FRIEND_BEGINNING 3 #define FRIEND_ONION_NODE_TIMEOUT (ONION_NODE_TIMEOUT * 6) @@ -1345,6 +1357,8 @@ void do_onion_client(Onion_Client *onion_c) for (i = 0; i < onion_c->num_friends; ++i) { do_friend(onion_c, i); } + } else { + populate_path_nodes_tcp(onion_c); } onion_c->last_run = unix_time();