diff options
author | zugz <mbays+tox@sdf.org> | 2017-08-05 20:25:33 +0200 |
---|---|---|
committer | zugz <mbays+tox@sdf.org> | 2017-09-17 20:27:37 +0200 |
commit | 9e43d678fb7e42526aa5ee2429efee4776dad69f (patch) | |
tree | 8bf143559be0fc9260217bd52ba11eb12a7f217a | |
parent | 7077662e328c79172a2e8503f1821a130b781a02 (diff) |
reset hole-punching parameters after not punching for a while
-rw-r--r-- | toxcore/DHT.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index a4b97fb8..4ebe7f33 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -46,6 +46,9 @@ | |||
46 | /* Interval in seconds between punching attempts*/ | 46 | /* Interval in seconds between punching attempts*/ |
47 | #define PUNCH_INTERVAL 3 | 47 | #define PUNCH_INTERVAL 3 |
48 | 48 | ||
49 | /* Time in seconds after which punching parameters will be reset */ | ||
50 | #define PUNCH_RESET_TIME 40 | ||
51 | |||
49 | #define MAX_NORMAL_PUNCHING_TRIES 5 | 52 | #define MAX_NORMAL_PUNCHING_TRIES 5 |
50 | 53 | ||
51 | #define NAT_PING_REQUEST 0 | 54 | #define NAT_PING_REQUEST 0 |
@@ -2129,6 +2132,12 @@ static void do_NAT(DHT *dht) | |||
2129 | continue; | 2132 | continue; |
2130 | } | 2133 | } |
2131 | 2134 | ||
2135 | if (dht->friends_list[i].nat.punching_timestamp + PUNCH_RESET_TIME < temp_time) { | ||
2136 | dht->friends_list[i].nat.tries = 0; | ||
2137 | dht->friends_list[i].nat.punching_index = 0; | ||
2138 | dht->friends_list[i].nat.punching_index2 = 0; | ||
2139 | } | ||
2140 | |||
2132 | uint16_t port_list[MAX_FRIEND_CLIENTS]; | 2141 | uint16_t port_list[MAX_FRIEND_CLIENTS]; |
2133 | uint16_t numports = NAT_getports(port_list, ip_list, num, ip); | 2142 | uint16_t numports = NAT_getports(port_list, ip_list, num, ip); |
2134 | punch_holes(dht, ip, port_list, numports, i); | 2143 | punch_holes(dht, ip, port_list, numports, i); |