diff options
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index a5149a7c..685ce653 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -1309,7 +1309,6 @@ int accept_crypto_connection(Net_Crypto *c, New_Connection *n_c) | |||
1309 | if (create_send_handshake(c, crypt_connection_id, n_c->cookie) != 0) | 1309 | if (create_send_handshake(c, crypt_connection_id, n_c->cookie) != 0) |
1310 | return -1; | 1310 | return -1; |
1311 | 1311 | ||
1312 | send_temp_packet(c, crypt_connection_id); | ||
1313 | conn->status = CRYPTO_CONN_NOT_CONFIRMED; | 1312 | conn->status = CRYPTO_CONN_NOT_CONFIRMED; |
1314 | conn->packet_send_rate = CRYPTO_PACKET_MIN_RATE; | 1313 | conn->packet_send_rate = CRYPTO_PACKET_MIN_RATE; |
1315 | crypto_connection_add_source(c, crypt_connection_id, n_c->source); | 1314 | crypto_connection_add_source(c, crypt_connection_id, n_c->source); |
@@ -1651,18 +1650,23 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id) | |||
1651 | return wipe_crypto_connection(c, crypt_connection_id); | 1650 | return wipe_crypto_connection(c, crypt_connection_id); |
1652 | } | 1651 | } |
1653 | 1652 | ||
1654 | /* return 0 if no connection. | 1653 | /* return one of CRYPTO_CONN_* values indicating the state of the connection. |
1655 | * return 1 we have sent a handshake. | 1654 | * |
1656 | * return 2 if connection is not confirmed yet (we have received a handshake but no empty data packet). | 1655 | * sets direct_connected to 1 if connection connects directly to other, 0 if it isn't. |
1657 | * return 3 if the connection is established. | ||
1658 | * return 4 if the connection is timed out and waiting to be killed. | ||
1659 | */ | 1656 | */ |
1660 | int is_cryptoconnected(Net_Crypto *c, int crypt_connection_id) | 1657 | unsigned int crypto_connection_status(Net_Crypto *c, int crypt_connection_id, uint8_t *direct_connected) |
1661 | { | 1658 | { |
1662 | if ((unsigned int)crypt_connection_id < c->crypto_connections_length) | 1659 | Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); |
1663 | return c->crypto_connections[crypt_connection_id].status; | 1660 | |
1661 | if (conn == 0) | ||
1662 | return CRYPTO_CONN_NO_CONNECTION; | ||
1663 | |||
1664 | *direct_connected = 0; | ||
1665 | |||
1666 | if ((CRYPTO_SEND_PACKET_INTERVAL * MAX_NUM_SENDPACKET_TRIES + conn->direct_lastrecv_time) > current_time_monotonic()) | ||
1667 | *direct_connected = 1; | ||
1664 | 1668 | ||
1665 | return CRYPTO_CONN_NO_CONNECTION; | 1669 | return conn->status; |
1666 | } | 1670 | } |
1667 | 1671 | ||
1668 | void new_keys(Net_Crypto *c) | 1672 | void new_keys(Net_Crypto *c) |