summaryrefslogtreecommitdiff
path: root/toxcore
AgeCommit message (Collapse)Author
2020-05-17Format comments according to tokstyle's requirements.iphydf
2020-05-05refactor: Remove multi-declarators entirely.iphydf
We no longer allow `int a, b;`. In the few cases where we used it, we instead better * limit the scope of the identifier (e.g. in a for-init-decl) * split the line and have 2 separate declarators, because the identifiers designate different types of things (e.g. friend numbers and group numbers).
2020-05-05refactor: Disallow multiple initialised declarators per decl.iphydf
We no longer allow: ```c int a = 0, b = 0; int a[3], b[3]; int a, *b; ``` But we do still allow (for now): ```c int a, b; ```
2020-05-05refactor: Minor cleanup: limit scope of loop iterators.iphydf
2020-05-04Fix typo: `NAC_LIBS` -> `NACL_LIBS`.iphydf
This is working, so probably `NACL_LIBS` is entirely useless, but I can't be bothered to figure out what this was supposed to be, so here we are.
2020-05-04Add logging to TCP and onion client.iphydf
2020-05-03Fix a bug in savedata loading when malloc fails.iphydf
Also added a bunch of asserts to tests where they don't check allocs.
2020-05-03Enable cimple tests by default but allow disabling them.iphydf
Use `bazel test //c-toxcore/... --build_tag_filters=-haskell` to run all tests except the ones that depend on Haskell (i.e. cimple tests).
2020-05-02Add a check that we don't have any unused functions.iphydf
This check puts all of our code in a C++ anonymous namespace, which is effectively making all functions `static`. This allows the compiler to determine that a function is unused, so we can delete it.
2020-05-02Fix errors on error paths found by oomer.iphydf
* Use-after-free because we free network before dht in one case. * Various unchecked allocs in tests (not so important). * We used to not check whether ping arrays were actually allocated in DHT. * `ping_kill` and `ping_array_kill` used to crash when passing NULL. Also: * Added an assert in all public API functions to ensure tox isn't NULL. The error message you get from that is a bit nicer than "Segmentation fault" when clients (or our tests) do things wrong. * Decreased the sleep time in iterate_all_wait from 20ms to 5ms. Everything seems to still work with 5ms, and this greatly decreases the amount of time spent per test run, making oomer run much faster.
2020-05-02Include `<string.h>` for `explicit_bzero`.iphydf
We need this for vanilla nacl builds on Linux.
2020-05-01Release 0.2.12Robin Linden
2020-04-29Bound the number of friends you can have to ~4 billion.iphydf
If you have UINT32_MAX friends, then adding one more friend will cause an overflow of the friend list (wrap to 0) and result in all friends being deleted. This subsequently results in a null pointer dereference when we're trying to add one friend to the deleted friend list.
2020-04-26Skip invalid TCP relays and DHT nodes when loading save datazugz (tox)
2020-04-20Enable TCP relay test in Bazel and autotools build.iphydf
This test was fixed by @robinlinden, but not enabled in all builds.
2020-04-19Invert `not_valid` functions and name them `is_valid`.iphydf
Also changed their return type to bool instead of 1/0 ints.
2020-04-19fix saving of combination of loaded and connected TCP relayszugz (tox)
2020-04-16Add new semi-private API functions to set per-packet-id custom handlers.zoff99
This is to prepare for ToxAV becoming independent of toxcore internal calls.
2020-04-16Remove tokstyle exemptions from build files.iphydf
We put some tokstyle exemptions into the source files themselves, instead. This way we can check some of the code in those files, and more in the future when tokstyle supports more constructs (like apidsl). Also: hacked ping_array.api.h to not emit `_array` as parameter names. We'll need to fix apidsl to do this better. This works for now.
2020-04-13Fix things not being initialized if creating a TCP-only networkRobin Linden
2020-04-09Stop using the "inline namespace" feature of apidsl.iphydf
This adds complexity for very little value.
2020-04-07Remove newlines from the end of LOGGER format strings.iphydf
See https://github.com/TokTok/hs-tokstyle/pull/49 for the corresponding tokstyle analysis.
2020-04-04Migrate format-source script to new apidsl web app.iphydf
This one is unfortunately a little more complicated to use. I may add a simpler API later, but for now, it's JSON-based (because I couldn't get binary data to work without it getting mangled somewhere along the way - JSON is at least text-transport-safe).
2020-03-22Release 0.2.11Robin Linden
2020-03-22Minor cleanups in network code.iphydf
Remove useless parameter, replace with assert (just to be sure). Also replaced some memsets with 0-initialiser and memcpy with assignment.
2020-03-22Minor cleanup: use `assoc_timeout` function where possible.iphydf
This function exists and simplifies some code a little bit. There are lots of places in DHT.c where we have the exact same code, so there is a lot of opportunity to factor out common bits. For now, we just make a minor improvement that's easy to review.
2020-03-22fix typo: now we periodically try to send direct packets when connected by tcpzugz (tox)
2020-03-18clear out old conference connectionszugz (tox)
This may fix problems with very large conferences. Sadly, it seems infeasible to test large conferences on one machine, so this is entirely theoretical.
2020-03-18Add "member" invite responsezugz (tox)
This allows invitations to work in the case that the invitee is already in the group, which can happen if the group becomes split. Such an invitation is automatically accepted, leading to the peers becoming connected in the group and sharing peer lists.
2020-03-18Check that LOGGER macros are only called with string literals.iphydf
Avoid any dynamic format strings, even ones like `cond ? "str1" : "str2"`.
2020-03-15clean groups codezugz (tox)
* make static functions return bool rather than int to indicate success * add peer_in_list() to factor out uniformity over peer and frozen lists * reduce repetition in send_lossy_all_close * rename 'close' to 'connections' * use uint32_t for peernumber (in accord with tox.c) * explain persistence in tox_conference_get_chatlist documentation * clarify "connectedness" in group API documentation * clarify that tox_conference_peer_count counts only online peers * refactor variously
2020-03-14Avoid casting back and forth between void-ptr.iphydf
In windows network code, we implement inet_pton and inet_ntop, which take void pointers. We can do slightly better because we already know the type when we call these functions, so we can avoid casting between void pointer and the addr struct types.
2020-03-14Standardise on having a comma at the end of enums.iphydf
Most of our enums already have one. Some didn't. Tokstyle is going to require commas at the end of enumerator lists in enum definitions.
2020-03-14Fix up comments a bit to start being more uniform.iphydf
Tokstyle (check-cimple) will start enforcing comment formats at some point. It will not support arbitrary stuff in comments, and will parse them. The result can then be semantically analysed.
2020-03-14Use spdx license identifier instead of GPL blurb.iphydf
2020-03-14use -1 rather than ~0 in unsigned integer typeszugz (tox)
Using ~0 involves a bitwise operation on int, so depends on the internal representation of signed integers.
2020-03-12Use rules_cc instead of native cc_library rules.iphydf
2020-03-11Add a mutex lock/unlock inside every public API function.iphydf
2020-03-08Pass packet ID to custom packet handlers.iphydf
We don't expose this to the user code, yet, because it would break the API, but this is useful for future internal code.
2020-03-06Use `net_pack` instead of casting bytes to ints.iphydf
The current code violates the C standard and causes crashes on strict alignment architectures.
2020-03-05Use net_pack/unpack instead of host_to_net.iphydf
The latter is doing pretty much the same thing but in a confusing way (it doesn't change the type of the variable, but does change the semantics).
2020-03-02Add "cimple_test" to the bazel build.iphydf
2020-01-22handle message_number wraparoundzugz (tox)
2020-01-22workaround for message number saving (fixes #961)zugz (tox)
Put a future message number into the save file. Peers require the message numbers of messages we send to increase monotonically. If we save the current message number, then send further messages, then quit without saving (e.g. due to a crash), and then resume from the old save data, then monotonicity will fail. This commit works around this problem by introducing an offset when the current message number, so that even in the above circumstance, as long as fewer messages than the offset were sent between saving and reloading, the sent message numbers will increase monotonically. The choice of offset is a balance between wanting it to be large enough that there is room for plenty of messages to be sent in the above scenario, and wanting to avoid the following potential problem: if we repeatedly save and reload without sending any further messages, then the message number may increase so far that peers will interpret an eventual message as being old. This is not conceivably a practical issue for the 32bit lossless message numbers, but is a concern for the 16bit lossy message numbers.
2020-01-22refactorzugz (tox)
2019-12-25don't wait for connection when killing Toxsudden6
When tox_kill is called no other thread should be running anymore so this locking is not needed there.
2019-12-23fix invalid use of mutexsudden6
- Moving a pthread_mutex in memory (e.g. via realloc()) is undefined behavior. - add a state for allocated but not yet used crypto connections - change crypto_connection_status signature
2019-11-17Fix miscellaneous small problems with groups:zugz (tox)
* unset global status callback in kill_groupchats * avoid dangling friend connections * fix num_introducer_connections leak * stop trying to keep connection alive on freeze * avoid relaying lossless messages back to sender where possible * avoid sending gratuitous online packets
2019-09-18Fix pthread_mutex_destroy getting too many argumentsRobin Lindén
2019-09-09don't update the overflow state in current_time_monotonicsudden6
This could make mono_time loose overflows on Windows.