Commit Graph

667 Commits

Author SHA1 Message Date
jfreegman
5e2c8cabc1
cleanup: make some improvements to group moderation test
- 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.
2024-01-16 18:08:11 -05:00
iphydf
fcf5882428
test: Add printf log statement to group_moderation_test. 2024-01-15 18:09:38 +00:00
iphydf
b4d8826228
cleanup: Remove old type-ordered event getters.
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.
2024-01-15 17:29:43 +00:00
iphydf
97bdd83937
refactor: Make event dispatch ordered by receive time. 2024-01-15 16:32:10 +00:00
Green Sky
d3b935f63f
fix(test): tests use ipv6 by default, even with USE_IPV6 set to 0 2024-01-15 15:29:01 +01:00
iphydf
d30c81acbc
refactor: Move file streaming test to its own file.
It can't easily be ported to events.
2024-01-14 23:00:42 +00:00
iphydf
df76f5cf47
chore: Move from gcov to llvm source-based coverage. 2024-01-12 10:27:48 +00:00
iphydf
b148a2afff
chore: Simplify msvc build using vcpkg. 2024-01-06 12:27:31 +00:00
iphydf
5cac6d7eb1
cleanup: Move tox_get_system out of the public API.
It's not released, yet, and this function is a pain. We don't want it
going forward.
2024-01-05 19:29:59 +00:00
iphydf
c9ca4007e3
refactor: Align group message sending with other send functions.
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.
2024-01-05 19:20:01 +00:00
iphydf
82d8265688
fix: Use QueryPerformanceCounter on windows for monotonic time.
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.
2023-12-27 12:21:33 +00:00
iphydf
766e62bc89
chore: Use pkg_search_module directly in cmake.
The `pkg_use_module` was doing magic we used to use, but no longer need.
2023-12-26 01:14:50 +00:00
iphydf
00ff078f91
cleanup: Use target_link_libraries directly in cmake.
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.
2023-12-26 00:24:08 +00:00
iphydf
895a6af122
cleanup: Remove NaCl support.
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.
2023-12-25 00:36:38 +00:00
iphydf
425216d9ec
fix: Correct a use-after-free and fix some memory leaks.
Also: use `find_package` to find gtest. This fixes the coverage build to
include unit tests.
2023-12-21 17:17:51 +00:00
iphydf
4e603bb613
refactor: Use enum-from-int rule from tokstyle.
These functions are a bit clearer and don't need to change if enum
values change.

See https://github.com/TokTok/hs-tokstyle/pull/212 for the relevant
linter implementation.
2023-12-19 20:53:15 +00:00
iphydf
6a895be0c7
test: Make esp32 build actually try to instantiate tox.
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.
2023-12-19 19:41:45 +00:00
iphydf
65d09c9bfb
cleanup: Remove test net support.
Mainnet now supports NGC.
2023-12-19 18:36:56 +00:00
Green Sky
2b0dc0f46b
add ngc related unpack functions 2023-12-19 19:18:28 +01:00
jfreegman
b2315c50e0
Add groupchat API function that returns an IP address string for a peer
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.
2023-12-19 11:07:03 -05:00
iphydf
028b017d79
perf: Slightly reduce bandwidth usage when there are few nodes.
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.
2023-12-18 16:23:45 +00:00
Green Sky
15ee46d431
add simple test for max sized lossy custom group packet 2023-12-15 01:25:31 +01:00
iphydf
7cfe35dff2
cleanup: Remove explicit layering_check feature.
It's default in .bazelrc now.
2023-11-23 23:55:57 +00:00
iphydf
d1e850c56c
fix: Add missing htons call when adding configured TCP relay. 2023-11-23 00:13:16 +00:00
iphydf
a927183233
test: Add a test for encrypting 100MB of data.
Both in C and C++, because the C++ tests don't currently run on FreeBSD,
and we want to know how the FreeBSD VM performs (answer: poorly).
2023-11-22 21:12:27 +00:00
Green Sky
8099d82397
diagnostic: get the number of close dht nodes with announce/store support 2023-11-13 01:24:15 +01:00
iphydf
58fac53429
refactor: Add a bin_unpack_bin_max for max-length arrays.
These are statically allocated (e.g. `uint8_t[1024]`) arrays with
variable length data inside them. Examples are group topics and
nicknames.
2023-11-12 00:57:44 +00:00
iphydf
0c5b918e9f
cleanup: Fix a few more clang-tidy warnings. 2023-09-07 07:06:34 +00:00
iphydf
4d3c97f49d
cleanup: Enforce stricter identifier naming using clang-tidy. 2023-08-31 13:37:16 +00:00
iphydf
a549807df7
refactor: Add mem module to allow tests to override allocators.
This will allow us to do more interesting things with memory allocation
within toxcore, and allow fuzzers to explore various allocation failure
paths.
2023-08-30 22:55:05 +00:00
jfreegman
0a277b52ea
Merge the remainder of the new groupchats implementation
Commit history: https://github.com/jfreegman/toxcore/tree/ngc_jf
Spec: https://toktok.ltd/spec.html#dht-group-chats
2022-09-22 11:16:08 -04:00
sudden6
4062c3a2ba
refactor: Simplify locking logic in DHT
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.
2022-05-25 19:32:57 +02:00
sudden6
0f1db935a9
test: fix wrong log callback types 2022-05-24 21:58:23 +02:00
iphydf
50094b7385
test: Add a protocol dump test to generate initial fuzzer input. 2022-04-19 23:42:47 +00:00
iphydf
2824aa2544
test: Improve test hermeticity by using local TCP relay.
This will attempt to bind to a few different TCP ports and connect toxes
to it if UDP is disabled for the test.
2022-04-14 21:44:15 +00:00
iphydf
078baf08bb
test: Improve error messages in toxav_basic_test. 2022-04-08 18:05:24 +00:00
iphydf
c4beda4dd1
refactor: Rename announce functions into their own namespace.
This avoids common names like `on_stored` and `store_data` in global
symbols. Turns out, toxic also has a `store_data`.
2022-04-05 20:30:53 +00:00
iphydf
941026266e
refactor: Allow overriding mono_time in tox_new.
This makes it so if mono_time is overridden, no monotonic time-related
system call is invoked in tox_new.
2022-04-03 22:48:16 +00:00
Robin Linden
657d185de5
chore: Support producing shared libraries on Windows
The FLAT_OUTPUT_STRUCTURE CMake option was added to allow the tests to
find the .dlls.

