Commit Graph

122 Commits

Author SHA1 Message Date
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 fc4396cef6 fix: potential division by zero in toxav and unsafe hex parsing
- Fix a potential division by zero crash in `toxav/audio.c` when
  `lp_sampling_rate` is 0.
- Fix unsafe hex string parsing in `bootstrap_daemon/config.c` that
  could leave variables uninitialized (replacing `sscanf` with a safe
  helper).

Also address various clang-tidy findings:
- Enforce const correctness and fix implicit bool conversions in
  `toxav`.
- Sort includes in `toxav`.
2026-01-05 16:08:32 +00:00
iphydf 206ea35304 refactor: Explicitly pass dependencies to constructors.
Instead of transitively loading them from dependencies, we should be
explicit about what each object needs. The downside of this is that it's
not clear whether the object and its dependency use the same common
dependency. The upside is that we don't expose those getters of internal
dependencies.
2025-11-02 23:31:59 +00:00
iphydf 7c3be23429 refactor: Add file/line to tox-bootstrapd logging.
Also, allow trace logging in bootstrapd (disabled by default, but
enabled on the websockify docker image so we can debug things there).
2025-10-18 22:33:09 +00:00
iphydf 390f7db060 refactor: Move random and memory OS-specifics to os_* files. 2025-10-08 10:59:32 +00:00
Green Sky 9f723f891d fix: run do_gca also in bootstrap nodes 2025-01-28 16:08:14 +01:00
iphydf e092ecd124 cleanup: Use tox memory allocator in some more places. 2025-01-14 17:34:21 +00:00
iphydf 5bd8a85eb8 cleanup: Align internal logger with external on type of source line.
We use `uint32_t` everywhere now. It's easier that way, and line numbers
are never negative.
2025-01-12 23:47:23 +00:00
iphydf bc43cec062 chore: Happy new year! 2025-01-05 23:24:52 +00:00
iphydf 819aa2b261 feat: Add option to disable DNS lookups in toxcore.
Allows clients to prevent leaking IP addresses through DNS lookups. This
option, together with disabling Tox UDP, entirely prevents any UDP
packets being sent by toxcore.
2024-11-27 17:19:56 +00:00
iphydf bdd17c1678 cleanup: Allocate logger using tox memory allocator. 2024-11-13 10:22:11 +00:00
iphydf ce4f29e803 cleanup: Fix all -Wsign-compare warnings. 2024-11-08 18:06:15 +00:00
Maxim Biro 5752fc29f8 refactor: Make tox-bootstrapd use bool instead of int
A continuation of the cleanup done in
b7404f24f6.

