Commit Graph

5660 Commits

Author SHA1 Message Date
Green Sky 3ff69eeed0 chore: update bootstrap docker hash 2026-02-07 20:43:07 +01:00
iphydf d9f6f04e0a test: Fix flakiness in group_moderation_test
The test was flaky due to a race condition in moderation event sync:
`wait_for_peer_role` was only checking a peer's self-view of its own
role via mirrored context, rather than ensuring other peers performing
subsequent moderation actions had actually received and processed the
broadcast.

This caused divergent sanctions lists between nodes, leading to `Invalid
credentials hash` warnings and test timeouts when subsequent moderation
actions (like Barrier 5/6) were rejected by nodes that hadn't yet
processed previous updates.

Fixed by using `tox_group_peer_get_role` in `wait_for_peer_role` to
ensure the calling node has locally processed the role update before
proceeding past a synchronization barrier.
2026-02-07 14:41:07 +00:00
iphydf 0b2e645ab8 chore: Update changelog removing past RCs.
Now that our clog implementation no longer outputs release candidate
changelogs for releases which have by now done their production release.
2026-02-07 14:36:53 +00:00
iphydf a8b7bcceb9 cleanup: Ensure callbacks to qsort cast their params.
This is needed for the `-Wmemcpy` linter, and also to ensure that
`qsort` is being called with the correct types.
2026-02-05 15:22:06 +00:00
github-actions[bot] 297db8ac45 chore: Release v0.2.22-rc.1
This release focuses on hardening, architectural refinement, and better testing capabilities.

On the Hardening front, the ToxAV module has undergone significant security improvements. We have addressed a heap buffer overflow in RTP packet handling and fixed several logic bugs in the bandwidth controller and audio modules that could affect stability.

Architectural Refactoring continues with the internalization of core system dependencies. The system clock, random number generation, and memory management are now accessed through abstract interfaces, further decoupling the core from OS-specific implementations and making the codebase more portable and testable.
v0.2.22-rc.1
2026-02-05 07:45:27 +00:00
iphydf 474e95437b chore: Update bootstrap daemon hash for release.
Also add `--release` flag to the update script so it can easily patch
the version change in to have a local reproducible build.
2026-02-04 21:15:56 +00:00
iphydf bdb86a5e02 chore: Fix tokstyle CI check. 2026-02-04 20:27:48 +00:00
iphydf 2101260fdf chore: Update bootstrap node sha256 hash. 2026-02-04 15:36:22 +00:00
iphydf 6f735b51be chore: Happy new year 2026! 2026-01-27 22:35:47 +00:00
Green Sky de30cf3ad9 docs: Add new file kinds, that should be useful to all clients. 2026-01-27 22:24:25 +01:00
iphydf d5b5e879d0 fix(DHT): Correct node skipping logic timed out nodes.
The previous logic would only skip nodes if they were both missing an IP
and NOT timed out. This caused Tox to attempt routing packets through
stale or informed but unreachable nodes.

This change ensures we skip any node that either lacks an IP or has
timed out, improving DHT routing reliability.
2026-01-27 00:39:32 +00:00
iphydf 30e71fe974 refactor: Generate event dispatch functions and add tox_events_dispatch. 2026-01-25 19:12:11 +00:00
iphydf 8fdbb0b50e style: Format parameter lists in event handlers. 2026-01-25 16:28:15 +00:00
iphydf d00dee12b1 refactor: Add warning logs when losing chat invites.
We can only send 10, then we silently overwrite the first one and lose it.
2026-01-24 19:39:47 +00:00
iphydf b144e8db10 feat: Add a way to look up a file number by ID. 2026-01-24 18:06:39 +00:00
iphydf 849281ea08 feat: Add a way to fetch groups by chat ID. 2026-01-24 17:13:59 +00:00
iphydf a2c1773969 refactor: Harden event system and improve type safety.
- Use MessagePack strings for IP addresses and other text fields.
- Mark dynamic event fields as nullable in getters.
- Add overflow checks for event list capacity.
2026-01-24 14:03:07 +00:00
iphydf 8f5caa6566 refactor: Add MessagePack string support to bin_pack. 2026-01-24 12:51:12 +00:00
iphydf 34e8d5ad58 chore: Add GitHub CodeQL workflow and local Docker runner. 2026-01-24 12:06:39 +00:00
iphydf f7b0680108 refactor: Add nullability annotations to event headers. 2026-01-24 10:09:27 +00:00
iphydf 788abe6516 refactor(toxav): Use system allocator for mutexes. 2026-01-23 21:48:22 +00:00
iphydf 2e4b423eb6 refactor: Use specific typedefs for public API arrays.
Makes it clearer to static analysers and API generators what those
things are, and whether they are compatible.
2026-01-21 00:49:26 +00:00
Green Sky 2baf34775b docs(toxav): update idle iteration interval
see 6794447518
2026-01-20 16:31:18 +01:00
iphydf 2f87ac67b0 feat: Add Event Loop abstraction (Ev).
- `Ev` interface in `toxcore/ev.h` and `toxcore/ev.c`.
- System-specific event loop backends (epoll, poll, win32) in
  `toxcore/os_event.c`.

