Less packet spam.

pull/1499/head
irungentoo 2015-12-16 14:26:40 -05:00
parent c1e00c5d39
commit 97ba2f7640
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 8 additions and 2 deletions

View File

@ -490,9 +490,14 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t
}
//TODO: a better way of sending packets directly to confirm the others ip.
if (length < 96 || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) {
if ((uint32_t)sendpacket(c->dht->net, ip_port, data, length) == length)
uint64_t current_time = unix_time();
if ((((UDP_DIRECT_TIMEOUT / 2) + conn->direct_send_attempt_time) > current_time && length < 96)
|| data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) {
if ((uint32_t)sendpacket(c->dht->net, ip_port, data, length) == length) {
direct_send_attempt = 1;
conn->direct_send_attempt_time = unix_time();
}
}
}

View File

@ -143,6 +143,7 @@ typedef struct {
int connection_lossy_data_callback_id;
uint64_t last_request_packet_sent;
uint64_t direct_send_attempt_time;
uint32_t packet_counter;
double packet_recv_rate;