From 8d7ba013a516c72588a5a99d42defaef75e70311 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sat, 8 Mar 2014 17:21:39 -0500 Subject: [PATCH] send_custom_user_packet now returns -1 when friend is offline. --- toxcore/Messenger.c | 7 +++++++ toxcore/onion_client.c | 1 + 2 files changed, 8 insertions(+) diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 2772d6d0..f4e497d0 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -1662,6 +1662,12 @@ int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t b int send_custom_user_packet(Messenger *m, int friendnumber, uint8_t *data, uint32_t length) { + if (friend_not_valid(m, friendnumber)) + return -1; + + if (m->friendlist[friendnumber].status != FRIEND_ONLINE) + return -1; + IP_Port ip_port = get_friend_ipport(m, friendnumber); if (ip_port.port == 0) @@ -2026,6 +2032,7 @@ void do_friends(Messenger *m) break; group_newpeer(m->chats[groupnum], data + crypto_box_PUBLICKEYBYTES); + /* This is just there to speedup joining. */ chat_bootstrap(m->chats[groupnum], get_friend_ipport(m, i), data + crypto_box_PUBLICKEYBYTES); break; } diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 8c0e426a..db6bd39a 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c @@ -528,6 +528,7 @@ int send_onion_data(Onion_Client *onion_c, int friend_num, uint8_t *data, uint32 continue; ++num_nodes; + if (list_nodes[i].is_stored) { if (random_path(onion_c->dht, &onion_c->friends_list[friend_num].onion_paths, ~0, &path[num_good]) == -1) continue;