Performance Benchmarks (epoll backend):

| Sockets (N) | Active (M) | Time (ns) | Time/Active (ns) |
|------------:|-----------:|----------:|-----------------:|
|           8 |          1 |       438 |              438 |
|          64 |          1 |       438 |              438 |
|         512 |          1 |       443 |              443 |
|        1024 |          1 |       442 |              442 |
|        1024 |         10 |       947 |               95 |
|        1024 |        100 |     6,268 |               63 |
|        1024 |       1024 |    61,875 |               60 |
2026-01-19 17:49:39 +00:00
iphydf f8dfc38d8c test: Fix data race in ToxScenario virtual_clock.
- Consistently use `tox_scenario_get_time` to access `virtual_clock`
  under `clock_mutex`.
- Initialize mutexes before setting the initial clock value.
2026-01-17 21:21:02 +00:00
iphydf 38313921e3 test(TCP): Add regression test for TCP priority queue integrity.
This test ensures that multiple priority packets added to a
`TCP_Connection` while the socket is busy are correctly queued in the
linked list without dropping intermediate packets.

Specifically, it protects against regressions where updating the tail
pointer incorrectly (e.g., using the head pointer as a base for append)
would result in data loss. This was identified as a risk in PR #2387.
2026-01-17 20:28:44 +00:00
iphydf f94a50d9af refactor(toxav): Replace mutable_mutex with dynamically allocated mutex.
The `mutable_mutex` member was used to work around const-correctness
checks when locking the mutex in `const` functions. This pattern
confused static analyzers and was generally unclear.

By changing the mutex member to be a pointer (`pthread_mutex_t *`) and
allocating it dynamically, we achieve the same effect (the pointer
itself is const in a const struct, but the pointed-to mutex is not) in a
standard compliant way that satisfies static analyzers and avoids
`-Wcast-qual` warnings without needing casts.
2026-01-17 17:43:25 +00:00
iphydf ad054511e6 refactor: Internalize DHT structs and add debug helpers.
- Move `struct NAT` from `toxcore/DHT.h` to `toxcore/DHT.c` to improve
  encapsulation.
- Add `tcp_packet_type_to_string` and `tcp_packet_from_int` to
  `toxcore/TCP_common` for better debug logs.
- Add `net_family_to_string` to `toxcore/net` for the same reason.
2026-01-17 17:25:19 +00:00
iphydf 8b467cc963 fix: Prevent potential integer overflow in group chat handshake.
- Change length from `uint16_t` to `uint32_t` in `make_gc_handshake_packet`.
- Add explicit cast to `uint16_t` when calling `wrap_group_handshake_packet`.

This is a hardening measure. Currently, `MAX_SENT_GC_NODES` is 1, so the
length variable (`uint16_t`) cannot overflow. However, if this constant
were increased significantly in the future, the addition `length +=
nodes_size` could wrap around. This change eliminates that latent risk.
2026-01-17 16:03:19 +00:00
iphydf 4962bdbb80 test: Improve TCP simulation and add tests
- `FakeTcpSocket` handles basic TCP state machine (SYN, ACK, RST, buffering).
- `NetworkUniverse` handles TCP routing and loopback.
- Add `TcpRelayChaining` test.
- Add LogFilter to Simulation.
2026-01-17 14:35:20 +00:00
iphydf 5f0227093c refactor: Allow nullable data in group chat handlers.
Removed the workaround in process_recv_array_entry where we replaced
nullptr data with empty_data.
2026-01-17 12:38:18 +00:00
iphydf e97b18ea99 chore: Improve Windows Docker support.
- Add `run` helper script and `.dockerignore` files.
- Update `build_dependencies.sh` to include GTest so we can run unit
  tests on Windows.
