summaryrefslogtreecommitdiff
path: root/toxcore/DHT.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/DHT.h')
-rw-r--r--toxcore/DHT.h51
1 files changed, 17 insertions, 34 deletions
diff --git a/toxcore/DHT.h b/toxcore/DHT.h
index 360773ff..ac02710f 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
@@ -55,11 +50,6 @@ typedef struct {
55 50
56typedef struct { 51typedef struct {
57 uint8_t client_id[CLIENT_ID_SIZE]; 52 uint8_t client_id[CLIENT_ID_SIZE];
58 IPPTsPng assoc;
59} Client_data_old; /* required to load old state files */
60
61typedef struct {
62 uint8_t client_id[CLIENT_ID_SIZE];
63 IPPTsPng assoc4; 53 IPPTsPng assoc4;
64 IPPTsPng assoc6; 54 IPPTsPng assoc6;
65} Client_data; 55} Client_data;
@@ -77,15 +67,19 @@ typedef struct {
77} NAT; 67} NAT;
78 68
79typedef struct { 69typedef struct {
80 uint8_t client_id[CLIENT_ID_SIZE]; 70 /* Node routes request correctly (true (1) or false/didn't check (0)) */
81 Client_data_old client_list[MAX_FRIEND_CLIENTS]; 71 uint8_t routes_requests_ok;
82 72 /* Time which we last checked this.*/
83 /* Time at which the last get_nodes request was sent. */ 73 uint64_t routes_requests_timestamp;
84 uint64_t lastgetnode; 74 /* Node sends correct send_node (true (1) or false/didn't check (0)) */
85 75 uint8_t send_nodes_ok;
86 /* Symetric NAT hole punching stuff. */ 76 /* Time which we last checked this.*/
87 NAT nat; 77 uint64_t send_nodes_timestamp;
88} DHT_Friend_old; /* required to load old state files */ 78 /* Node can be used to test other nodes (true (1) or false/didn't check (0)) */
79 uint8_t testing_requests;
80 /* Time which we last checked this.*/
81 uint64_t testing_timestamp;
82} Hardening;
89 83
90typedef struct { 84typedef struct {
91 uint8_t client_id[CLIENT_ID_SIZE]; 85 uint8_t client_id[CLIENT_ID_SIZE];
@@ -94,6 +88,7 @@ typedef struct {
94 /* Time at which the last get_nodes request was sent. */ 88 /* Time at which the last get_nodes request was sent. */
95 uint64_t lastgetnode; 89 uint64_t lastgetnode;
96 90
91 Hardening hardening;
97 /* Symetric NAT hole punching stuff. */ 92 /* Symetric NAT hole punching stuff. */
98 NAT nat; 93 NAT nat;
99} DHT_Friend; 94} DHT_Friend;
@@ -111,11 +106,6 @@ typedef struct {
111 106
112/*----------------------------------------------------------------------------------*/ 107/*----------------------------------------------------------------------------------*/
113 108
114typedef struct {
115 IP_Port ip_port;
116 uint64_t id;
117 uint64_t timestamp;
118} pinged_t;
119 109
120typedef struct { 110typedef struct {
121 Net_Crypto *c; 111 Net_Crypto *c;
@@ -125,8 +115,10 @@ typedef struct {
125 uint16_t num_friends; 115 uint16_t num_friends;
126 uint64_t close_lastgetnodes; 116 uint64_t close_lastgetnodes;
127 117
128 pinged_t send_nodes[LSEND_NODES_ARRAY];
129 void *ping; 118 void *ping;
119
120 /* Note: this key should not be/is not used to transmit any sensitive materials */
121 uint8_t secret_symmetric_key[crypto_secretbox_KEYBYTES];
130} DHT; 122} DHT;
131/*----------------------------------------------------------------------------------*/ 123/*----------------------------------------------------------------------------------*/
132 124
@@ -240,15 +232,6 @@ DHT *new_DHT(Net_Crypto *c);
240 232
241void kill_DHT(DHT *dht); 233void kill_DHT(DHT *dht);
242 234
243/* Load the DHT from data of size size.
244 * old/new: version of config file
245 *
246 * return -1 if failure.
247 * return 0 if success.
248 */
249int DHT_load_old(DHT *dht, uint8_t *data, uint32_t size);
250int DHT_load_new(DHT *dht, uint8_t *data, uint32_t size);
251
252/* return 0 if we are not connected to the DHT. 235/* return 0 if we are not connected to the DHT.
253 * return 1 if we are. 236 * return 1 if we are.
254 */ 237 */