summaryrefslogtreecommitdiff
path: root/toxcore/DHT.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/DHT.h')
-rw-r--r--toxcore/DHT.h58
1 files changed, 22 insertions, 36 deletions
diff --git a/toxcore/DHT.h b/toxcore/DHT.h
index 360773ff..9f70f423 100644
--- a/toxcore/DHT.h
+++ b/toxcore/DHT.h
@@ -35,19 +35,33 @@
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
46typedef struct { 41typedef struct {
42 /* Node routes request correctly (true (1) or false/didn't check (0)) */
43 uint8_t routes_requests_ok;
44 /* Time which we last checked this.*/
45 uint64_t routes_requests_timestamp;
46 uint8_t routes_requests_pingedid[CLIENT_ID_SIZE];
47 /* Node sends correct send_node (true (1) or false/didn't check (0)) */
48 uint8_t send_nodes_ok;
49 /* Time which we last checked this.*/
50 uint64_t send_nodes_timestamp;
51 uint8_t send_nodes_pingedid[CLIENT_ID_SIZE];
52 /* Node can be used to test other nodes (true (1) or false/didn't check (0)) */
53 uint8_t testing_requests;
54 /* Time which we last checked this.*/
55 uint64_t testing_timestamp;
56 uint8_t testing_pingedid[CLIENT_ID_SIZE];
57} Hardening;
58
59typedef struct {
47 IP_Port ip_port; 60 IP_Port ip_port;
48 uint64_t timestamp; 61 uint64_t timestamp;
49 uint64_t last_pinged; 62 uint64_t last_pinged;
50 63
64 Hardening hardening;
51 /* Returned by this node. Either our friend or us. */ 65 /* Returned by this node. Either our friend or us. */
52 IP_Port ret_ip_port; 66 IP_Port ret_ip_port;
53 uint64_t ret_timestamp; 67 uint64_t ret_timestamp;
@@ -55,11 +69,6 @@ typedef struct {
55 69
56typedef struct { 70typedef struct {
57 uint8_t client_id[CLIENT_ID_SIZE]; 71 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; 72 IPPTsPng assoc4;
64 IPPTsPng assoc6; 73 IPPTsPng assoc6;
65} Client_data; 74} Client_data;
@@ -78,17 +87,6 @@ typedef struct {
78 87
79typedef struct { 88typedef struct {
80 uint8_t client_id[CLIENT_ID_SIZE]; 89 uint8_t client_id[CLIENT_ID_SIZE];
81 Client_data_old client_list[MAX_FRIEND_CLIENTS];
82
83 /* Time at which the last get_nodes request was sent. */
84 uint64_t lastgetnode;
85
86 /* Symetric NAT hole punching stuff. */
87 NAT nat;
88} DHT_Friend_old; /* required to load old state files */
89
90typedef struct {
91 uint8_t client_id[CLIENT_ID_SIZE];
92 Client_data client_list[MAX_FRIEND_CLIENTS]; 90 Client_data client_list[MAX_FRIEND_CLIENTS];
93 91
94 /* Time at which the last get_nodes request was sent. */ 92 /* Time at which the last get_nodes request was sent. */
@@ -111,11 +109,6 @@ typedef struct {
111 109
112/*----------------------------------------------------------------------------------*/ 110/*----------------------------------------------------------------------------------*/
113 111
114typedef struct {
115 IP_Port ip_port;
116 uint64_t id;
117 uint64_t timestamp;
118} pinged_t;
119 112
120typedef struct { 113typedef struct {
121 Net_Crypto *c; 114 Net_Crypto *c;
@@ -125,8 +118,10 @@ typedef struct {
125 uint16_t num_friends; 118 uint16_t num_friends;
126 uint64_t close_lastgetnodes; 119 uint64_t close_lastgetnodes;
127 120
128 pinged_t send_nodes[LSEND_NODES_ARRAY];
129 void *ping; 121 void *ping;
122
123 /* Note: this key should not be/is not used to transmit any sensitive materials */
124 uint8_t secret_symmetric_key[crypto_secretbox_KEYBYTES];
130} DHT; 125} DHT;
131/*----------------------------------------------------------------------------------*/ 126/*----------------------------------------------------------------------------------*/
132 127
@@ -240,15 +235,6 @@ DHT *new_DHT(Net_Crypto *c);
240 235
241void kill_DHT(DHT *dht); 236void kill_DHT(DHT *dht);
242 237
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. 238/* return 0 if we are not connected to the DHT.
253 * return 1 if we are. 239 * return 1 if we are.
254 */ 240 */