Commit Graph

39 Commits

Author SHA1 Message Date
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
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
ad26560516
Improve static and const correctness.
- Any non-externally-visible declarations should be `static`.
- Casting away the `const` qualifier from pointers-to-const is
  dangerous. All but one instance of this are now correct. The one
  instance where we can't keep `const` is one where toxav code actually
  writes to a chunk of memory marked as `const`. This code also assumes
  4 byte alignment of data packets. I don't know whether that is a valid
  assumption, but it's likely unportable, and *not* obviously correct.
- Replaced empty parameter lists with `(void)` to avoid passing
  parameters to it. Empty parameter lists are old style declarations for
  unknown number and type of arguments.
- Commented out (as `#if DHT_HARDENING` block) the hardening code that
  was never executed.
- Minor style fix: don't use `default` in enum-switches unless the number
  of enumerators in the default case is very large. In this case, it was
  2, so we want to list them both explicitly to be warned about missing
  one if we add one in the future.
- Removed the only two function declarations from nTox.h and put them
  into nTox.c. They are not used outside and nTox is not a library.
2016-09-06 11:54:37 +01:00
Gregory Mullen (grayhatter)
aad1e0ad3f
Make friend requests stateless
Messenger is slightly twisty when it comes to sending connection status
callbacks It will very likely need at the very least a partial refactor to
clean it up a bit. Toxcore shouldn't need void *userdata as deep as is
currently does.

(amend 1) Because of the nature of toxcore connection callbacks, I decided to
change this commit from statelessness for connections changes to statelessness
for friend requests. It's simpler this was and doesn't include doing anything
foolish in the time between commits.

group fixup because grayhatter doesn't want to do it

"arguably correct" is not how you write security sensitive code

Clear a compiler warning about types within a function.
2016-09-06 02:22:04 -07:00
iphydf
77db27331e
Sort #includes in all source files. 2016-09-01 16:35:46 +01:00
iphydf
633da98ae6
Add braces to all if statements. 2016-08-31 20:04:16 +01:00
iphydf
13ae9e9a93
Move logging to a callback.
This removes the global logger (which by the way was deleted when the first tox
was killed, so other toxes would then stop logging). Various bits of the code
now carry a logger or pass it around. It's a bit less transparent now, but now
there is no need to have a global logger, and clients can decide what to log and
where.
2016-08-27 01:16:14 +01:00
iphydf
6935643f9a
Fix some compiler warnings. 2016-08-18 17:10:15 +01:00
iphydf
a5e35180c7
Make tox_callback_friend_name stateless.
See #27 and #40 for details.
2016-08-18 00:01:53 +01:00
irungentoo
9a87f03aec
Onion test fixed to work with faster DHT. 2015-12-15 14:58:36 -05:00
irungentoo
cf436fde12
Fixed onion test. 2015-04-06 15:57:23 -04:00
irungentoo
d9ea6e9485
Properly free everything at the end of each test. 2015-02-07 22:57:04 -05:00
irungentoo
f463cb52a2
Code cleanups.
Rename array in Node_format from client_id to public_key.
2015-01-29 19:38:44 -05:00
irungentoo
6bbb939855
Cleaned up packet length types in toxcore.
They are now all uint16_t instead of sometimes being uint32_t.

Replaced some other uint32_t with unsigned ints.
2014-11-21 20:18:29 -05:00
irungentoo
f2a313359e
Added callbacks to onion_client and net_crypto for the temp dht key.
Better than the polling mess.

Moved DHT to Messenger from onion_client (still needs some cleanups).
2014-09-26 20:32:38 -04:00
irungentoo
78dd2234e0
Added basic socks5 proxy support to TCP client. 2014-08-14 14:31:26 -04:00
irungentoo
bc4fe2c80d
Decreased maximum onion_test test time. 2014-08-13 10:15:25 -04:00
pyruvate
ec9082f2c3 Remove DEFTESTCASE and DEFTESTCASE_SLOW redefinitions 2014-08-09 11:33:20 +03:00
irungentoo
881b2d900d
Fixed some warnings. 2014-06-15 20:49:39 -04:00
irungentoo
53cc5ea6a9
Fixed onion test. 2014-05-12 19:43:44 -04:00
irungentoo
0559904ea2
Updated some files so that they could build with latest core.
Fixed some issues.
2014-04-23 12:29:24 -04:00
irungentoo
be413de396
Fixed regression, announce responses can contain 0 nodes. 2014-04-15 19:16:35 -04:00
irungentoo
d0d9f95b34 Fixed onion test. 2014-02-27 16:59:17 -05:00
irungentoo
1c676147a2 Fixed/updated tests. 2014-02-26 12:46:11 -05:00
irungentoo
696a6ba02e Onion_test should be now a bit less failure prone. 2014-02-07 20:39:30 -05:00
irungentoo
7ccff33069 Made onion test taste more like onion. 2014-02-05 19:51:22 -05:00
irungentoo
a13e30e8bb Test passes now, uncommented it. 2014-01-30 14:59:31 -05:00
irungentoo
f1e0e16b67 A bit of tests added. 2014-01-29 20:59:50 -05:00
irungentoo
aff6b112c0 Merge branch 'onion' 2014-01-20 12:48:26 -05:00
Ben Iofel
174cec7f15 proper windows preprocessor detection 2014-01-19 19:30:14 -05:00
irungentoo
81dd4a8083 Fixed onion_test. 2014-01-19 14:41:29 -05:00
irungentoo
a49a09f94b Onion data packets can now be handled in onion_client.
oniondata_registerhandler(...) can be used to register different packet
types to handle them and send_onion_data(...) can be used to send these
packets.
2014-01-14 14:20:42 -05:00
irungentoo
ea7d1a726d Putting the sendback outside the encrypted part of the response.
It's more useful this way.
2014-01-09 19:54:42 -05:00
irungentoo
0fd8e49c38 Fixed problem in onion_announce.c
Added a way to know if a announce response is valid.
2014-01-08 20:15:35 -05:00
irungentoo
566c9f63bc onion_announce seems to be working perfectly.
Stuff added and fixed.
2014-01-06 17:59:44 -05:00
irungentoo
6cd1e7fb70 Tests added and some fixes for the onion part. 2014-01-05 19:22:38 -05:00
irungentoo
7e2d21271a Some work on the onion part done. 2014-01-04 19:40:43 -05:00
irungentoo
d46891c3b7 A bit of work done on the onion part. 2014-01-03 22:13:20 -05:00
irungentoo
97b9a9cf04 Added onion.c to build system and added a test. 2013-12-31 23:18:37 -05:00