diff options
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 744bc754..8f3a6be1 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -446,10 +446,10 @@ int realloc_cryptoconnection(Net_Crypto *c, uint32_t num) | |||
446 | int crypto_connect(Net_Crypto *c, uint8_t *public_key, IP_Port ip_port) | 446 | int crypto_connect(Net_Crypto *c, uint8_t *public_key, IP_Port ip_port) |
447 | { | 447 | { |
448 | uint32_t i; | 448 | uint32_t i; |
449 | int id = getcryptconnection_id(c, public_key); | 449 | int id_existing = getcryptconnection_id(c, public_key); |
450 | 450 | ||
451 | if (id != -1) { | 451 | if (id_existing != -1) { |
452 | IP_Port c_ip = connection_ip(c->lossless_udp, c->crypto_connections[id].number); | 452 | IP_Port c_ip = connection_ip(c->lossless_udp, c->crypto_connections[id_existing].number); |
453 | 453 | ||
454 | if (ipport_equal(&c_ip, &ip_port)) | 454 | if (ipport_equal(&c_ip, &ip_port)) |
455 | return -1; | 455 | return -1; |
@@ -464,12 +464,12 @@ int crypto_connect(Net_Crypto *c, uint8_t *public_key, IP_Port ip_port) | |||
464 | 464 | ||
465 | for (i = 0; i <= c->crypto_connections_length; ++i) { | 465 | for (i = 0; i <= c->crypto_connections_length; ++i) { |
466 | if (c->crypto_connections[i].status == CONN_NO_CONNECTION) { | 466 | if (c->crypto_connections[i].status == CONN_NO_CONNECTION) { |
467 | int id = new_connection(c->lossless_udp, ip_port); | 467 | int id_new = new_connection(c->lossless_udp, ip_port); |
468 | 468 | ||
469 | if (id == -1) | 469 | if (id_new == -1) |
470 | return -1; | 470 | return -1; |
471 | 471 | ||
472 | c->crypto_connections[i].number = id; | 472 | c->crypto_connections[i].number = id_new; |
473 | c->crypto_connections[i].status = CONN_HANDSHAKE_SENT; | 473 | c->crypto_connections[i].status = CONN_HANDSHAKE_SENT; |
474 | random_nonce(c->crypto_connections[i].recv_nonce); | 474 | random_nonce(c->crypto_connections[i].recv_nonce); |
475 | memcpy(c->crypto_connections[i].public_key, public_key, crypto_box_PUBLICKEYBYTES); | 475 | memcpy(c->crypto_connections[i].public_key, public_key, crypto_box_PUBLICKEYBYTES); |
@@ -478,7 +478,7 @@ int crypto_connect(Net_Crypto *c, uint8_t *public_key, IP_Port ip_port) | |||
478 | if (c->crypto_connections_length == i) | 478 | if (c->crypto_connections_length == i) |
479 | ++c->crypto_connections_length; | 479 | ++c->crypto_connections_length; |
480 | 480 | ||
481 | if (send_cryptohandshake(c, id, public_key, c->crypto_connections[i].recv_nonce, | 481 | if (send_cryptohandshake(c, id_new, public_key, c->crypto_connections[i].recv_nonce, |
482 | c->crypto_connections[i].sessionpublic_key) == 1) { | 482 | c->crypto_connections[i].sessionpublic_key) == 1) { |
483 | increment_nonce(c->crypto_connections[i].recv_nonce); | 483 | increment_nonce(c->crypto_connections[i].recv_nonce); |
484 | return i; | 484 | return i; |