Commit Graph

1857 Commits

Author SHA1 Message Date
zugz (tox)
94c2a5182b
clear out old conference connections
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-18 00:00:00 +00:00
zugz (tox)
db07bda7f7
Add "member" invite response
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-18 00:00:00 +00:00
iphydf
36cb30d47d
Check that LOGGER macros are only called with string literals.
Avoid any dynamic format strings, even ones like `cond ? "str1" : "str2"`.
2020-03-18 14:51:56 +00:00
zugz (tox)
52655b0c1b
clean groups code
* 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-15 00:00:27 +00:00
iphydf
8795c5f987
Avoid casting back and forth between void-ptr.
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-14 13:48:56 +00:00
iphydf
94d98ddd86
Standardise on having a comma at the end of enums.
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-14 13:40:36 +00:00
iphydf
cb22b3df5f
Fix up comments a bit to start being more uniform.
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-14 13:28:42 +00:00
iphydf
11ad5471b9
Use spdx license identifier instead of GPL blurb. 2020-03-14 13:06:19 +00:00
zugz (tox)
c644ef7681
use -1 rather than ~0 in unsigned integer types
Using ~0 involves a bitwise operation on int, so depends on
the internal representation of signed integers.
2020-03-14 00:00:02 +00:00
iphydf
e671490989
Use rules_cc instead of native cc_library rules. 2020-03-12 12:20:54 +00:00
iphydf
64bf3695d9
Add a mutex lock/unlock inside every public API function. 2020-03-11 15:21:43 +00:00
iphydf
bd7b7fadba
Pass packet ID to custom packet handlers.
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-08 19:17:50 +00:00
iphydf
7b3d2eda3f
Use net_pack instead of casting bytes to ints.
The current code violates the C standard and causes crashes on strict
alignment architectures.
2020-03-06 11:05:52 +00:00
iphydf
e35d70af18
Use net_pack/unpack instead of host_to_net.
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-05 22:56:26 +00:00
iphydf
e618829112
Add "cimple_test" to the bazel build. 2020-03-02 15:20:34 +00:00
zugz (tox)
f6c3ce6d1f
handle message_number wraparound 2020-01-22 00:00:02 +00:00
zugz (tox)
886b9a7019
workaround for message number saving (fixes #961)
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-22 00:00:02 +00:00
zugz (tox)
e6cbe907ac
refactor 2020-01-22 00:00:00 +00:00
sudden6
393a6be5c4
don't wait for connection when killing Tox
When tox_kill is called no other thread should be running anymore so
this locking is not needed there.
2019-12-25 14:56:43 +01:00
sudden6
6338cb46ad
fix invalid use of mutex
- 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-12-23 23:48:15 +01:00
zugz (tox)
2677a53ee0
Fix miscellaneous small problems with groups:
* 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-11-17 13:29:10 +01:00
Robin Lindén
1f89a57180
Fix pthread_mutex_destroy getting too many arguments 2019-09-18 23:26:13 +02:00
sudden6
ca370df651
don't update the overflow state in current_time_monotonic
This could make mono_time loose overflows on Windows.
2019-09-09 01:31:49 +02:00
sudden6
571897cecb
fix concurrency issues in mono_time
Since mono_time is accessed from the main thread as well as the toxav
thread it is needed to properly lock time updates.
2019-09-06 23:10:39 +02:00
sudden6
3d21e66a8a
fix overflow in peer nick len 2019-08-04 16:38:53 +02:00
sudden6
8ed83c3d4c
fix missing group title length check
This fixes a buffer overflow when a malformed *.tox save file is
loaded.
2019-08-04 16:38:49 +02:00
Robin Lindén
7aab0d9952
Release 0.2.10 2019-05-30 15:36:12 +02:00
zugz (tox)
306dd1f21f
add configurable limit on number of stored frozen peers 2019-05-19 18:51:28 +02:00
Evgeny Kurnevsky
d26b11d0c2
Do not send the same packet to the same node twice. 2019-05-01 16:40:04 +02:00
zugz (tox)
49e2406ffa
Expose api functions for enabling and disabling AV in AV groups
A group loaded from a savefile starts with AV disabled.
2019-02-10 00:00:00 +00:00
zugz (tox)
0aad180d1e
Specify that buffer size for tox_conference_peer_get_name is given by $size 2019-01-21 22:17:49 +01:00
Robin Lindén
98b754e1f2
Release 0.2.9 2019-01-12 23:35:54 +01:00
zugz (tox)
a4bca35a1a
Add some const qualifiers
(Implementing suggestions of sudden6)
2019-01-12 22:38:51 +01:00
iphydf
91ff39599d
Implement all min/max functions for (un)signed int types.
Also, use them in the `onion_client` module.
2019-01-12 13:12:39 +00:00
iphydf
3dd31b1fd0
Fix misaligned 4-byte access in trace logging.
This code is undefined behaviour as is, and breaks on various platforms
requiring strict alignment (many microcontrollers).
2019-01-10 19:37:28 +00:00
zugz (tox)
86935beb2f
Avoid sending group messages to a peer before we have its group number 2019-01-07 01:11:12 +01:00
zugz (tox)
e5561ad2b0
Improve handling of peers entering and leaving conferences
* send freeze packet on quit
* delete existing peers with same real_pk on adding a peer
* record actual number of conference peers saved
2019-01-06 19:37:33 +00:00
zugz (tox)
a122ee9e01
Expose offline conference peers in API 2019-01-05 15:01:29 +00:00
zugz (tox)
1ddc922750
Define tox_conference_id_size and tox_conference_uid_size
Closes #1264
2019-01-03 14:29:20 +00:00
Evgeny Kurnevsky
e5320579a9
Fix indices calculation for congestion control. 2019-01-03 11:13:27 +00:00
zoff99
78bc9e7403
Added test and patch for VLA stack overflow vuln.
Also added and used the new crypto_malloc and crypto_free.

The latter also zeroes out the memory safely. The former only exists for
symmetry (static analysis can detect asymmetric usages).
2019-01-03 11:13:27 +00:00
zugz (tox)
9770880e97
Implement conferences saving
* add global friend_connection status callback, used for group rejoining
* stop leaving groups on killing tox
2018-11-29 21:52:23 +01:00
zugz (tox)
0bf90df5e1
Return TOX_ERR_CONFERENCE_SEND_MESSAGE_NO_CONNECTION if we are not connected to any peers 2018-11-23 17:53:50 +01:00
zugz (tox)
b56166f5a6
Add some hopefully helpful documentation to the functions in mono_time.h
(I found I couldn't remember whether get_mono_time returned unix time or
not, and had to source-dive to find out. This should make that
unnecessary next time!)
2018-10-31 19:34:52 +01:00
NamsooCho
15cc8050d2
Change method of PK production for fake friend in DHT 2018-10-24 13:05:32 +02:00
zugz (tox)
744dc2f5da
Make saving and loading the responsibility of Tox rather than Messenger 2018-10-20 11:03:10 +02:00
iphydf
aa5c782880
Add LOGGER_ASSERT for checking fatal error conditions.
These are not compiled out under `NDEBUG` and should be provably correct.
2018-10-19 18:08:46 +00:00
Leonid Bobrov
ed9beef61c
Support DragonFlyBSD and prune unused variables. 2018-10-16 22:01:00 +00:00
zugz (tox)
4dd86f1f29
ensure save data unchanged after save and load 2018-10-11 00:21:39 +02:00
iphydf
605dfe882c
Consistently use camel case enum names.
Including in tests and implementation files.
2018-10-09 17:33:37 +00:00