Skip to content

Commit

Permalink
reset hole-punching parameters after not punching for a while
Browse files Browse the repository at this point in the history
  • Loading branch information
zugz committed Sep 17, 2017
1 parent 7077662 commit 9e43d67
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions toxcore/DHT.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9e43d67

Please sign in to comment.