Commit Graph

106 Commits

Author SHA1 Message Date
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
iphydf 30c939e4ab cleanup: Fix some clang-tidy warnings and make them errors.
The android warnings are disabled now because they suggest using
linux-only extensions of libc. Useful for android indeed, but we're
targeting non-android and non-linux systems as well.
2021-12-10 15:21:27 +00:00
iphydf fd91bbdd7b test: Add a simple test for ip_ntoa.
Just to demonstrate that it will never exceed its input buffer.
2021-12-09 20:51:15 +00:00
Maxim Biro 4e8e556a93 Fix previous refactor
Includes should be sorted alphabetically and null-terminating is
unnecessary with snprintf.
2021-12-09 13:23:06 -05:00
jfreegman edf9d66717 Add logger to onion and onion announce objects
This will be used in the future
2021-12-07 13:01:15 -05:00
sudden6 0320e2eb8e fix missing braces in computed macro value
Using this value in any computation might not work as expected.
2021-12-05 14:20:04 +01:00
iphydf 02a5bdc60c Add logging to TCP and onion client. 2020-05-04 01:27:36 +01:00
iphydf 11ad5471b9 Use spdx license identifier instead of GPL blurb. 2020-03-14 13:06:19 +00:00
Maxim Biro 5530e41742 Increase NOFILE limit for tox-bootstrapd
tox-bootstrapd can use around 600 TCP sockets during TCP server's normal
functioning. Many systems default to having a soft limit of 1024 open file
descriptors, which we are close to reaching, so it was suggested we bump that
limit to a higher number. iphy suggested increasing it to 32768.
2018-11-04 20:10:09 -05:00
Maxim Biro 1cbc9609a7 Make tox-bootstrapd free memory on SIGINT and SIGTERM
Useful for using memory analyzing tools.
2018-10-16 21:35:27 -04:00
iphydf 49bb43f662 Standardise header guards.
Using the full path including the repo name.
2018-09-14 19:09:10 +00:00
Maxim Biro 2e4cae692e Use our own logging facility to log toxcore's logs 2018-08-30 22:44:18 +00:00
cotox deb82006e5 Feature bootstrap trace/debug log output
Don't know why codes with macro dosen't work.
As it's only a few expensive, just code it without macro for now.

\#if (MIN_LOGGER_LEVEL == LOG_TRACE) || (MIN_LOGGER_LEVEL == LOG_DEBUG)
    fprintf(stderr, "[%s] %s:%d(%s) %s\n", strlevel, file, line, func, message);
\#endif
2018-08-30 22:44:18 +00:00
iphydf 473cde24d8 Update copyright to 2018. 2018-08-26 18:57:29 +00:00
iphydf d6d305feeb Use per-instance Mono_Time for Messenger and onion. 2018-08-16 21:01:43 +00:00
iphydf 54066f338f Reduce the number of times unix_time_update is called.
Reduced by, e.g.:
* `file_transfer_test`: 33% of the `clock_gettime` calls.
* `tox_many_test`: 53% of the `clock_gettime` calls.

Other tests will see similar improvements. Real world applications will
be closer to 40-50% improvement, since tox_many_test has 100 nodes, while
file_transfer_test has 2 nodes.
2018-08-16 21:01:38 +00:00
iphydf d92c96e783 Fix a few warnings from clang.
Also remove the use of a VLA in a context where there can be unbounded
memory allocations.
2018-08-12 14:09:59 +00:00