summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authorGregory Mullen (grayhatter) <greg@grayhatter.com>2016-11-11 03:10:24 -0800
committerGregory Mullen (grayhatter) <greg@grayhatter.com>2016-11-24 17:38:34 -0800
commitad517eb1df8841db52a45c7ac9ecf5976a290d57 (patch)
tree6e0d82599a6c1b0fd819ecf84e4abc82aa41b02e /toxcore/DHT.c
parent19711d0fd0e2c181c3fe9df692b15f57390420d1 (diff)
add NAT hole punching level to Tox API
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 9a6996b2..5185353e 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -2088,6 +2088,10 @@ static uint16_t NAT_getports(uint16_t *portlist, IP_Port *ip_portlist, uint16_t
2088 2088
2089static void punch_holes(DHT *dht, IP ip, uint16_t *port_list, uint16_t numports, uint16_t friend_num) 2089static void punch_holes(DHT *dht, IP ip, uint16_t *port_list, uint16_t numports, uint16_t friend_num)
2090{ 2090{
2091 if (!dht->hole_punching_enabled) {
2092 return;
2093 }
2094
2091 if (numports > MAX_FRIEND_CLIENTS || numports == 0) { 2095 if (numports > MAX_FRIEND_CLIENTS || numports == 0) {
2092 return; 2096 return;
2093 } 2097 }
@@ -2577,7 +2581,7 @@ static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *pack
2577 2581
2578/*----------------------------------------------------------------------------------*/ 2582/*----------------------------------------------------------------------------------*/
2579 2583
2580DHT *new_DHT(Logger *log, Networking_Core *net) 2584DHT *new_DHT(Logger *log, Networking_Core *net, bool holepunching_enabled)
2581{ 2585{
2582 /* init time */ 2586 /* init time */
2583 unix_time_update(); 2587 unix_time_update();
@@ -2594,6 +2598,9 @@ DHT *new_DHT(Logger *log, Networking_Core *net)
2594 2598
2595 dht->log = log; 2599 dht->log = log;
2596 dht->net = net; 2600 dht->net = net;
2601
2602 dht->hole_punching_enabled = holepunching_enabled;
2603
2597 dht->ping = new_ping(dht); 2604 dht->ping = new_ping(dht);
2598 2605
2599 if (dht->ping == NULL) { 2606 if (dht->ping == NULL) {