From 147d820ad2439b14394ae863466458d0736f6406 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sat, 19 Oct 2013 22:29:48 -0400 Subject: [PATCH] Fixed connection sometimes being too slow and some other possible problems. --- toxcore/net_crypto.c | 9 ++++++++- toxcore/net_crypto.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 3049776f..b7e3ced7 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -704,10 +704,17 @@ static void receive_crypto(Net_Crypto *c) CONN_ESTABLISHED; /* Connection status needs to be 3 for write_cryptpacket() to work. */ write_cryptpacket(c, i, ((uint8_t *)&zero), sizeof(zero)); c->crypto_connections[i].status = CONN_NOT_CONFIRMED; /* Set it to its proper value right after. */ + } else { + /* This should not happen, timeout the connection if it does. */ + c->crypto_connections[i].status = CONN_TIMED_OUT; } + } else { + /* This should not happen, timeout the connection if it does. */ + c->crypto_connections[i].status = CONN_TIMED_OUT; } } else if (id_packet(c->lossless_udp, - c->crypto_connections[i].number) != -1) { // This should not happen, timeout the connection if it does. + c->crypto_connections[i].number) != -1) { + /* This should not happen, timeout the connection if it does. */ c->crypto_connections[i].status = CONN_TIMED_OUT; } } diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index 0c1bffe6..0ddb711a 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h @@ -28,7 +28,7 @@ #define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */ #define CRYPTO_PACKET_NAT_PING 254 /* NAT ping crypto packet ID. */ -#define CRYPTO_HANDSHAKE_TIMEOUT CONNEXION_TIMEOUT +#define CRYPTO_HANDSHAKE_TIMEOUT (CONNEXION_TIMEOUT * 2) typedef struct { uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* The real public key of the peer. */