Commit Graph

5212 Commits

Author SHA1 Message Date
iphydf
1928704065
test: Add fuzzer tests to the bazel build. 2022-03-25 18:48:41 +00:00
iphydf
7dde71c4e9
chore: Use "master" as the branch in toktok-fuzzer.
This is the standard across toktok repos. Exceptions are a pain for
automation and tooling.
2022-03-23 23:03:52 +00:00
iphydf
2dcb946e62
cleanup: Reduce scope of array-typed variables where possible.
Cimple cannot actually find these without also causing false positives,
but I found them with cimple before removing the code causing false
positives again.
2022-03-21 12:02:46 +00:00
iphydf
1fc05ce616
cleanup: Reduce scope of variables as requested by cimple. 2022-03-20 23:24:09 +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
iphydf
c3a938e38c
cleanup: Avoid memset on structs.
Most of these were safe (some were not), but even the safe ones can
become unsafe (non-portable) later on when adding pointer or float members.
2022-03-19 12:32:36 +00: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
88ae190aca
cleanup: Split the huge TCP client packet handler.
Also enable cppcheck in both C and C++ mode.
2022-03-19 11:06:50 +00:00
iphydf
2b2eb41211
chore: Enable memory sanitizer build.
I don't know if this will actually work, or how many of these "fixes" I
need to get msan to be happy on CI. For me locally, it all works fine.
On CI, for some reason it's not fine even though I run in the exact same
docker image as CI.
2022-03-19 03:11:16 +00:00
iphydf
faccbe3943
test: Speed up toxav_many_test by using fake mono_time. 2022-03-17 18:20:40 +00:00
Robin Linden
a09f34ae65
chore: Update the Appveyor build to VS2019 to work around conan issues
Apparently the libvpx recipe doesn't really work on VS2015 anymore.
2022-03-17 18:48:52 +01:00
iphydf
4916347169
cleanup: Sync doc comments between .h and .c files. 2022-03-15 21:44:22 +00:00
iphydf
28623dcfa9
fix: Eliminate memory leak in toxav.
This happens when shutting down a toxav session when it still has some
packets in its internal queue. It's not a serious leak and happens very
rarely (1 in 300 runs of the toxav_many_test), but it can happen and
long-running tox instances that start and end calls a lot would
eventually discover this.
2022-03-15 17:19:44 +00:00
iphydf
caac17699e
doc: Put all the tox public api into a fake "tox" namespace.
This will help with code generation, FFI generation, and API validation later on.
2022-03-14 15:53:43 +00:00
iphydf
83c9c0bd85
cleanup: Move all the group.h structs into group.c.
Almost nothing used these. The one thing that did only does it to get a
`Mono_Time` object. We should probably get that from elsewhere, but for
now the refactoring is just this simple move.
2022-03-13 17:49:50 +00:00
iphydf
864b4aa01f
chore: Be even more explicit about integer range bounds.
For coverity, which continues to think we're overrunning buffers when
at this point it's easy to prove we're not. Here would be the corrected
coverity finding:

6. Condition packet_length <= 105 /* 1 + 32 * 2 + 24 + 16 */, taking false branch.
7. Condition packet_length > 1024, taking false branch.

Now packet_length must be > 105 and <= 1024.

12. Condition len1 == packet_length - (89 /* 1 + 32 * 2 + 24 */) - 16, taking true branch.

len1 must be > 0 (105 - 89 - 16) and <= 919 (1024 - 89 - 16).

14. decr: Decrementing len1. The value of len1 is now between 0 and 919 (inclusive).

This is where coverity goes wrong: it thinks len1 could be up to 2147483629.

15. buffer access should be OK. Coverity thinks it's not.
2022-03-08 20:46:46 +00:00
iphydf
9df7bf7ccd
chore: Add testing/Dockerfile to the CI build. 2022-03-08 20:31:39 +00:00
iphydf
001aa63401
fix: Allow port range in DHT_bootstrap.c. 2022-03-08 12:16:08 +00:00
iphydf
d15d9fa72d
cleanup: Minor cleanups in TCP_connection.c.
Nothing very noteworthy, I just came across this and made it slightly
more readable.

I'm not making this function `bool` right now because it's used in NGC
and that will break.
2022-03-08 07:53:45 +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
9e26185678
cleanup: Disable LAN discovery in TCP-only mode.
It causes warnings in the logs.