2026-01-17 03:50:47 +00:00
iphydf b14943bbdd refactor: Move Logger out of Messenger into Tox.
So it can be used across other pieces we plug together in `tox_new`.
2026-01-15 18:08:29 +00:00
iphydf dd31362509 cleanup: Apply nullability qualifiers to C++ codebase. 2026-01-15 12:19:00 +00:00
iphydf 1849f70fca refactor: Extract low-level networking code to net and os_network.
Move core networking types and the Network interface to net, and the
standard OS socket implementation to os_network. Update network to use
these new abstractions.
2026-01-14 23:44:18 +00:00
iphydf 8fec754218 refactor: Delete tox_random, align on rng and os_random. 2026-01-14 15:15:40 +00:00
iphydf a03ae8051e refactor: Delete tox_memory, align on mem and os_memory.
os_memory will be os_mem later.
2026-01-14 10:19:05 +00:00
iphydf 4c88fed2c9 refactor: Use std:: prefixes more consistently in C++ code. 2026-01-14 02:10:10 +00:00
iphydf 72452f2aeb test: Add some more tests for onion and shared key cache.
Also some other cleanups.
2026-01-13 23:43:56 +00:00
iphydf d5a51b09a2 cleanup: Use tox_attributes.h in tox_private.h and install it.
Only when using experimental APIs.
2026-01-13 23:24:29 +00:00
iphydf b6f5b9fc56 test: Add some benchmarks for various high level things. 2026-01-12 14:37:27 +00:00
iphydf 8a8d02785e test(support): Introduce threaded Tox runner and simulation barrier
- Add `MpscQueue` for thread-safe task scheduling.
- Add `ToxRunner` to execute Tox instances in dedicated threads.
- Update `Simulation` to coordinate time steps across multiple runners using a synchronization barrier.
- Refactor `FakeMemory` and `FakeClock` to be thread-safe.
- Update `tox_network` helpers and tests to utilize the threaded runner infrastructure.
2026-01-11 22:51:59 +00:00
Green Sky d68d1d0950 perf(toxav): optimize audio and video intermediate buffers
by keeping them around
2026-01-11 18:02:08 +01:00
iphydf 4f6d4546b2 test: Improve the fake network library.
Some bugfixes, and getting ready for benchmark support code.
2026-01-11 12:32:44 +00:00
iphydf a2581e700d refactor(toxcore): generate Friend_Request and Dht_Nodes_Response
Update `generate_event_c.cpp` to support `EventTypeByteArray` and custom C
types for byte ranges.
2026-01-10 01:59:15 +00:00
iphydf 2aaa11770e refactor(toxcore): use Tox_Memory in generated events
Update event generator to use mem_balloc/mem_delete for byte arrays in
events, ensuring consistency with Tox memory management. Also fix struct
initialization to use compound literals compliant with tokstyle.
2026-01-09 23:05:37 +00:00
iphydf 5c367452b9 test(toxcore): fix incorrect mutex in tox_scenario_get_time
Fixes CID 1668103 and CID 1668102 by protecting `s->virtual_clock` with
`s->clock_mutex` instead of `s->mutex`, consistent with other usages.
2026-01-09 15:48:58 +00:00
iphydf 8f92e710f3 perf: Add a timed limit of number of cookie requests.
Avoids being spammed by cookie requests and spending a lot of CPU on it.
2026-01-09 15:05:43 +00:00
iphydf 695b6417aa test: Add some more simulated network support.
We'll need this for future tests (coming soon).
2026-01-08 18:50:34 +00:00
iphydf 815ae9ce9d test(toxcore): fix thread-safety in scenario framework
Properly lock virtual clock access and snapshot synchronization to
address Coverity CIDs 1668069, 1668068, 1668067, 1668066. Use a separate
clock_mutex to avoid the need for recursive mutexes and ensure
portability.
2026-01-08 12:59:31 +00:00