diff options
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index d74f0bf5..43468b73 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -1634,10 +1634,12 @@ int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key, const u | |||
1634 | 1634 | ||
1635 | /* Set the direct ip of the crypto connection. | 1635 | /* Set the direct ip of the crypto connection. |
1636 | * | 1636 | * |
1637 | * Connected is 0 if we are not sure we are connected to that person, 1 if we are sure. | ||
1638 | * | ||
1637 | * return -1 on failure. | 1639 | * return -1 on failure. |
1638 | * return 0 on success. | 1640 | * return 0 on success. |
1639 | */ | 1641 | */ |
1640 | int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port) | 1642 | int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port, _Bool connected) |
1641 | { | 1643 | { |
1642 | Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); | 1644 | Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id); |
1643 | 1645 | ||
@@ -1661,7 +1663,13 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port) | |||
1661 | if (bs_list_add(&c->ip_port_list, (uint8_t *)&ip_port, crypt_connection_id)) { | 1663 | if (bs_list_add(&c->ip_port_list, (uint8_t *)&ip_port, crypt_connection_id)) { |
1662 | bs_list_remove(&c->ip_port_list, (uint8_t *)&conn->ip_port, crypt_connection_id); | 1664 | bs_list_remove(&c->ip_port_list, (uint8_t *)&conn->ip_port, crypt_connection_id); |
1663 | conn->ip_port = ip_port; | 1665 | conn->ip_port = ip_port; |
1664 | conn->direct_lastrecv_time = 0; | 1666 | |
1667 | if (connected) { | ||
1668 | conn->direct_lastrecv_time = unix_time(); | ||
1669 | } else { | ||
1670 | conn->direct_lastrecv_time = 0; | ||
1671 | } | ||
1672 | |||
1665 | return 0; | 1673 | return 0; |
1666 | } | 1674 | } |
1667 | } | 1675 | } |