forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' changes from d4b06edc2a..adbd5b32d8
adbd5b32d8 feat: add ngc events 15ee46d431 add simple test for max sized lossy custom group packet 01e7950c67 increase lossy custom packet size in ngc to the toxcore common max of 1373 9b3c1089f1 Make group saving/loading more forgiving with data errors 55a76003b0 Replace memset(int32_t*, -1, _) with a for-loop 66453439ac fix: also Install header for private/experimental API functions with autotools 3983369103 fix: Enable debug flag for ubsan. 4d1db21102 Update tox-boostrapd hash e700c31b70 Fix memory leak in group connection 2994441d9c Fix memory leak in save-generator d0400df13d Fix memory leak in tox-bootstrapd 7a6d50ebe3 Install header for private/experimental API functions d89677fb5f Remove defunct IRC channel from README.md 26d41fc604 Replace DEFAULT_TCP_RELAY_PORTS_COUNT with a compile-time calculation 63fb2941ca Clarify disabling of static assert checks 65b3375b98 refactor: Use Bin_Pack for packing Node_format. 84ba154f6a group connection queries now return our own connection type a4df2862ed Replace tabs with spaces 1b6dee7594 Update tox-bootstrapd's base Docker images a030cdee5c Fix Docker tox-bootstrapd hash update failing when using BuildKit 7cfe35dff2 cleanup: Remove explicit layering_check feature. d390947245 chore: Upgrade sonar-scan jvm to java 17. d1e850c56c fix: Add missing `htons` call when adding configured TCP relay. 814090f2b8 chore: Cancel old PR builds on docker and sonar-scan workflows. 83efb17367 perf: Add a KVM FreeBSD build on cirrus ci. a927183233 test: Add a test for encrypting 100MB of data. 28f39049f6 chore: Retry freebsd tests 2 times. 47e77d1bb0 chore: Use C99 on MSVC instead of C11. 7155f7f60e test: Add an s390x build (on alpine) for CI. 6c35cef63f chore: Add a compcert docker run script. 41e6ea865e cleanup: Use tcc docker image for CI. e726b197b0 refactor: Store time in Mono_Time in milliseconds. REVERT: d4b06edc2a feat: add ngc events git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: adbd5b32d85d9c13800f5ece17c0a9dce99faacd
This commit is contained in:
@ -757,6 +757,20 @@ int m_set_statusmessage(Messenger *m, const uint8_t *status, uint16_t length)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Userstatus userstatus_from_int(uint8_t status)
|
||||
{
|
||||
switch (status) {
|
||||
case 0:
|
||||
return USERSTATUS_NONE;
|
||||
case 1:
|
||||
return USERSTATUS_AWAY;
|
||||
case 2:
|
||||
return USERSTATUS_BUSY;
|
||||
default:
|
||||
return USERSTATUS_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
int m_set_userstatus(Messenger *m, uint8_t status)
|
||||
{
|
||||
if (status >= USERSTATUS_INVALID) {
|
||||
@ -767,7 +781,7 @@ int m_set_userstatus(Messenger *m, uint8_t status)
|
||||
return 0;
|
||||
}
|
||||
|
||||
m->userstatus = (Userstatus)status;
|
||||
m->userstatus = userstatus_from_int(status);
|
||||
|
||||
for (uint32_t i = 0; i < m->numfriends; ++i) {
|
||||
m->friendlist[i].userstatus_sent = false;
|
||||
@ -923,7 +937,7 @@ static int set_friend_statusmessage(const Messenger *m, int32_t friendnumber, co
|
||||
non_null()
|
||||
static void set_friend_userstatus(const Messenger *m, int32_t friendnumber, uint8_t status)
|
||||
{
|
||||
m->friendlist[friendnumber].userstatus = (Userstatus)status;
|
||||
m->friendlist[friendnumber].userstatus = userstatus_from_int(status);
|
||||
}
|
||||
|
||||
non_null()
|
||||
@ -2024,7 +2038,7 @@ non_null(1, 3) nullable(5)
|
||||
static int m_handle_packet_offline(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
|
||||
{
|
||||
if (data_length == 0) {
|
||||
set_friend_status(m, i, FRIEND_CONFIRMED, userdata);
|
||||
set_friend_status(m, i, FRIEND_CONFIRMED, userdata);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -2081,9 +2095,9 @@ static int m_handle_packet_userstatus(Messenger *m, const int i, const uint8_t *
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Userstatus status = (Userstatus)data[0];
|
||||
const Userstatus status = userstatus_from_int(data[0]);
|
||||
|
||||
if (status >= USERSTATUS_INVALID) {
|
||||
if (status == USERSTATUS_INVALID) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2403,8 +2417,8 @@ static int m_handle_packet(void *object, int i, const uint8_t *temp, uint16_t le
|
||||
return m_handle_packet_file_data(m, i, data, data_length, userdata);
|
||||
case PACKET_ID_MSI:
|
||||
return m_handle_packet_msi(m, i, data, data_length, userdata);
|
||||
case PACKET_ID_INVITE_GROUPCHAT:
|
||||
return m_handle_packet_invite_groupchat(m, i, data, data_length, userdata);
|
||||
case PACKET_ID_INVITE_GROUPCHAT:
|
||||
return m_handle_packet_invite_groupchat(m, i, data, data_length, userdata);
|
||||
}
|
||||
|
||||
return handle_custom_lossless_packet(object, i, temp, len, userdata);
|
||||
@ -2627,7 +2641,7 @@ void do_messenger(Messenger *m, void *userdata)
|
||||
if (m->tcp_server != nullptr) {
|
||||
/* Add self tcp server. */
|
||||
IP_Port local_ip_port;
|
||||
local_ip_port.port = m->options.tcp_server_port;
|
||||
local_ip_port.port = net_htons(m->options.tcp_server_port);
|
||||
local_ip_port.ip.family = net_family_ipv4();
|
||||
local_ip_port.ip.ip.v4 = get_ip4_loopback();
|
||||
add_tcp_relay(m->net_crypto, &local_ip_port, tcp_server_public_key(m->tcp_server));
|
||||
@ -3153,7 +3167,7 @@ static void pack_groupchats(const GC_Session *c, Bin_Pack *bp)
|
||||
}
|
||||
|
||||
non_null()
|
||||
static bool pack_groupchats_handler(Bin_Pack *bp, const void *obj)
|
||||
static bool pack_groupchats_handler(Bin_Pack *bp, const Logger *log, const void *obj)
|
||||
{
|
||||
pack_groupchats((const GC_Session *)obj, bp);
|
||||
return true; // TODO(iphydf): Return bool from pack functions.
|
||||
@ -3163,7 +3177,7 @@ non_null()
|
||||
static uint32_t saved_groups_size(const Messenger *m)
|
||||
{
|
||||
GC_Session *c = m->group_handler;
|
||||
return bin_pack_obj_size(pack_groupchats_handler, c);
|
||||
return bin_pack_obj_size(pack_groupchats_handler, m->log, c);
|
||||
}
|
||||
|
||||
non_null()
|
||||
@ -3185,7 +3199,7 @@ static uint8_t *groups_save(const Messenger *m, uint8_t *data)
|
||||
|
||||
data = state_write_section_header(data, STATE_COOKIE_TYPE, len, STATE_TYPE_GROUPS);
|
||||
|
||||
if (!bin_pack_obj(pack_groupchats_handler, c, data, len)) {
|
||||
if (!bin_pack_obj(pack_groupchats_handler, m->log, c, data, len)) {
|
||||
LOGGER_FATAL(m->log, "failed to pack group chats into buffer of length %u", len);
|
||||
return data;
|
||||
}
|
||||
@ -3622,7 +3636,9 @@ Messenger *new_messenger(Mono_Time *mono_time, const Memory *mem, const Random *
|
||||
m->onion = new_onion(m->log, m->mem, m->mono_time, m->rng, m->dht);
|
||||
m->onion_a = new_onion_announce(m->log, m->mem, m->rng, m->mono_time, m->dht);
|
||||
m->onion_c = new_onion_client(m->log, m->mem, m->rng, m->mono_time, m->net_crypto);
|
||||
m->fr_c = new_friend_connections(m->log, m->mono_time, m->ns, m->onion_c, options->local_discovery_enabled);
|
||||
if (m->onion_c != nullptr) {
|
||||
m->fr_c = new_friend_connections(m->log, m->mono_time, m->ns, m->onion_c, options->local_discovery_enabled);
|
||||
}
|
||||
|
||||
if ((options->dht_announcements_enabled && (m->forwarding == nullptr || m->announce == nullptr)) ||
|
||||
m->onion == nullptr || m->onion_a == nullptr || m->onion_c == nullptr || m->fr_c == nullptr) {
|
||||
|
Reference in New Issue
Block a user