summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-12-16 14:26:40 -0500
committerirungentoo <irungentoo@gmail.com>2015-12-16 14:26:40 -0500
commit97ba2f7640cc14e2cda3d38dda470e5940327958 (patch)
tree08db36c8015a8e223e2c37d47af1803dac8c7168 /toxcore/net_crypto.c
parentc1e00c5d3940fc590d099692b848a106c28633ad (diff)
Less packet spam.
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r--toxcore/net_crypto.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index 03b84ecd..f6234a08 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -490,9 +490,14 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t
490 } 490 }
491 491
492 //TODO: a better way of sending packets directly to confirm the others ip. 492 //TODO: a better way of sending packets directly to confirm the others ip.
493 if (length < 96 || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) { 493 uint64_t current_time = unix_time();
494 if ((uint32_t)sendpacket(c->dht->net, ip_port, data, length) == length) 494
495 if ((((UDP_DIRECT_TIMEOUT / 2) + conn->direct_send_attempt_time) > current_time && length < 96)
496 || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) {
497 if ((uint32_t)sendpacket(c->dht->net, ip_port, data, length) == length) {
495 direct_send_attempt = 1; 498 direct_send_attempt = 1;
499 conn->direct_send_attempt_time = unix_time();
500 }
496 } 501 }
497 } 502 }
498 503