diff options
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 472c2ae4..f53a1d04 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -195,6 +195,21 @@ void getaddress(Messenger *m, uint8_t *address) | |||
195 | memcpy(address + crypto_box_PUBLICKEYBYTES + sizeof(nospam), &checksum, sizeof(checksum)); | 195 | memcpy(address + crypto_box_PUBLICKEYBYTES + sizeof(nospam), &checksum, sizeof(checksum)); |
196 | } | 196 | } |
197 | 197 | ||
198 | /* callback for recv TCP relay nodes. */ | ||
199 | static int tcp_relay_node_callback(void *object, uint32_t number, IP_Port ip_port, uint8_t *public_key) | ||
200 | { | ||
201 | Messenger *m = object; | ||
202 | |||
203 | if (friend_not_valid(m, number)) | ||
204 | return -1; | ||
205 | |||
206 | if (m->friendlist[number].crypt_connection_id != -1) { | ||
207 | return add_tcp_relay_peer(m->net_crypto, m->friendlist[number].crypt_connection_id, ip_port, public_key); | ||
208 | } else { | ||
209 | return add_tcp_relay(m->net_crypto, ip_port, public_key); | ||
210 | } | ||
211 | } | ||
212 | |||
198 | /* | 213 | /* |
199 | * Add a friend. | 214 | * Add a friend. |
200 | * Set the data that will be sent along with friend request. | 215 | * Set the data that will be sent along with friend request. |
@@ -277,6 +292,7 @@ int32_t m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t leng | |||
277 | m->friendlist[i].message_id = 0; | 292 | m->friendlist[i].message_id = 0; |
278 | m->friendlist[i].receives_read_receipts = 1; /* Default: YES. */ | 293 | m->friendlist[i].receives_read_receipts = 1; /* Default: YES. */ |
279 | memcpy(&(m->friendlist[i].friendrequest_nospam), address + crypto_box_PUBLICKEYBYTES, sizeof(uint32_t)); | 294 | memcpy(&(m->friendlist[i].friendrequest_nospam), address + crypto_box_PUBLICKEYBYTES, sizeof(uint32_t)); |
295 | recv_tcp_relay_handler(m->onion_c, onion_friendnum, &tcp_relay_node_callback, m, i); | ||
280 | 296 | ||
281 | if (m->numfriends == i) | 297 | if (m->numfriends == i) |
282 | ++m->numfriends; | 298 | ++m->numfriends; |
@@ -322,6 +338,7 @@ int32_t m_addfriend_norequest(Messenger *m, uint8_t *client_id) | |||
322 | m->friendlist[i].is_typing = 0; | 338 | m->friendlist[i].is_typing = 0; |
323 | m->friendlist[i].message_id = 0; | 339 | m->friendlist[i].message_id = 0; |
324 | m->friendlist[i].receives_read_receipts = 1; /* Default: YES. */ | 340 | m->friendlist[i].receives_read_receipts = 1; /* Default: YES. */ |
341 | recv_tcp_relay_handler(m->onion_c, onion_friendnum, &tcp_relay_node_callback, m, i); | ||
325 | 342 | ||
326 | if (m->numfriends == i) | 343 | if (m->numfriends == i) |
327 | ++m->numfriends; | 344 | ++m->numfriends; |