Commit Graph

5038 Commits

Author SHA1 Message Date
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
Robin Linden
0ac930e1f6
cleanup: Clean up comparing bools with ints 2022-02-23 22:50:12 +00:00
Robin Linden
0ca2882b92
cleanup: Remove yet more implicit bool conversions 2022-02-23 22:00:46 +00:00
iphydf
c2c7c9f0fd
cleanup: Remove more implicit bool conversions.
Also use `bool` type in place of `uint8_t` which was the old bool type
in toxcore before C99.
2022-02-23 22:00:46 +00:00
sudden6
3e6fc59f91
chore: remove cpufeatures.c
The method to detect CPU features in Android has changed and this is no
longer needed.
2022-02-23 20:59:06 +01:00
iphydf
b13590a86d
cleanup: Mark all local non-pointers as const where possible. 2022-02-23 19:30:01 +00:00
iphydf
17c8f50f44
cleanup: Reduce name shadowing; remove ptr-to-bool conversions.
Missed a few of those in check-c. check-cimple now catches these with a
stronger type check.

Other changes:
* `ptr + int` must always have the `ptr` first, so `int + ptr` is not
  allowed anymore.
* `close` and `time` were shadowing libc functions. `file_data` was
  shadowed in a function (and is not a good function name anyway), so
  renamed to `send_file_data` which is more descriptive.
* Within a function, all local variables of the same name must have the
  same type.
* The `strerror_r` change wasn't necessary, but I kept it because it
  seems a bit clearer to me now. `#ifdef`s inside functions are a bit
  confusing sometimes.
2022-02-23 17:30:53 +00:00
iphydf
70d75ae9a3
cleanup: Remove implicit conversions from uint32_t to bool. 2022-02-22 23:25:23 +00:00
sudden6
e42441e3cf
chore: remove DHT_test.c since it's unused 2022-02-22 22:30:27 +01:00
iphydf
6be655c56c
cleanup: Return boolean constants, not ints from bool functions. 2022-02-22 17:50:17 +00:00
iphydf
b7f95bbe70
cleanup: Remove any disallowed casts.
The ones in toxav weren't needed. The ones in network.c are
non-trivially correct. Now, the code is more easily verifiable.
2022-02-22 02:19:29 +00:00
iphydf
b8ce394e64
fix: Null function pointer dereference. 2022-02-22 01:55:15 +00:00
iphydf
2760966836
cleanup: Avoid casting function pointers.
Also added declarations using the `_cb` type for each of the callback
handlers in tox.h. This forces cppcheck to check whether the parameter
names in the definitions agree with the `_cb` parameter names.
2022-02-21 20:02:47 +00:00
iphydf
f98137d697
refactor: Move tox_new_log to auto_test_support.
This is only used in auto tests.
2022-02-21 17:39:10 +00:00
iphydf
e7bc611dac
cleanup: Enable most cppcheck warnings as errors.
Cleaned up some of the warnings it gives. Disabled the ones that are
less useful for us at this time.
2022-02-21 17:17:36 +00:00
iphydf
86a528a37a
chore: Add a .clang-format that mostly agrees with astyle. 2022-02-21 16:16:16 +00:00
iphydf
a9ccf1be26
cleanup: Remove all implicit bool conversions in if-conditions.
Note to reviewer: please review carefully. This was done manually.
2022-02-21 15:10:22 +00:00
sudden6
fff2b1c4e7
fix: out-of-memory condition by corrupted save file
Don't allocate the memory trusting the values in a toxsave file.
2022-02-21 13:54:32 +01:00
sudden6
12dbafbd18
fix: memory leak during conference load
This was found in our continous fuzzing setup.
2022-02-20 21:23:09 +01:00
iphydf
6a6bc029de
cleanup: Remove unused execution trace library. 2022-02-19 11:44:13 +00:00
iphydf
a6426d7e7a
chore: Make coverity scan a nightly job.
Instead of on every push. It only produces results once a day anyway.
2022-02-19 02:47:36 +00:00
iphydf
68f4e5c0fa
chore: Simplify and speed up windows builds using docker image. 2022-02-19 00:47:37 +00:00
iphydf
c44930d323
chore: Fix build-args in win32/win64 docker build. 2022-02-19 00:46:34 +00:00
iphydf
570485e186
chore: Add docker image builds for windows cross compiler. 2022-02-19 00:08:33 +00:00
Robin Linden
1937ee39c3
Release 0.2.16 2022-02-19 00:51:01 +01:00