diff options
Diffstat (limited to 'toxcore/onion_client.c')
-rw-r--r-- | toxcore/onion_client.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index ed328fb3..5db426d3 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 | } |