summaryrefslogtreecommitdiff
path: root/toxcore/friend_connection.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/friend_connection.h')
-rw-r--r--toxcore/friend_connection.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/toxcore/friend_connection.h b/toxcore/friend_connection.h
index b814eb0c..60b62646 100644
--- a/toxcore/friend_connection.h
+++ b/toxcore/friend_connection.h
@@ -36,6 +36,7 @@
36#define GROUPCHAT_CALLBACK_INDEX 1 36#define GROUPCHAT_CALLBACK_INDEX 1
37 37
38#define PACKET_ID_ALIVE 16 38#define PACKET_ID_ALIVE 16
39#define PACKET_ID_SHARE_RELAYS 17
39#define PACKET_ID_FRIEND_REQUESTS 18 40#define PACKET_ID_FRIEND_REQUESTS 18
40 41
41/* Interval between the sending of ping packets. */ 42/* Interval between the sending of ping packets. */
@@ -47,6 +48,14 @@
47/* Time before friend is removed from the DHT after last hearing about him. */ 48/* Time before friend is removed from the DHT after last hearing about him. */
48#define FRIEND_DHT_TIMEOUT BAD_NODE_TIMEOUT 49#define FRIEND_DHT_TIMEOUT BAD_NODE_TIMEOUT
49 50
51#define FRIEND_MAX_STORED_TCP_RELAYS (MAX_FRIEND_TCP_CONNECTIONS * 4)
52
53/* Max number of tcp relays sent to friends */
54#define MAX_SHARED_RELAYS (RECOMMENDED_FRIEND_TCP_CONNECTIONS)
55
56/* Interval between the sending of tcp relay information */
57#define SHARE_RELAYS_INTERVAL (5 * 60)
58
50 59
51enum { 60enum {
52 FRIENDCONN_STATUS_NONE, 61 FRIENDCONN_STATUS_NONE,
@@ -61,12 +70,13 @@ typedef struct {
61 uint8_t dht_temp_pk[crypto_box_PUBLICKEYBYTES]; 70 uint8_t dht_temp_pk[crypto_box_PUBLICKEYBYTES];
62 uint16_t dht_lock; 71 uint16_t dht_lock;
63 IP_Port dht_ip_port; 72 IP_Port dht_ip_port;
64 uint64_t dht_ping_lastrecv, dht_ip_port_lastrecv; 73 uint64_t dht_pk_lastrecv, dht_ip_port_lastrecv;
65 74
66 int onion_friendnum; 75 int onion_friendnum;
67 int crypt_connection_id; 76 int crypt_connection_id;
68 77
69 uint64_t ping_lastrecv, ping_lastsent; 78 uint64_t ping_lastrecv, ping_lastsent;
79 uint64_t share_relays_lastsent;
70 80
71 struct { 81 struct {
72 int (*status_callback)(void *object, int id, uint8_t status); 82 int (*status_callback)(void *object, int id, uint8_t status);
@@ -83,6 +93,9 @@ typedef struct {
83 } callbacks[MAX_FRIEND_CONNECTION_CALLBACKS]; 93 } callbacks[MAX_FRIEND_CONNECTION_CALLBACKS];
84 94
85 uint16_t lock_count; 95 uint16_t lock_count;
96
97 Node_format tcp_relays[FRIEND_MAX_STORED_TCP_RELAYS];
98 uint16_t tcp_relay_counter;
86} Friend_Conn; 99} Friend_Conn;
87 100
88 101
@@ -127,6 +140,13 @@ int get_friendcon_public_keys(uint8_t *real_pk, uint8_t *dht_temp_pk, Friend_Con
127 */ 140 */
128void set_dht_temp_pk(Friend_Connections *fr_c, int friendcon_id, const uint8_t *dht_temp_pk); 141void set_dht_temp_pk(Friend_Connections *fr_c, int friendcon_id, const uint8_t *dht_temp_pk);
129 142
143/* Add a TCP relay associated to the friend.
144 *
145 * return -1 on failure.
146 * return 0 on success.
147 */
148int friend_add_tcp_relay(Friend_Connections *fr_c, int friendcon_id, IP_Port ip_port, const uint8_t *public_key);
149
130/* Set the callbacks for the friend connection. 150/* Set the callbacks for the friend connection.
131 * index is the index (0 to (MAX_FRIEND_CONNECTION_CALLBACKS - 1)) we want the callback to set in the array. 151 * index is the index (0 to (MAX_FRIEND_CONNECTION_CALLBACKS - 1)) we want the callback to set in the array.
132 * 152 *