summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toxcore/DHT.c12
-rw-r--r--toxcore/DHT.h22
-rw-r--r--toxcore/net_crypto.h1
3 files changed, 30 insertions, 5 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 7c3894b3..661ac98a 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -1552,6 +1552,16 @@ static void do_NAT(DHT *dht)
1552/*----------------------------------------------------------------------------------*/ 1552/*----------------------------------------------------------------------------------*/
1553/*-----------------------END OF NAT PUNCHING FUNCTIONS------------------------------*/ 1553/*-----------------------END OF NAT PUNCHING FUNCTIONS------------------------------*/
1554 1554
1555
1556/* Handle a received ping request for. */
1557static int handle_hardening(void *object, IP_Port source, uint8_t *source_pubkey, uint8_t *packet, uint32_t length)
1558{
1559 DHT *dht = object;
1560 return 0;/* success*/
1561}
1562
1563/*----------------------------------------------------------------------------------*/
1564
1555DHT *new_DHT(Net_Crypto *c) 1565DHT *new_DHT(Net_Crypto *c)
1556{ 1566{
1557 if (c == NULL) 1567 if (c == NULL)
@@ -1575,6 +1585,8 @@ DHT *new_DHT(Net_Crypto *c)
1575 networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES_IPV6, &handle_sendnodes_ipv6, dht); 1585 networking_registerhandler(c->lossless_udp->net, NET_PACKET_SEND_NODES_IPV6, &handle_sendnodes_ipv6, dht);
1576 init_cryptopackets(dht); 1586 init_cryptopackets(dht);
1577 cryptopacket_registerhandler(c, CRYPTO_PACKET_NAT_PING, &handle_NATping, dht); 1587 cryptopacket_registerhandler(c, CRYPTO_PACKET_NAT_PING, &handle_NATping, dht);
1588 cryptopacket_registerhandler(c, CRYPTO_PACKET_HARDENING, &handle_hardening, dht);
1589
1578 new_symmetric_key(dht->secret_symmetric_key); 1590 new_symmetric_key(dht->secret_symmetric_key);
1579 return dht; 1591 return dht;
1580} 1592}
diff --git a/toxcore/DHT.h b/toxcore/DHT.h
index b60f744b..b3ab5f89 100644
--- a/toxcore/DHT.h
+++ b/toxcore/DHT.h
@@ -35,11 +35,6 @@
35/* A list of the clients mathematically closest to ours. */ 35/* A list of the clients mathematically closest to ours. */
36#define LCLIENT_LIST 32 36#define LCLIENT_LIST 32
37 37
38/* The list of ip ports along with the ping_id of what we sent them and a timestamp. */
39#define LPING_ARRAY 256 // NOTE: Deprecated (doesn't do anything).
40
41#define LSEND_NODES_ARRAY LPING_ARRAY/2
42
43/* Maximum newly announced nodes to ping per TIME_TOPING seconds. */ 38/* Maximum newly announced nodes to ping per TIME_TOPING seconds. */
44#define MAX_TOPING 16 39#define MAX_TOPING 16
45 40
@@ -77,12 +72,28 @@ typedef struct {
77} NAT; 72} NAT;
78 73
79typedef struct { 74typedef struct {
75 /* Node routes request correctly (true (1) or false/didn't check (0)) */
76 uint8_t routes_requests_ok;
77 /* Time which we last checked this.*/
78 uint64_t routes_requests_timestamp;
79 /* Node sends correct send_node (true (1) or false/didn't check (0)) */
80 uint8_t send_nodes_ok;
81 /* Time which we last checked this.*/
82 uint64_t send_nodes_timestamp;
83 /* Node can be used to test other nodes (true (1) or false/didn't check (0)) */
84 uint8_t testing_requests;
85 /* Time which we last checked this.*/
86 uint64_t testing_timestamp;
87} Hardening;
88
89typedef struct {
80 uint8_t client_id[CLIENT_ID_SIZE]; 90 uint8_t client_id[CLIENT_ID_SIZE];
81 Client_data_old client_list[MAX_FRIEND_CLIENTS]; 91 Client_data_old client_list[MAX_FRIEND_CLIENTS];
82 92
83 /* Time at which the last get_nodes request was sent. */ 93 /* Time at which the last get_nodes request was sent. */
84 uint64_t lastgetnode; 94 uint64_t lastgetnode;
85 95
96 Hardening hardening;
86 /* Symetric NAT hole punching stuff. */ 97 /* Symetric NAT hole punching stuff. */
87 NAT nat; 98 NAT nat;
88} DHT_Friend_old; /* required to load old state files */ 99} DHT_Friend_old; /* required to load old state files */
@@ -94,6 +105,7 @@ typedef struct {
94 /* Time at which the last get_nodes request was sent. */ 105 /* Time at which the last get_nodes request was sent. */
95 uint64_t lastgetnode; 106 uint64_t lastgetnode;
96 107
108 Hardening hardening;
97 /* Symetric NAT hole punching stuff. */ 109 /* Symetric NAT hole punching stuff. */
98 NAT nat; 110 NAT nat;
99} DHT_Friend; 111} DHT_Friend;
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h
index f44bae6c..38400ebc 100644
--- a/toxcore/net_crypto.h
+++ b/toxcore/net_crypto.h
@@ -27,6 +27,7 @@
27#include "Lossless_UDP.h" 27#include "Lossless_UDP.h"
28 28
29#define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */ 29#define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */
30#define CRYPTO_PACKET_HARDENING 48 /* Hardening crypto packet ID. */
30#define CRYPTO_PACKET_NAT_PING 254 /* NAT ping crypto packet ID. */ 31#define CRYPTO_PACKET_NAT_PING 254 /* NAT ping crypto packet ID. */
31#define CRYPTO_HANDSHAKE_TIMEOUT (CONNECTION_TIMEOUT * 2) 32#define CRYPTO_HANDSHAKE_TIMEOUT (CONNECTION_TIMEOUT * 2)
32 33