The global data symbols were converted to functions to allow
WINDOWS_EXPORT_ALL_SYMBOLS handle them.

See:
https://cmake.org/cmake/help/v3.23/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html
2022-04-03 23:04:11 +02:00
iphydf
7a3ead591f
cleanup: Use a struct for the ip_ntoa buffer.
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.
2022-04-03 18:57:04 +00:00
iphydf
4d5887cc58
test: Improve stability of forwarding_test.
By trying to create a tox tcp relay on 100 ports starting at 36570.
2022-04-03 18:14:01 +00:00
zugz (tox)
e49a477a84
feat: add forwarding and announce request handling
This is the "server-side" part of the new friend finding system,
allowing DHT nodes to store small amounts of data and permit searching
for it. A forwarding (proxying) mechanism allows this to be used by TCP
clients, and deals with non-transitivity in the network.
2022-04-03 00:00:08 +00:00
iphydf
cc31ff07fa
feat: Add support for custom random number generator.
This can be used by fuzzers to make RNG-driven code deterministic (i.e.
based on the fuzzer input).
2022-04-01 14:06:05 +00:00
iphydf
660e346fce
cleanup: Disallow stack frames of over 9000 bytes.
This only happens in tests, which are easy to fix. Inside toxcore we
should actually be more stringent, but for now this helps already.
2022-04-01 13:57:16 +00:00
iphydf
d0ebc21a0e
cleanup: Add Network object parameter for addr_resolve.
This function doesn't use Network yet, but it will in the future, and
for now it's better to pass Network to all network I/O functions.
2022-04-01 10:42:43 +00:00
iphydf
b09a1ff02d
cleanup: Remove all uses of TOX_*_MAX_SIZE macros.
We should use the functions for these instead.
2022-04-01 09:10:37 +00:00
iphydf
f39aac09e6
feat: Allow custom network functions.
The idea here is to have a `Network` object that contains functions for
network operations and an optional userdata object that can manage those
network operations. This allows e.g. a fuzzer to replace the network
functions with no-ops or fuzzer inputs, reducing the need for `#ifdef`s.
2022-03-29 22:03:26 +00:00
iphydf
ad90f5bbb8
cleanup: Mark Mono_Time const where possible. 2022-03-28 21:26:34 +00:00
iphydf
f13029417e
test: Remove save_load_test from autotools build.
It keeps timing out. Not great, but it's covered by other builds.
2022-03-28 00:11:47 +00:00
iphydf
bb7b1e9b3a
cleanup: Make addr_resolve a private function.
This isn't used anywhere except in network_test. That test now checks
behaviour of the function actually used elsewhere in tox code, instead.
2022-03-27 20:10:42 +00:00