summaryrefslogtreecommitdiff
path: root/toxcore/onion_client.h
diff options
context:
space:
mode:
authordubslow <bunslow@gmail.com>2014-09-28 12:37:47 -0500
committerdubslow <bunslow@gmail.com>2014-09-28 12:37:47 -0500
commit57666d95bac5e070acda74020f5faca88cfa4bd5 (patch)
tree7dd17305a43ce332984034a1dec783d8e96ac780 /toxcore/onion_client.h
parent3711b881cb6f64cf08209f70216ec75672464d1a (diff)
parent72d6a92efd8cad191282c8a2e294a768c49d5f25 (diff)
Merge branch 'master' of https://github.com/irungentoo/toxcore
Diffstat (limited to 'toxcore/onion_client.h')
-rw-r--r--toxcore/onion_client.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h
index cf0975d3..483038e8 100644
--- a/toxcore/onion_client.h
+++ b/toxcore/onion_client.h
@@ -36,7 +36,7 @@
36#define ONION_FAKEID_INTERVAL 30 36#define ONION_FAKEID_INTERVAL 30
37#define DHT_FAKEID_INTERVAL 20 37#define DHT_FAKEID_INTERVAL 20
38 38
39#define NUMBER_ONION_PATHS 3 39#define NUMBER_ONION_PATHS 6
40 40
41/* The timeout the first time the path is added and 41/* The timeout the first time the path is added and
42 then for all the next consecutive times */ 42 then for all the next consecutive times */
@@ -79,7 +79,6 @@ typedef struct {
79 uint8_t is_online; /* Set by the onion_set_friend_status function. */ 79 uint8_t is_online; /* Set by the onion_set_friend_status function. */
80 80
81 uint8_t is_fake_clientid; /* 0 if we don't know the fake client id of the other 1 if we do. */ 81 uint8_t is_fake_clientid; /* 0 if we don't know the fake client id of the other 1 if we do. */
82 uint64_t fake_client_id_timestamp;
83 uint8_t fake_client_id[crypto_box_PUBLICKEYBYTES]; 82 uint8_t fake_client_id[crypto_box_PUBLICKEYBYTES];
84 uint8_t real_client_id[crypto_box_PUBLICKEYBYTES]; 83 uint8_t real_client_id[crypto_box_PUBLICKEYBYTES];
85 84
@@ -103,6 +102,10 @@ typedef struct {
103 void *tcp_relay_node_callback_object; 102 void *tcp_relay_node_callback_object;
104 uint32_t tcp_relay_node_callback_number; 103 uint32_t tcp_relay_node_callback_number;
105 104
105 void (*dht_pk_callback)(void *data, int32_t number, const uint8_t *dht_public_key);
106 void *dht_pk_callback_object;
107 uint32_t dht_pk_callback_number;
108
106 uint32_t run_count; 109 uint32_t run_count;
107} Onion_Friend; 110} Onion_Friend;
108 111
@@ -205,6 +208,18 @@ int onion_getfriendip(const Onion_Client *onion_c, int friend_num, IP_Port *ip_p
205int recv_tcp_relay_handler(Onion_Client *onion_c, int friend_num, int (*tcp_relay_node_callback)(void *object, 208int recv_tcp_relay_handler(Onion_Client *onion_c, int friend_num, int (*tcp_relay_node_callback)(void *object,
206 uint32_t number, IP_Port ip_port, const uint8_t *public_key), void *object, uint32_t number); 209 uint32_t number, IP_Port ip_port, const uint8_t *public_key), void *object, uint32_t number);
207 210
211
212/* Set the function for this friend that will be callbacked with object and number
213 * when that friend gives us his DHT temporary public key.
214 *
215 * object and number will be passed as argument to this function.
216 *
217 * return -1 on failure.
218 * return 0 on success.
219 */
220int onion_dht_pk_callback(Onion_Client *onion_c, int friend_num, void (*function)(void *data, int32_t number,
221 const uint8_t *dht_public_key), void *object, uint32_t number);
222
208/* Set a friends DHT public key. 223/* Set a friends DHT public key.
209 * timestamp is the time (current_time_monotonic()) at which the key was last confirmed belonging to 224 * timestamp is the time (current_time_monotonic()) at which the key was last confirmed belonging to
210 * the other peer. 225 * the other peer.
@@ -212,14 +227,14 @@ int recv_tcp_relay_handler(Onion_Client *onion_c, int friend_num, int (*tcp_rela
212 * return -1 on failure. 227 * return -1 on failure.
213 * return 0 on success. 228 * return 0 on success.
214 */ 229 */
215int onion_set_friend_DHT_pubkey(Onion_Client *onion_c, int friend_num, const uint8_t *dht_key, uint64_t timestamp); 230int onion_set_friend_DHT_pubkey(Onion_Client *onion_c, int friend_num, const uint8_t *dht_key);
216 231
217/* Copy friends DHT public key into dht_key. 232/* Copy friends DHT public key into dht_key.
218 * 233 *
219 * return 0 on failure (no key copied). 234 * return 0 on failure (no key copied).
220 * return timestamp on success (key copied). 235 * return 1 on success (key copied).
221 */ 236 */
222uint64_t onion_getfriend_DHT_pubkey(const Onion_Client *onion_c, int friend_num, uint8_t *dht_key); 237unsigned int onion_getfriend_DHT_pubkey(const Onion_Client *onion_c, int friend_num, uint8_t *dht_key);
223 238
224#define ONION_DATA_IN_RESPONSE_MIN_SIZE (crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES) 239#define ONION_DATA_IN_RESPONSE_MIN_SIZE (crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES)
225#define ONION_CLIENT_MAX_DATA_SIZE (MAX_DATA_REQUEST_SIZE - ONION_DATA_IN_RESPONSE_MIN_SIZE) 240#define ONION_CLIENT_MAX_DATA_SIZE (MAX_DATA_REQUEST_SIZE - ONION_DATA_IN_RESPONSE_MIN_SIZE)