Commit Graph

77 Commits

Author SHA1 Message Date
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
zugz (tox)
5beb00c93d
Fix memleak in tcp server by wiping priority queues on deletion 2018-10-07 20:13:51 +02: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
beeb9b4335
Style fixes in TCP code; remove MIN and PAIR from util.h.
* Moved PAIR to toxav, where it's used (but really this should die).
* Replace most MIN calls with typed `min_*` calls. Didn't replace the
  ones where the desired semantics are unclear. Moved the MIN macro to
  the one place where it's still used.
* Avoid assignments in `while` loops. Instead, factored out the loop body
  into a separate `bool`-returning function.
* Use named types for callbacks (`_cb` types).
* Avoid assignments in `if` conditions.
* Removed `MAKE_REALLOC` and expanded its two calls. We can't have
  templates in C, and this fake templating is ugly and hard to analyse
  and debug (it expands on a single line).
* Moved epoll system include to the .c file, out of the .h file.
* Avoid assignments in expressions (`a = b = c;`).
* Avoid multiple declarators per struct member declaration.
* Fix naming inconsistencies.
* Replace `net_to_host` macro with function.
2018-07-12 20:21:42 +00:00
iphydf
abc17b0f89
Factor out time keeping code into its own module: mono_time.c.
It turns out, `unix_time` is also monotonic, and is used as such, so I've
renamed the new functions to `mono_time_*`.

2018-07-08:
```
00:01 <@irungentoo> the idea used to be that the unix_time() function
  could go backward in time but I think I might have started using it like
  if it could not after I changed it so that it would never go back in time
```
2018-07-09 21:04:50 +00:00
iphydf
21675ce0d2
Finish @Diadlo's network Family abstraction.
The Family stuff in toxcore is a big mess. I'm sure I saw a bunch of bugs
on the way, but I'm not verifying that code now, so the bugs stay.
2018-05-20 19:35:28 +00:00
iphydf
be797d4b03
Move system header includes from network.h to network.c 2018-05-20 15:42:42 +00:00
iphydf
d3b286cb43
Fix a bunch of compiler warnings and remove suppressions. 2018-02-24 22:20:22 +00:00
iphydf
35f13ef51d
Get rid of the only GNU extension we used. 2018-02-14 20:51:55 +00:00
iphydf
92ffad1a72
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
2018-01-30 23:35:50 +00:00
iphydf
da739a9438
Add random_u16 function and rename the others to match. 2018-01-14 21:08:02 +00:00
iphydf
bacd74c4dd
Make TCP_Client_Connection a module-private type. 2018-01-14 19:13:32 +00:00
Diadlo
e28d48130f
Add platform independent constants 2017-08-24 20:09:08 +03:00
Diadlo
66b8a7685e
AF_INET -> TOX_AF_INET 2017-08-24 20:09:08 +03:00
iphydf
1e8fa85aad
Add a monolith_test that includes all toxcore sources.
This requires that every symbol, even if static (file-scope), is unique.
The idea is that we can easily run "whole" program static analysis on
programs that include monolith.h ("whole" is in quotes, as we don't
include dependencies like libsodium in this static analysis).
2017-06-04 17:48:23 +00:00
Maxim Biro
c7f63737eb Revert "Implement tox_loop"
This reverts commit 5ff099763b.
2017-04-22 15:31:25 -04:00
Ansa89
5ff099763b
Implement tox_loop 2017-04-01 17:47:34 +02:00
Diadlo
b19a9e5464
Add part of platform-independent network API implementation
socket      -> net_socket
htons       -> net_htons
htonl       -> net_htonl
connect     -> net_connect
sendto      -> net_sendto_ip4
getaddrinfo -> net_getipport
sa_family_t -> Family
2017-02-26 23:16:16 +03:00
iphydf
6ae33c16cf
Add VLA compatibility macro for C89-ish compilers. 2017-01-28 20:49:12 +00:00
Diadlo
f00006cf1d
Add platform-independent Socket and IP implementation 2017-01-26 23:11:15 +03:00
iphydf
8f96ca6d86
Update license headers and remove redundant file name comment.
"All rights reserved" was incorrect. The project was licensed under GPL3,
which means a lot of rights are licensed to everybody in the world, i.e.
not reserved to the "Tox Project".
2017-01-19 00:01:44 +00:00
iphydf
ce29c8e7ec
Wrap all sodium/nacl functions in crypto_core.c. 2016-12-22 10:26:59 +00:00
iphydf
aed24408db
Remove new_nonce function in favour of random_nonce.
`new_nonce` has been an alias for `random_nonce` for a while now. Having
two names for the same operation is confusing. `random_nonce` better
expresses the intent. The documentation for `new_nonce` talks about
guaranteeing that the nonce is different from previous ones, which is
incorrect, it's just quite likely to be different.
2016-11-09 22:30:49 +00:00
iphydf
96c672aef5
Compile as C++ for windows builds.
Compiling as C++ changes nothing semantically, but ensures that we don't
break C++ compatibility while also retaining C compatibility.

