sending.
When a peer leaves a group, they send a packet to the group
indicating that they're leaving. However if this packet is sent
via TCP, it gets put in a packet queue, which is then destroyed
on the rest of the group cleanup process before ever being able
to send.
This pr allows do_gc() to finish an iteration before cleaning the
group up, which allows the TCP packet queue to be emptied. However
this bug still exists on a tox_kill() event because we don't have
a chance to do another do_gc() iteration.
- We no longer assert peer roles in the mod event callback
because this causes an issue with the new events implementation,
which triggers the events after all the packets from the
current tox_iterate() are processed, rather than as the
packets are received. These checks were superfluous and shouldn't
reduce code coverage.
- A moderator now sets the topic before the founder kicks him in
order to increase internal code coverage.
These are quite expensive, because they go through all events to index
in a typed array that no longer exists. Clients should index in the
union array and find the event they want themselves, or use dispatch.
None of the others use out parameters. Also no toxcore function uses out
parameters for anything other than arrays and errors. This would be a
first, for no good reason.
This fixes time resolution issues and simplifies the code a bit. QPC can
in theory jump forward in time, but in practice not by enough to matter
in our use case.
Instead of using `target_link_modules`, which does magic that we no
longer need, because we only have 1 library we install, and all binaries
we build link statically because they need access to internal symbols.
We now depend on libsodium unconditionally. Future work will require
functions from libsodium, and nobody we're aware of uses the nacl build
for anything other than making sure it still works on CI.
It doesn't work, because esp32 has too little RAM (320KB). DHT is a
240KB struct, so even just allocating that immediately fails. We'll need
to think carefully about trimming that if we ever want this to work on
embedded devices.
This function will return an IP address string associated with a peer.
If the peer is not accepting direct connections a placeholder value
will be returned, indicating that their real IP address is unknown.
We do not return TCP relay IP addresses because a TCP connection
with a peer may use multiple relays simultaneously.
This mainly saves spam in test logs, but may save some packets here and
there, if nodes are randomly selected twice for GET_NODES and onion
routing packets.
This fixes an error reported by cppcheck about overflowing the callback
array. The locking logic probably was broken, so I replaced it with
something simpler and more robust.
Every use of this function needs to allocate the same buffer. None of
the callers uses a differently sized buffer, so we might as well put it
in a struct and have the type checker prove the buffer size is correct.
Also rename `ip_ntoa` to `net_ip_ntoa` to avoid clashes with ESP-IDF
system libraries which define this function as well.