summaryrefslogtreecommitdiff
path: root/toxcore/onion_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/onion_client.c')
-rw-r--r--toxcore/onion_client.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c
index ed328fb3..6575f632 100644
--- a/toxcore/onion_client.c
+++ b/toxcore/onion_client.c
@@ -190,7 +190,7 @@ static int is_path_used(const Onion_Client_Paths *onion_paths, const Node_format
190 continue; 190 continue;
191 } 191 }
192 192
193 if (ipport_equal(&onion_paths->paths[i].ip_port1, &nodes[2].ip_port)) { 193 if (ipport_equal(&onion_paths->paths[i].ip_port1, &nodes[ONION_PATH_LENGTH - 1].ip_port)) {
194 return i; 194 return i;
195 } 195 }
196 } 196 }
@@ -215,9 +215,9 @@ static int random_path(const Onion_Client *onion_c, Onion_Client_Paths *onion_pa
215 if ((onion_paths->last_path_success[pathnum] + ONION_PATH_TIMEOUT < onion_paths->last_path_used[pathnum] 215 if ((onion_paths->last_path_success[pathnum] + ONION_PATH_TIMEOUT < onion_paths->last_path_used[pathnum]
216 && onion_paths->last_path_used_times[pathnum] >= ONION_PATH_MAX_NO_RESPONSE_USES) 216 && onion_paths->last_path_used_times[pathnum] >= ONION_PATH_MAX_NO_RESPONSE_USES)
217 || is_timeout(onion_paths->path_creation_time[pathnum], ONION_PATH_MAX_LIFETIME)) { 217 || is_timeout(onion_paths->path_creation_time[pathnum], ONION_PATH_MAX_LIFETIME)) {
218 Node_format nodes[3]; 218 Node_format nodes[ONION_PATH_LENGTH];
219 219
220 if (random_nodes_path_onion(onion_c, nodes, 3) != 3) 220 if (random_nodes_path_onion(onion_c, nodes, ONION_PATH_LENGTH) != ONION_PATH_LENGTH)
221 return -1; 221 return -1;
222 222
223 int n = is_path_used(onion_paths, nodes); 223 int n = is_path_used(onion_paths, nodes);
@@ -267,13 +267,12 @@ static uint32_t set_path_timeouts(Onion_Client *onion_c, uint32_t num, uint32_t
267 onion_paths->last_path_success[path_num % NUMBER_ONION_PATHS] = unix_time(); 267 onion_paths->last_path_success[path_num % NUMBER_ONION_PATHS] = unix_time();
268 onion_paths->last_path_used_times[path_num % NUMBER_ONION_PATHS] = 0; 268 onion_paths->last_path_used_times[path_num % NUMBER_ONION_PATHS] = 0;
269 269
270 unsigned int path_len = 3; 270 Node_format nodes[ONION_PATH_LENGTH];
271 Node_format nodes[path_len];
272 271
273 if (onion_path_to_nodes(nodes, path_len, &onion_paths->paths[path_num % NUMBER_ONION_PATHS]) == 0) { 272 if (onion_path_to_nodes(nodes, ONION_PATH_LENGTH, &onion_paths->paths[path_num % NUMBER_ONION_PATHS]) == 0) {
274 unsigned int i; 273 unsigned int i;
275 274
276 for (i = 0; i < path_len; ++i) { 275 for (i = 0; i < ONION_PATH_LENGTH; ++i) {
277 onion_add_path_node(onion_c, nodes[i].ip_port, nodes[i].public_key); 276 onion_add_path_node(onion_c, nodes[i].ip_port, nodes[i].public_key);
278 } 277 }
279 } 278 }
@@ -1205,7 +1204,7 @@ static void populate_path_nodes_tcp(Onion_Client *onion_c)
1205 unsigned int i; 1204 unsigned int i;
1206 1205
1207 for (i = 0; i < num_nodes; ++i) { 1206 for (i = 0; i < num_nodes; ++i) {
1208 onion_add_path_node(onion_c, nodes_list[i].ip_port, nodes_list[i].public_key); 1207 onion_add_bs_path_node(onion_c, nodes_list[i].ip_port, nodes_list[i].public_key);
1209 } 1208 }
1210} 1209}
1211 1210