C++ compatibility is useful for tooling and additional diagnostics and
analyses.
2016-11-02 18:50:41 +00:00
iphydf
15cb426166
Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
2016-09-24 21:53:50 +01:00
iphydf
1494e474dd
Ensure that all TODOs have an owner.
In the future, all TODOs added either need a bug number (TODO(#NN)) or a
person's github user name. By default, I made irungentoo the owner of
all toxcore TODOs, mannol the owner of toxav TODOs, and myself the owner
of API TODOs.
2016-09-16 12:06:02 +01:00
iphydf
45d28904b9
Use <stdbool.h> and replace _Bool with bool.
This header is a requirement for the public API, therefore is assumed to
exist. It is a C99 standard library header, and _Bool is not intended to
be used directly, except in legacy code that defines bool (and
true/false) itself. We don't use or depend on such code. None of our
client code uses or depends on such code. There is no reason to not use
bool.
2016-09-13 22:01:45 +01:00
iphydf
0aa2840164
Group #include directives in 3-4 groups.
1. Current module (if C file).
2. Headers from current library.
3. Headers from other library (e.g. toxcore includes in toxav).
4. System headers.
2016-09-13 00:32:02 +01:00
iphydf
a9fbdaf46b
Do not use else after return.
http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
2016-09-02 11:02:56 +01:00
iphydf
633da98ae6
Add braces to all if statements. 2016-08-31 20:04:16 +01:00
iphydf
a5e35180c7
Make tox_callback_friend_name stateless.
See #27 and #40 for details.
2016-08-18 00:01:53 +01:00
Roman Proskuryakov
23b0c9cded fix: replace memset with sodium_memzero for sensitive data 2016-01-27 02:17:40 +03:00
Roman Proskuryakov
b3655f2c60 add: comments about hairy code 2016-01-27 02:14:59 +03:00
irungentoo
e4ae993a80
Some small fixes.
Increased interval between onion key changes to 2 hours.
2015-04-20 20:40:32 -04:00
irungentoo
be014f9e3c
Fixed memory leak in TCP connection. 2015-04-15 19:52:13 -04:00
irungentoo
efea858c91
Make it possible to port clients to the new api by just replacing
proxy_enabled with proxy_type.
2014-12-26 20:33:34 -05:00
irungentoo
c2e394c5c2
Fixed bug with auto tests and cleaned up the code a bit. 2014-12-26 20:12:51 -05:00
Maxim Biro
35602e12c0 Further refactoring of proxy code 2014-12-21 21:00:46 -05:00
Maxim Biro
e9bf38499e Some refactoring of proxy code 2014-12-21 19:59:00 -05:00
Maxim Biro
377da127a1 Added HTTP proxy support 2014-12-13 23:59:50 -05:00
irungentoo
411457dc8f
Fixed gcc warnings. 2014-08-28 20:54:05 -04:00
irungentoo
bb1bb58352
Set socket family to family of proxy when using proxy. 2014-08-15 12:06:13 -04:00
irungentoo
78dd2234e0
Added basic socks5 proxy support to TCP client. 2014-08-14 14:31:26 -04:00
Jfreegman
82c40b9c8a
remove unneeded printf's/prevent stdout spam 2014-08-03 15:56:09 -04:00
irungentoo
bcfb1261ac
Fixed possible bug with TCP nonce not getting incremented. 2014-07-16 20:39:58 -04:00
irungentoo
1e69af8cff
Merge branch 'split-video' of https://github.com/notsecure/toxcore 2014-07-16 20:38:53 -04:00
notsecure
e04fff3eac applied priority queue changes to the TCP client too 2014-07-16 08:33:24 -04:00