diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 222bf3e4..51d5c73b 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -96,7 +96,7 @@ enum { #define FRIEND_SHARE_RELAYS_INTERVAL (5 * 60) /* If no packets are received from friend in this time interval, kill the connection. */ -#define FRIEND_CONNECTION_TIMEOUT (FRIEND_PING_INTERVAL * 2) +#define FRIEND_CONNECTION_TIMEOUT (FRIEND_PING_INTERVAL * 3) /* USERSTATUS - diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index b29184e2..033f494b 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -2427,7 +2427,7 @@ unsigned int crypto_connection_status(Net_Crypto *c, int crypt_connection_id, ui *direct_connected = 0; - if ((CRYPTO_SEND_PACKET_INTERVAL * MAX_NUM_SENDPACKET_TRIES + conn->direct_lastrecv_time) > current_time_monotonic()) + if ((UDP_DIRECT_TIMEOUT + conn->direct_lastrecv_time) > current_time_monotonic()) *direct_connected = 1; return conn->status; diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index 054dbb5d..ebbfb8d3 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h @@ -55,6 +55,9 @@ before giving up. */ #define MAX_NUM_SENDPACKET_TRIES 8 +/* The timeout of no recieved UDP packets before the direct UDP connection is considered dead. */ +#define UDP_DIRECT_TIMEOUT (MAX_NUM_SENDPACKET_TRIES * CRYPTO_SEND_PACKET_INTERVAL * 2) + #define PACKET_ID_PADDING 0 #define PACKET_ID_REQUEST 1 #define PACKET_ID_KILL 2