Commit Graph

657 Commits

Author SHA1 Message Date
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
sudden6
bc006beb4e
cleanup: split CMakeLists.txt and add some missing targets 2022-03-27 20:09:10 +02:00
iphydf
ac3e8fea63
test: Improve stability of tox_many_tcp_test.
If the TCP port is in use, try the next TCP port.
2022-03-27 15:10:24 +00:00
iphydf
ee154da4a9
refactor: Use cmp instead of msgpack-c for events packing.
This library is better in every way.
2022-03-26 23:57:15 +00:00
iphydf
6749974470
cleanup: Expose struct Tox to internal code.
To avoid unsafe casts that tokstyle doesn't allow and that can cause
random breakages.
2022-03-26 21:15:31 +00:00
jfreegman
26c2bb1061
Merge onion_announce changes from new groupchats fork
These changes will make the DHT compatible with the new groupchat
implementation. Additionally, onion announces now support arbitrary
extra data
2022-03-20 17:33:06 -04:00
Robin Linden
00e55b34d6
test: Speed up load_save_test by using fake mono_time 2022-03-19 13:09:18 +01:00
Robin Linden
290b1a7716
test: Improve the stability of the save_load test
We were leaving a self_connection_status callback attached to tox1 while
reloading tox2 and 3, the only other toxes in the network. This lead to
tox1 occasionally going offline, triggering the "Tox went offline"
assert and failing the test.
2022-03-19 13:09:07 +01:00
iphydf
faccbe3943
test: Speed up toxav_many_test by using fake mono_time. 2022-03-17 18:20:40 +00:00
iphydf
2f10cb1730
cleanup: Count re-adding an existing bootstrap node as success.
It does nothing in the onion, but we shouldn't be reporting failure for
it. Also added a bit more information to the `tox_bootstrap` logging.
2022-03-07 17:42:16 +00:00
iphydf
3275bb8fea
cleanup: Add explicit callback setters for MSI callbacks.
Instead of a callback ID and a `switch`.
2022-03-04 10:33:23 +00:00