tox-bootrstrapd historically had used ints for boolean values, as it was
initially written in C89 which has no stdbool.h. Since then it has
modernized and moved on to using C11, but the usage of the int type to
represent boolean values, "boolean ints", remained. Recently, driven by
a desire to eliminate implicit int-to-bool conversion, @iphydf did a
cleanup in b7404f24f6, changing some of
the boolean ints to bools and doing manual int-to-bool conversion on the
remaining boolean ints. This left the codebase in an inconsistent state
of both ints and bools now being used to represent boolean values, not
to mention that the explicit int-to-bool conversions are a bit ugly. The
only boolean ints that remained are those stemming from libconfig's
config_lookup_bool() taking an *int parameter to return a boolean value,
as libconfig still uses C89. This commit adds a wrapper function around
libconfig's config_lookup_bool() that takes a *bool instead, eliminating
the remaining boolean ints and majority of the explicit int-to-bool
conversions in tox-bootstrapd.
2024-11-07 05:41:51 -05:00
Maxim Biro 5344d7f84d fix: Memory leak in the bootstrap daemon 2024-04-03 23:31:27 -04:00
iphydf 08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
Found by PVS Studio.
2024-02-09 18:00:04 +00:00
iphydf b7404f24f6 cleanup: Remove implicit bool conversions. 2024-02-02 01:31:54 +00:00
iphydf 4e2dba4d9f chore: Reformat sources with astyle.
Restyled astyle is fixed now.
2024-02-02 01:31:32 +00:00
iphydf f70e588bc6 cleanup: Add more const where possible. 2024-01-31 19:55:17 +00:00
iphydf 511bfe39c8 cleanup: Use Bazel modules to enforce proper #include hygiene. 2024-01-30 23:51:43 +00:00
iphydf bdf460a3a9 refactor: Rename system_{memory,...} to os_{memory,...}.
This rename happens in the system PR, so I'm pulling it out to reduce
the size of that PR.
2024-01-25 21:33:52 +00:00
Maxim Biro 32576656bb Make the comment capitalization uniform 2024-01-02 19:07:39 -05:00
Maxim Biro aff4dda17c Spellcheck tox-bootstrapd 2024-01-02 19:07:37 -05:00
iphydf fad6e4e173 cleanup: Make all .c files include the headers they need. 2023-12-27 01:21:47 +00:00
iphydf ef4897a898 cleanup: Upgrade to clang-tidy-17 and fix some warnings. 2023-12-27 01:05:47 +00:00
iphydf b7f9367f6f test: Upgrade cppcheck, fix some warnings.
Also started teaching it about toxcore's alloc/dealloc functions in
hopes of it catching some errors (it doesn't seem to be very good at
this, but maybe better than nothing?).
2023-12-27 00:00:10 +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
Maxim Biro d0400df13d Fix memory leak in tox-bootstrapd 2023-12-08 03:31:04 -05:00
Maxim Biro 26d41fc604 Replace DEFAULT_TCP_RELAY_PORTS_COUNT with a compile-time calculation
That way we don't have to rely on a human to remember to keep
DEFAULT_TCP_RELAY_PORTS_COUNT in sync with DEFAULT_TCP_RELAY_PORTS.
2023-12-05 09:56:46 -05:00
Maxim Biro a4df2862ed Replace tabs with spaces 2023-12-03 04:09:43 -05:00
iphydf 0cef46ee91 cleanup: Fix a few more clang-tidy warnings. 2023-09-07 07:49:47 +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
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
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 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 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 f19524cb21 cleanup: Remove dependency from LAN_discovery onto DHT.
As a side-effect, DHT now always accepts LAN discovery packets, even
when LAN discovery is disabled. When LAN discovery is disabled, those
packets are ignored.
2022-03-04 10:19:05 +00:00
iphydf 21688d1d34 cleanup: Move test-only functions into tests.
Also inlined `new_networking` in most places.
2022-03-03 23:58:43 +00:00
Maxim Biro 2965403e2c Add bash-completion for tox-bootstrapd 2022-02-10 02:40:42 -05:00
iphydf 9218566599 cleanup: Make LAN discovery thread-safe without data races.
It was kind of thread-safe, maybe, but there was a data race that makes
tsan unhappy. We now do interface detection once per Tox instance
instead of once per process.
2022-02-06 19:56:34 +00:00
iphydf 28dc8c1ded cleanup: Don't pass the whole DHT object to lan discovery.
It only needs net and dht public key.
2022-02-03 20:50:36 +00:00
jfreegman 5619b5e056 Make more functions take const pointers to IP_Port
We additionally now make local copies of the IP_Port param instead
of modifying the passed argument
2022-02-03 11:17:29 -05:00
Tha14 5a88159b8f Pass "b" for fopen to fix bugs on windows 2022-01-24 16:00:01 +02:00
iphydf 7f94e411a9 chore: Add cpplint to the CI. 2022-01-17 23:42:38 +00:00
jfreegman fc18810ba8 Fix buffer overwrite in bootstrap config 2022-01-17 17:56:47 -05:00
iphydf 5fbcbb6c83 cleanup: Remove uses of strcpy and sprintf.
Use of `strcpy` in these particular cases was safe, but it's hard to
tell and also useless. `strcpy` would effectively need to do another
`strlen` which we already did.

Also removed sprintf, which was also safe in this case but it's easier to
be "obviously safe", especially for static analysers.
2022-01-17 18:25:40 +00:00