Also added the IP/Port to TCP connect logging.
2022-03-07 00:10:49 +00:00
iphydf
0d8b9b6b3d
cleanup: Add assertion for decrypted data length.
Hopefully this will make it clear enough to coverity that we're not
overrunning any buffers.
2022-03-06 18:06:39 +00:00
Robin Linden
0467101381
Release 0.2.17 2022-03-06 01:45:06 +01:00
iphydf
e1e92c1ac1
docs: Clean up doxygen comments to be more doxygen-like. 2022-03-05 22:30:48 +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
iphydf
cff9a18e39
cleanup: Split util.c out of the network library.
Also, don't include ccompat.h in header files. Instead, explicitly
include it in .c files.
2022-03-04 10:33:11 +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
0d3703c756
cleanup: Remove redundant () around return expression. 2022-03-04 09:47:24 +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
iphydf
2cc8dafd4c
cleanup: Remove redundant Messenger and DHT tests.
These don't test anything that isn't covered by higher level tox tests.
These are also not unit tests and have never found any bug that wasn't
also caught by other tests. This makes them a pure maintenance burden.
2022-03-03 21:17:03 +00:00
iphydf
ad2ed9e837
test: Add unit test for create/handle request packets.
Also added an assert to tell coverity that we don't actually have an
overflow (or underflow) of the length parameter.
2022-03-03 18:00:17 +00:00
iphydf
5812214b7c
cleanup: Remove EAGAIN from the list of ignored errors.
It is the same as `EINPROGRESS`, so the check is useless.
2022-03-03 16:03:04 +00:00
jfreegman
0dca481e1d
Re-implement progressive backoff interval for friend finding
We now exponentially reduce the frequency of friend lookups based on how many
lookups we've already made for an offline friend
2022-03-03 10:43:54 -05:00
jfreegman
af5dd43c98
Refactor onion_client.c do_friends()
This commit simplifies the logic determining how often we
send announce request packets to offline peers and how often
we attempt to re-populate our nodes lists. It also removes
some randomness from packet sending that was intended to
reduce network traffic but greatly increased the code complexity
and didn't really do all that much to help.

We now aggressively search the DHT for offline friends when we first
bootstrap, add a new friend, or when a friend goes offline, for a
short duration until we've sent a certain number of successful
lookup requests. Thereafter, we send one lookup request every 3
minutes for each node associated with the friend (typically
between 4 and 8), for each friend.

We also no longer spam node requests whenever our list of living
nodes drops below the maximum. Instead, we repopulate the nodes
list only when it drops to or below half the maximum, or after
a 10 minute timeout.

The effects of these changes is a decrease in overall tox network
traffic by about 30-40% with UDP enabled, and a bit less than
that with UDP disabled. The network may also be more reliable
overall because everything is significantly more deterministic
and less random
2022-03-03 10:40:22 -05:00
iphydf
6c2014d719
cleanup: Remove port from Broadcast_Info.
This is added later when we actually send the broadcasts.
2022-03-03 15:21:34 +00:00
iphydf
64254d6459
cleanup: Don't reference local variables in macro bodies.
Tokstyle enforces this now.
2022-03-03 00:45:34 +00:00
iphydf
c20f878934
cleanup: Remove some more implicit bool conversions.
Also removed one explicit bool cast.
Also avoid using the same name for struct fields and global functions.
2022-03-01 18:16:11 +00:00
iphydf
e855135916
chore: Enable a bunch more warnings in GCC builds.
g++ doesn't emit these warnings properly, so the `run-gcc` tool, which
compiles code as C++, doesn't work for all of these. There are a few
builds that do use GCC, e.g. the sonar-scan build, so these flags will
be passed at some point in CI.
2022-02-28 23:26:35 +00:00
iphydf
fe4da6a541
cleanup: Log at ERROR level when connect() fails.
Failure is defined as either being passed an invalid IP/Port, or some
unexpected error code.
2022-02-28 14:01:01 +00:00
iphydf
3ef96f7096
cleanup: Remove *all* boolean-int conversions.
These were found by the new cimple type check which is completely
unforgiving to implicit boolean conversions. After this PR, there should
be no more implicit int-to-bool or bool-to-int conversions.
2022-02-27 00:29:43 +00:00
iphydf
163e9c3b03
cleanup: Remove more boolean conversions (and a bugfix).
These were found by the new stronger type check in cimple. The one
bugfix is in `crypto_sha512_cmp`, which used to think `crypto_verify_32`
returns bool while actually it's -1/0/1.
2022-02-26 00:03:56 +00:00
iphydf
e230ad4d09
cleanup: Comply with strict include ordering.
Tokstyle will require this format:
- Optionally a single include (the module header).
- System includes.
- Local includes.

In headers, there is no module header to include, so system includes
come first there.
2022-02-25 16:44:35 +00:00
iphydf
093927ba4f
test: Add mallocfail and proxy test to our coverage runs. 2022-02-25 01:55:28 +00:00
iphydf
50b0ec824f
cleanup: Avoid creating invalid enum values.
Enums should be fairly strong type guarantees about the possible value
range. The API says the return value is unspecified, so this is not a
breaking change.
2022-02-25 01:22:55 +00:00
iphydf
cad7cf8344
cleanup: Remove superfluous parentheses on the rhs of assignments. 2022-02-25 01:02:11 +00:00
iphydf
aa72c47125
test: Add test coverage docker build for local tests.
This uses mallocfail to further increase coverage using the existing
tests. Also:
* Moved the non-auto "tox_one_test" to gtest. This should be
  split into smaller tests later.
* Changed `hole_punching` to `bool`.
2022-02-24 16:24:28 +00:00
iphydf
2ce6f5b169
fix: Report failure to DHT bootstrap back to the client.
Also reduce log verbosity a bit.
2022-02-24 11:37:47 +00:00
jfreegman
de67c4067c
Fix issue with friend finding taking too long after disconnects
This forces the onion to consider all friends as new after a 10 second
period of the onion being disconnected. new friends are aggressively
searched for in the DHT, whereas old friends are only searched for in
intervals spanning minutes.
2022-02-23 20:10:23 -05:00
iphydf
7ca14d4f52
cleanup: Change valid status of onion friend to bool.
Also renamed it to `is_valid`, since that's what the comment says it
means.
2022-02-24 00:57:09 +00:00