reset hole-punching parameters after not punching for a while

This commit is contained in:
zugz 2017-08-05 20:25:33 +02:00
parent 7077662e32
commit 9e43d678fb

View File

@ -46,6 +46,9 @@
/* Interval in seconds between punching attempts*/
#define PUNCH_INTERVAL 3
/* Time in seconds after which punching parameters will be reset */
#define PUNCH_RESET_TIME 40
#define MAX_NORMAL_PUNCHING_TRIES 5
#define NAT_PING_REQUEST 0
@ -2129,6 +2132,12 @@ static void do_NAT(DHT *dht)
continue;
}
if (dht->friends_list[i].nat.punching_timestamp + PUNCH_RESET_TIME < temp_time) {
dht->friends_list[i].nat.tries = 0;
dht->friends_list[i].nat.punching_index = 0;
dht->friends_list[i].nat.punching_index2 = 0;
}
uint16_t port_list[MAX_FRIEND_CLIENTS];
uint16_t numports = NAT_getports(port_list, ip_list, num, ip);
punch_holes(dht, ip, port_list, numports, i);