Commit Graph

828 Commits

Author SHA1 Message Date
iphydf
ce29c8e7ec
Wrap all sodium/nacl functions in crypto_core.c. 2016-12-22 10:26:59 +00:00
Gregory Mullen (grayhatter)
ad517eb1df
add NAT hole punching level to Tox API 2016-11-24 17:38:34 -08:00
iphydf
656f0b9112 Support float32 and float64 in msgpack type printer. 2016-11-21 02:25:11 +00:00
Maxim Biro
a403c996b5 Fix a memory leak in hstox interface 2016-11-20 20:14:53 -05:00
Mikhael-Danilov
06ad5613bc Support arbitrary video resolutions in av_test 2016-11-12 20:10:56 +03:00
iphydf
fe1fea82c3
Add decode/encode PlainText test support.
These are implemented in terms of decode/encode CipherText. They do the
exact same thing, since they are both simple length-prefixed byte arrays.
2016-11-11 00:00:37 +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
42dfdf73c1
Add spectest to the cmake test suite.
This allows for easier development. It is not used on travis (yet).
2016-11-08 21:58:26 +00:00
iphydf
82515f92ee
Move log callback to options.
Previously, all log messages generated by tox_new (which is quite a lot)
were dropped, because client code had no chance to register a logging
callback, yet. This change allows setting the log callback from the
beginning and removes the ability to unset it.

Since the log callback is forever special, since it can't be stateless,
we don't necessarily need to treat it uniformly (with `event`).
2016-11-06 20:35:09 +00:00
iphydf
cf94537266
Enable all possible C compiler warning flags.
We disable the ones that fire, so we can use -Werror. We can then
investigate each warning individually and see whether to fix it or to
keep silencing it.
2016-11-06 01:32:10 +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
c037100747
Import the hstox SUT interface from hstox.
We'll maintain it in the c-toxcore repo, where it belongs.
2016-10-01 02:13:34 +01:00
iphydf
1977d56caa
Remove return after no-return situation (and other cleanups).
Cleanups:
- Fix header guards to not use reserved names.
- Avoid name shadowing.
- Removed an unused variable found by avoiding name shadowing.
2016-09-30 19:06:44 +01:00
iphydf
d369448ace
Work around bug in opencv3 headers.
OpenCV 3.1 doesn't define cvRound in C, only in C++. Thus, we now need
to compile av_test as C++ code.
2016-09-25 01:58:51 +01:00
iphydf
f60900c4b8
Move ring buffer out of toxcore/util into toxav.
Toxcore itself doesn't use this data structure. Only toxav does, so now
toxav owns the code for it.
2016-09-24 23:36:50 +01: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
0d347c2b2e
Minor cleanups: unused vars, unreachable code, static globals.
- All global variables should be static unless they have an explicit
  extern declaration in a header file.
- `to_compare` was not used in encryptsave and toxav tests.
- `break` in switch cases is not required directly after `return`,
  `goto`, or a noreturn function like `abort`.
2016-09-24 20:52:09 +01:00
Jfreegman
dd2965a58f Make group callbacks stateless 2016-09-21 15:33:55 -04:00
iphydf
51d18236c8
Revert "Make ToxAV stateless"
This reverts commit 21f8db12c4.

It is currently broken. Incoming call callbacks are not invoked, and
instead the client goes offline immediately.
2016-09-19 21:53:40 +01:00
Jfreegman
8e43ca834c Complete old groupchat conversion to new API 2016-09-17 19:11:28 -04:00
iphydf
c0397a0a46 ApiDSL'ing old group chats (now: conference). 2016-09-17 19:11:28 -04:00
Gregory Mullen (grayhatter)
21f8db12c4
Make ToxAV stateless 2016-09-17 14:05:51 -07:00
iphydf
80cc32a79d
Use C99 %zu format conversion in printf for size_t.
size_t is unsigned long long on LLP64 and %lu prints unsigned long (32
bit), potentially causing problems.
2016-09-17 10:19:49 +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
a8823830d3
Add some astyle options to make it do more.
It now enforces a bit more formatting. In particular, padding inside
parentheses is removed. I would like it to remove padding after unary
operators, but there seems to be no option for that.
2016-09-13 01:07:02 +01:00
michael bishop
05f474b4df
make the majority of the callbacks stateless and add some status to a testcase 2016-09-10 01:09:37 -03: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
iphydf
5b57ab6332
Improve C standard compliance.
- Don't cast between object and function pointers.
- Use standard compliant `__VA_ARGS__` in macros.
- Add explicit `__extension__` on unnamed union in struct (it's a GNU
  extension).
- Remove ; after function definitions.
- Replace `const T foo = 3;` for integral types `T` with `enum { foo = 3 };`.
  Folding integral constants like that as compile time constants is a GNU
  extension. Arrays allocated with `foo` as dimension are VLAs on strictly
  compliant C99 compilers.
- Replace empty initialiser list `{}` with zero-initialiser-list `{0}`.
  The former is a GNU extension meaning the latter.
- Cast `T*` (where `T != void`) to `void *` in format arguments. While any
  object pointer can be implicitly converted to and from `void *`, this
  conversion does not happen in variadic function calls.
- Replace arithmetic on `void *` with arithmetic on `char *`. The former
  is non-compliant.
- Replace non-`int`-derived types (like `uint16_t`, which is
  `short`-derived) in bit fields with `int`-derived types. Using any type
  other than `int` or `unsigned int` (or any of their aliases) in bit
  fields is a GNU extension.
2016-09-06 11:09:10 +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
aa0e3974c5
Add TODO for @mannol. 2016-09-05 22:44:06 +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
6f42eadc54
Replace pthread_yield with sched_yield.
The former is a non-standard glibc extension. On linux, it is implemented as a
call to sched_yield, so this change does nothing there. On OSX, pthread_yield
doesn't exist, and we already use sched_yield.
2016-09-02 09:55:00 +01:00
iphydf
77db27331e
Sort #includes in all source files. 2016-09-01 16:35:46 +01:00
iphydf
ad13518153
Add missing #include <pthread.h> to av_test.c.
It was an undefined function before.
2016-09-01 15:22:03 +01:00
iphydf
3a9300368d
Add newlines because astyle wants them.
We'll revert this once we move to clang-format.
2016-08-31 20:54:20 +01:00
iphydf
633da98ae6
Add braces to all if statements. 2016-08-31 20:04:16 +01:00
iphydf
6356eb4e4f
Enable build of av_test.
It has not been built in a while. We do want to keep this one working (or at
least compiling).
2016-08-31 20:02:41 +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
Gregory Mullen (grayhatter)
1f94c96266
Make the friend message callback stateless 2016-08-20 11:07:49 -07:00
iphydf
bdf5ac37b4
Make friend_status_message callback stateless.
See #40 for details.
2016-08-18 17:19:23 +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
iphydf
db22522741
Add missing DHT_bootstrap to CMakeLists.txt.
- This PR also adds a DEBUG cmake option that enables -DTOX_DEBUG.
- We also remove `-Wall`, because there are too many warnings, and nobody really
  looks at them at the moment. We'll see about fixing them soon. We'll also want
  to enable `-Werror` at some point.
- Finally, this PR enables `-O3` to make sure toxcore still works correctly
  under heavy compiler optimisations.
2016-08-17 22:12:39 +01:00
iphydf
dd8a568141
Make self_connection_status callback stateless.
**What are we doing?**

We are moving towards stateless callbacks. This means that when registering a
callback, you no longer pass a user data pointer. Instead, you pass a user data
pointer to tox_iterate. This pointer is threaded through the code, passed to
each callback. The callback can modify the data pointed at. An extra indirection
will be needed if the pointer itself can change.

**Why?**

Currently, callbacks are registered with a user data pointer. This means the
library has N pointers for N different callbacks. These pointers need to be
managed by the client code. Managing the lifetime of the pointee can be
difficult. In C++, it takes special effort to ensure that the lifetime of user
data extends at least beyond the lifetime of the Tox instance. For other
languages, the situation is much worse. Java and other garbage collected
languages may move objects in memory, so the pointers are not stable. Tox4j goes
through a lot of effort to make the Java/Scala user experience a pleasant one by
keeping a global array of Tox+userdata on the C++ side, and communicating via
protobufs. A Haskell FFI would have to do similarly complex tricks.

Stateless callbacks ensure that a user data pointer only needs to live during a
single function call. This means that the user code (or language runtime) can
move the data around at will, as long as it sets the new location in the
callback.

**How?**

We are doing this change one callback at a time. After each callback, we ensure
that everything still works as expected. This means the toxcore change will
require 15 Pull Requests.
2016-08-17 14:57:20 +01:00
Roman Proskuryakov
ed3a794c9b fix: compare sensitive data with sodium_memcmp
fix: make increment_nonce & increment_nonce_number independent of user-controlled input
	fix: make crypto_core more stable agains null ptr dereference
2016-01-27 02:14:59 +03:00
irungentoo
6a494e2cbd
Astyle. 2015-11-03 13:42:05 -05:00
Eniz Vukovic
d6fdf16520 New Adaptive BR algorithm, cleanups and fixes 2015-10-10 23:54:23 +02:00
mannol
c641b0fceb Updated with upstream 2015-08-09 12:39:21 +02:00
irungentoo
2ab3b14731
Merge branch 'dragonfly' of https://github.com/mneumann/toxcore 2015-08-08 21:38:23 -04:00
mannol
3c8cae72d0 Removed redundant function from video.[h|c] 2015-08-08 17:45:24 +02:00
irungentoo
6cb8ff4d65
Removed a useless define. 2015-08-07 20:53:53 -04:00
Michael Neumann
caebc5303a Fix for DragonFlyBSD 2015-08-08 01:45:55 +02:00
mannol
657a57b406 Fixed memory leak during session cleanup and fixed naming. 2015-08-07 02:04:04 +02:00
irungentoo
dfc154cc9e
client_id -> public_key 2015-07-29 22:39:56 -04:00
mannol
2ecb71bb1e Renamed TOXAV_CALL_STATE to TOXAV_FRIEND_CALL_STATE 2015-06-27 17:28:07 +02:00
mannol
a3132feddb Fixed sample size in callback and other stuff 2015-06-13 15:00:34 +02:00
mannol
d694839d60 Rebased on master and removed alpha channel (again) 2015-06-05 22:14:37 +02:00
irungentoo
8e80ced6ce
Move savedata to options struct.
Add a way to select the type of savedata (normal savedata, load a
secret key, potentially others?) to load.
2015-05-22 18:23:56 -04:00
mannol
3100042a2b Updated with master 2015-05-22 23:22:31 +02:00
irungentoo
782d68cdc3
Syncbot fixes. 2015-05-20 14:09:05 -04:00
mannol
73fbc22961 Fixed inconsistencies 2015-05-07 23:14:03 +02:00
mannol
9bba7a0434 Done 2015-04-29 01:01:25 +02:00
irungentoo
b0983104d5
Renamed tox_file_send_control to tox_file_control.
Renamed tox_file_send_seek to tox_file_seek.
2015-03-21 08:58:54 -04:00
Dubslow
d8da9bf709
callback_file_request_chunk -> callback_file_chunk_request
A couple of minor reasons, combined warrant a PR imo:
a) fileChunkRequested is a better signal name than fileRequestChunkReceived, and I don't want to break consistency by reordering words for just this signal
b) "request chunk" is parsed by English speakers as a verb-object combination,
   implying sending the request, not receiving, whereas "chunk requested" is
   parsed (more correctly) as an adjective-noun combo (in particular, request is
   a noun not a verb), and thus reads far more like "hey heads up we just got a request"

For instance some tests/testing code had some callbacks to *receive* chunk requests, and they were called "tox_file_request_chunk"... to receive a chunk, not request it. Now they're called "tox_file_chunk_request".

So yeah...
2015-03-19 08:38:27 -05:00
irungentoo
e0bd6ef4e0
Renamed TOX_MESSAGE_TYPE_MESSAGE to TOX_MESSAGE_TYPE_NORMAL. 2015-03-18 17:14:57 -04:00
irungentoo
45cf8a744c
Merge branch 'one_more_rename' of https://github.com/dubslow/toxcore into new_api 2015-03-18 16:15:36 -04:00
irungentoo
d711362622
Merged normal message function and send action function into one
messaging function.

This removes code duplication and allows us to easily add new message
types to the api without having to add new functions.
2015-03-18 15:32:53 -04:00
Dubslow
2f65de6fd1
Move get_connection_status to self pseudonamespace, to contrast friend_get_connection_status 2015-03-18 14:18:36 -05:00
irungentoo
b9e747fd50
When friend goes offline all his file transfers get removed.
This is now documented in the API.

Ported programs in testing/ to this behaviour.
2015-03-18 14:39:52 -04:00
irungentoo
5b7cbc8956
Api changes.
receive to recv in file receive functions.

Added TOX_MAX_FILENAME_LENGTH define.
2015-03-18 12:54:00 -04:00
irungentoo
8286c2c22f
Save function renamed to tox_get_savedata() 2015-03-17 16:20:38 -04:00
irungentoo
24c70c9e84
Added and implemented file_id parameter to file tranfers.
file_id is a 32byte identifier that can be used by users to identify
file tranfers across core/client restarts in order to resume broken
file tranfers.

In avatar tranfers it corresponds to the hash of the avatar.

Added tox_file_get_file_id() function to api to obtain the file_id
of an ongoing file transfer.

If not set, core will generate a random one.
2015-03-17 13:44:48 -04:00
irungentoo
6cf7270638
Make nTox save on exit. 2015-03-14 10:05:39 -04:00
irungentoo
c3e07b73d3
Remove TOX_FILE_KIND typedef. 2015-03-13 15:38:44 -04:00
irungentoo
8e2957ec50
Merge branch 'newer_api' of https://github.com/dubslow/toxcore into new_api 2015-03-13 15:29:34 -04:00
Dubslow
64fefb6f43
revert to TOX_FILE_KIND 2015-03-13 12:34:14 -05:00
Dubslow
3bf259f69d Convert core code depending on the api 2015-03-12 18:23:14 -05:00
irungentoo
8dc2db2025
Added position parameter to tox_file_send_chunk().
This is done so that the function now has the same parameters as the
request chunk callback.
2015-03-12 15:17:34 -04:00
irungentoo
7afab000f7
tox_new now sets error to TOX_ERR_NEW_PORT_ALLOC when binding to port fails. 2015-03-12 13:03:14 -04:00
irungentoo
8e55d96381
Ported nTox to new file transfer api. 2015-03-10 18:49:06 -04:00
irungentoo
c434d48579
testing/tox_sync now fully works on the new api. 2015-03-10 18:29:10 -04:00
irungentoo
f5eca31637
Fixed small issue. 2015-03-09 20:59:50 -04:00
irungentoo
d83efd35dd
Ported some of the code in testing/ to the new api. 2015-02-24 20:29:01 -05:00
Alexandre Erwin Ittner
c2421e6f21 Update avatar documentation
Add missing function and fixes some typos and formatting.
2015-01-31 20:13:39 -02:00
Alexandre Erwin Ittner
eea4153594 Rename "client id" to "public key" in avatar docs and examples
Commit b8d530c9e0 and some of its
parents changed the public name of "client id" to "public key".
Update the avatar documentation to follow the idea.
2015-01-31 19:45:03 -02:00
irungentoo
534efc7349
Fixed irc syncbot. 2014-11-10 18:03:09 -05:00
irungentoo
94ac524374
Group audio might work now but I have not tested anything yet. 2014-11-10 17:59:14 -05:00
dubslow
ca38ee8bc7 fix #1120 2014-10-17 06:04:08 -05:00
irungentoo
9ef1be1b6f
Use monotonic time function already in toxcore. 2014-10-15 13:28:19 -04:00
irungentoo
3d1c0f0536
irc_syncbot now parse out NULL characters from the Tox groupchat. 2014-10-15 09:01:00 -04:00
irungentoo
6985353392
Added basic IRC group syncbot to testing. 2014-10-14 19:49:29 -04:00
irungentoo
e304fa847e
Group chats now actually work somewhat. 2014-10-01 15:28:27 -04:00
dubslow
57666d95ba Merge branch 'master' of https://github.com/irungentoo/toxcore 2014-09-28 12:37:47 -05:00
Alexandre Erwin Ittner
3711b881cb test_avatars: Implement new policy for the user avatar file
Change location of the user avatar from "<data dir>/avatar.png" to
"<data dir>/avatars/<user id>.png", as proposed by commit
6f4ab49f5c
2014-09-27 23:11:53 -03:00
irungentoo
33721da46a
Added callbacks to DHT called when the ip of a peer is discovered. 2014-09-26 17:56:06 -04:00
irungentoo
8b35d194c0
Group chats are starting to work. 2014-09-26 13:25:52 -04:00
irungentoo
d264010364
Tox object doesn't need to be passed to tox_hash. 2014-09-25 07:18:44 -04:00
irungentoo
80fdfbad07
Merge branch 'master' of https://github.com/dubslow/toxcore 2014-09-25 07:16:49 -04:00
dubslow
d409bad30d remove tox_avatar_hash 2014-09-24 18:06:30 -05:00
irungentoo
bce301f3c3
Merge branch 'stal888-patch-1' 2014-09-24 18:00:17 -04:00
dubslow
ba6ae15a73 housekeeping 2014-09-24 13:00:42 -05:00
stal
f27794000a ifdef out use of linux/limts.h in test_avatars
This fixes building on OS X and other systems whose limits.hs have PATH_MAX.
2014-09-23 20:47:21 -07:00
irungentoo
b52da45aeb
Merge branch 'avatars' of https://github.com/ittner/toxcore 2014-09-22 15:07:14 -04:00
Alexandre Erwin Ittner
70b4018069 Remove support for avatar image formats other than PNG
Support for other formats was deemed unnecessary in the code review
and therefore removed. The value for the constant TOX_AVATARFORMAT_PNG
is now set in stone; if the other formats become needed again in the
future, this commit shall be reverted and the enum values reordered to
keep compatibility.
2014-09-21 10:25:46 -03:00
Alexandre Erwin Ittner
e4f66475d8 Add support for user avatars in the core protocol
Add a protocol and the APIs to straightforwardly support user avatars
in client applications. The protocol is designed to transfer avatars
in background, between friends only, and minimize network load by
providing a lightweight avatar notification for local cache validation.
Strict safeguards are imposed to avoid damage from non-cooperative or
malicious users and to limit network usage.

The complete documentation is available in docs/Avatars.md and sample
code is available in testing/test_avatars.c.

Code and documentation are released under the GNU GPLv3 or later, as
described in the file COPYING.
2014-08-30 16:43:07 -03:00
Maxim Biro
bc5daa5eff Added FreeBSD include 2014-08-23 23:20:00 -04:00
stal
62e6e9bc07 Daily OS X fix.
Patch also fixes NetBSD and OpenBSD, but I can't test that.

<pty.h> is <util.h> on some BSDs.
2014-08-20 09:28:26 -07:00
irungentoo
7330ebdffe
Added tox_shell to testing.
tox_shell is a basic secure shell that can be used to control a
computer from any Tox client.

Just run tox_shell and make it add your Tox id.

It's very basic but it works.
2014-08-19 19:01:18 -04:00
irungentoo
7557b92fc9
Modified tox_bootstrap_from_address() function.
PORT IS NO LONGER PASSED IN NETWORK BYTE ORDER.

Removed useless ipv6enabled parameter.
2014-08-14 19:01:21 -04:00
irungentoo
ef78169842
Added disabling of UDP and basic SOCKS5 proxy support to public API.
tox_new() now takes a Tox_Options struct as argument.

If a NULL pointer is passed to that struct, defaults are used.
2014-08-14 18:34:20 -04:00
irungentoo
1298932deb
UDP can now be disabled.
new_messenger() now takes an options struct as an argument.
2014-08-14 15:27:34 -04:00
irungentoo
a679756eca
crypto speed test is pretty useless, removed it. 2014-08-06 20:56:27 -04:00
irungentoo
c4f0650ae3
Fixed const related warnings. 2014-07-02 16:04:41 -04:00
Marc Schütz
8391417f61 Const correctness for toxcore/Messenger.c and related files 2014-06-30 21:26:50 +02:00
Tux3 / Mlkj / !Lev.uXFMLA
3044bd8101 Fix CppCheck style errors
#if 0 the content of toxav/msi.c : int stringify_message(MSIMessage
*msg, char *dest)
This function has no effect and does not seem to be used for actively
waiting.

Fix various other style errors, reduce scope when possible, avoid
redundant writes, clarify operator priorities, etc.
2014-06-20 21:43:21 +02:00
irungentoo
3c64c87ea7
dns3_test now automatically does the DNS request.
tox_decrypt_dns3_TXT no longer needs id_record to be null terminated.
2014-06-19 10:50:46 -04:00
irungentoo
d6a9ce3175
Fixed some issues in toxdns and added a test.
Added request_id.

request_id must be obtained with tox_generate_dns3_string, stored,
then passed to tox_decrypt_dns3_TXT when we want to decrypt the
received response.
2014-06-14 11:31:56 -04:00
irungentoo
c49d74a125
Attempt fix of tox_sync not building on some systems. 2014-06-13 05:38:19 -04:00
irungentoo
07936960df
Astyle and fixes. 2014-06-10 18:35:55 -04:00
Marc Schütz
99d5940140 Const correctness in various interdependent files 2014-06-10 20:54:48 +02:00
irungentoo
7a11c10429
Fixed some nTox bugs. 2014-06-08 09:21:37 -04:00
liuguangzhao
9aa28c10b8 fix nTox cmdline input slow problem. 2014-06-08 14:08:52 +00:00
irungentoo
1bad0b5eea
Fixed TOX_MAX_MESSAGE_LENGTH define.
Removed some useless code from toxcore.

Astyled core code with new version of astyle.
2014-06-01 18:55:52 -04:00
Maxim Biro
24c6db5968 Fixed the undefined reference to pow error 2014-05-31 13:16:08 -04:00
irungentoo
89bf08287d
Renamed tox_do_run_interval to tox_do_interval.
tox_do_interval now returns a time in ms based on how much action
is going on in net_crypto.
2014-05-30 23:01:17 -04:00
irungentoo
0e814904e4
Replaced tox_wait* functions with tox_do_run_interval().
Build system fixes.
2014-05-30 13:20:36 -04:00
irungentoo
ec25f64407
Fixed Tox sync. 2014-05-28 18:27:35 -04:00
irungentoo
8e24771fc4
Remove Lossless UDP (This breaks Tox.) 2014-05-02 10:36:48 -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
9c6a8432ce Crypto related cleanups.
Moved Bunch of functions from net_crypto to crypto_core.

decrypt_data_fast and decrypt_data_symmetric were the same thing
therefore, removed decrypt_data_fast.

Replaced all the crypto_secretbox_* defines with the equivalent
crypto_box_* one.

New define: crypto_box_KEYBYTES that is equal to
crypto_box_BEFORENMBYTES.
2014-04-21 16:51:36 -04:00
irungentoo
4f1e02bafa
tox_group_get_names now returns a list of name lengths along with the list of names.
TCP test now also tests pings.
2014-03-31 20:37:03 -04:00
Jin^eLD
70475d281d Fix NaCl builds for *BSD
From what I see there is a difference between *BSD and Linux when
linking vs. toxcore which has been bulit vs. the NaCl library:

on Linux it only links if NaCl's object files (i.e. randombytes.o) is
present in the linker options, however on *BSD systems this will cause a
linking error, see:
https://github.com/Tox/toxic/issues/31#issuecomment-38224441

This commit makes sure that we do not add the NaCl object files to our
pkg-config settings on *BSD, but do add them on Linux.
2014-03-23 02:05:57 +01:00
irungentoo
f7beb70fe9 nTox fixes.
Added TOX_MAX_MESSAGE_LENGTH to tox.h
2014-03-18 20:45:03 -04:00
irungentoo
5770a0e29a Merge branch 'api-fix'
Main changes:
1. Strings no longer need to be NULL terminated.
2. tox_get_friend_id is now named tox_get_friend_number.
3. The friend request callback function is now (Tox *tox, uint8_t *,
uint8_t *, uint16_t, void *), the Tox object pointer has been added to
it.
2014-03-18 20:02:50 -04:00
irungentoo
5babb281c0 Friend request callback now contains the Tox object. 2014-03-16 13:24:39 -04:00
Kelong Cong
a13de8b105 updated compilation and execution instructions for Lossless UDP tests, and fixed minor typos 2014-03-12 21:40:52 +00:00
seshagiriprabhu
9bb27fbea6 bound checking in messenger testing 2014-02-25 22:18:27 +05:30
seshagiriprabhu
bcb393d336 Added bound checking for friend ID input in DHT test 2014-02-25 21:21:21 +05:30
Maxim Biro
5a142bb697 Renamed dht server to dht node 2014-02-22 17:07:15 -05:00
irungentoo
554afe11d7 Some api changes. 2014-02-21 11:38:04 -05:00
irungentoo
7a2ed25d36 Astyled and removed some useless files. 2014-02-09 09:43:16 -05:00
Maxim Biro
3782213b6e Fixed build 2014-02-09 03:22:24 -05:00
Maxim Biro
ecbceac341 Fixed memory leaks and removed repeated code 2014-02-09 02:01:04 -05:00
Maxim Biro
5fad72b910 Modified hex_string_to_bin 2014-02-09 00:58:15 -05:00
irungentoo
15d01ca746 Updated DHT server list with onion supporting DHT servers.
Onionised DHT_test.
2014-01-20 15:20:17 -05:00
Ben Iofel
174cec7f15 proper windows preprocessor detection 2014-01-19 19:30:14 -05:00
irungentoo
a6d5a54c79 Fixed ntox building on windows. 2013-12-19 12:36:51 -05:00
irungentoo
15d17b0a3c Astyled the code. 2013-12-16 20:49:24 -05:00
irungentoo
7cd43ecc76 Merge branch 'master' into harden 2013-12-06 22:51:17 -05:00
AZ Huang
2cb7f24132 Fix typo. 2013-11-29 23:38:06 +08:00
AZ Huang
8419d3469a Fix API name consistency. 2013-11-29 23:12:07 +08:00
AZ Huang
eec31edb1c Fix return code inconsistency. 2013-11-29 18:26:09 +08:00
Coren[m]
26fef7cf9a
Various changes to nTox including a potential crash (also possible from remote!), and a tiny change to toxcore.
Crash stuff:

nTox.c:
- do_refresh(): avoid crashes (input a "%" and the client goes "boom!", send someone a string with embedded "%" and see him blow up...)

Other stuff:

toxcore: tox.h (doc.)/network.c (code):
- networking_wait_prepare(): return -1 if lenptr was NULL and therefore not settable

nTox.c:
- fraddr_to_str(): function to convert a TOX_FRIEND_ADDRESS into a segmented (and therefore line-breakable) string
- print_friendlist(): print index of friend on name line, print id on 2nd line
- command /f: skip spaces (and +) inside a friend id
- command /r (new): "/r #" to remove a friend
- main(): reduce cpu consumption if we're not currently sending files
2013-11-27 21:00:23 +01:00
Coren[m]
a204b95c51
Print a more detailed message on CHAT_CHANGE_PEER_DEL, so a user isn't confounded by the change of peer numbers.
On deleting the last peer, it's just a delete.
On deleting any other peer, the last peer is moved into that space, gaining a different number.
Print that detail where appropriate.
2013-11-26 18:55:11 +01:00
Coren[m]
e85e9dbb99
group_namelistchange(): for ui reasons, divulge the peernumber and the nature of the change (add, del, name change).
tox.*, Messenger.*, group_chats.*:
- expand interface of callback by peernumber/change

groupchats.c:
- call callback in addpeer/delpeer/setnick with peernumber and flag

nTox.c:
- print_groupchatpeers(): print as many names on a line as possible, not one peer per line
- print_groupnamelistchange(): only print the change, if possible (i.e. "new peer", "peer's new name")
- added command "/p" to print the list of peers
2013-11-24 21:12:26 +01:00
irungentoo
f21a9a7666 Added callback that tells you when the peer name list of a group chat changes. 2013-11-23 17:19:02 -05:00
irungentoo
d2b56faded Added function to get the number of peers and list of names for group chats. 2013-11-22 23:31:55 -05:00
Coren[m]
ca621bd440
Wrapping: Expanded space of output to be a bit larger than input. Basic wrap(): Embed continuation markers if there's enough space. 2013-11-14 02:45:37 +01:00
Coren[m]
bde536f6bc
Add a "conversation mode", where you set your conversation partner once and then all non-commands are sent as message to them.
/cf # rsp. /cg # sets, /cr resets target

Also reformatted display of sent group message slightly to look less beta-ish.
Then using "#<num>" for group number vs. "<num>" for friend/peer numbers.
Also changed to a slightly different message on people without name.
2013-11-13 22:34:02 +01:00
irungentoo
244c625e51 Merge branch 'group_peername' of https://github.com/FullName/ProjectTox-Core into FullName-group_peername 2013-11-12 19:41:52 -05:00
Coren[m]
6d31a9be7e
Group chat: Add a nickname message. Remove strange default nickname. (Seriously...)
group_chats.*:
- group_send_nick() to send own name
- setnick() to store a received name

Messenger.c:
- group_send_nick() before group_sendmessage() (in regular intervals, to inform new peers)

nTox.c:
- print_groupmessage(): on error or on a name of length zero the result of tox_group_peername() isn't null-terminated, catch that
2013-11-12 19:57:01 +01:00
Coren[m]
e457eb6635
Undo faulty newlines, undo extra newlines. 2013-11-12 14:17:48 +01:00
Coren[m]
553aba0498
nTox.c:
- multiple places: tox_getname() doesn't terminate the string, make sure nTox does
- format_message():
.  - renamed to print_formatted_message()
.  - changed semantics: does the new_line() itself, saves caller from freeing the buffer (which no caller did)
.  - changed signature: now also prints the friend's name when sending
.  - intern: date is only printed once, the message line gets only time
- print_message(): enforce null termination
- main():
.  - setlocale() to init locale (for date/time printing)
.  - own name: ensure null termination

Messenger.c:
- notify of friend name change *before* the old name is overwritten
2013-11-11 15:25:54 +01:00
irungentoo
4943054742 Fixed small issues.
DHT_test now only prints non zero entries.
2013-11-10 17:57:24 -05:00
irungentoo
ce29937b8d Added more printing to DHT_test, fixed typo. 2013-11-10 14:55:36 -05:00
Coren[m]
4993928888
Started as a simple bugfix for wrap(), expanded to more detailed help.
nTox.c:
- flag[]: additional flag for special wrapping
- help expanded and split (to keep below 256 chars)
- new_lines_mark(): stores flag for special wrapping
- print_friendlist():
.  - extracted pattern for output
.  - added length of id string allocation
.  - replaced '\t' with '+ ', wrappers don't account for '\t'
- line_eval():
.  - removed a few do_refresh() directly after a new_lines() (calls do_refresh() at its end)
.  - 'h' (help): parsing of an additional character for f(riend) or g(roup)
- wrap():
.  - the major bugfix:
.    - no more endless looping if the input had a substring with no spaces
.      for more than line_width (e.g. ID of 78 and window smaller than 78)
- wrap_bars(): wrap() for "rich" messages, honors embedded '\n', breaks preferable at '|'
- print_help(): listed all options and added explanations
- print_invite(): fixed minuscule typo
- main(): made print_help() reachable again

nTox.h:
- majorly cut down to what is really needed
2013-11-10 19:06:17 +01:00
irungentoo
8e0ab68d30 Removed define that could become confusing. 2013-10-24 13:34:04 -04:00
irungentoo
55dececf90 Code cleanups.
Fixed some tests.
2013-10-23 14:49:59 -04:00
irungentoo
9303c18b0c Merge branch 'Cleanup-defines' of https://github.com/FullName/ProjectTox-Core into FullName-Cleanup-defines 2013-10-20 15:12:46 -04:00
Coren[m]
a0f08839bd Main: Eliminate TOX_ENABLE_IPV6 (then always on), CLIENT_ONETOONE_IP (then always off).
Additionally (besides cleanups):

network.h/tox.h:
- WIN32: fix a strange sa_family_t definition
- WIN32: define EWOULDBLOCK to WSAEWOULDBLOCK
- WIN32: kill macro for an existing function (IN6_ADDR_EQUAL)

network.c:
- use EWOULDBLOCK instead of EAGAIN (same value, but EWOULDBLOCK is more "popular")
- new_networking(): only try to enable IPv4-in-IPv6 if it's not already enabled per default
- inet_ntop()/inet_pton(): WIN32: remove partial initializers in favor of a simple memset()
- ip_equal(): WIN32: use an existing function
- logging: networking_wait_execute(): only dump result if not timeout
- logging: loglogdata(): kill an unused variable

LAN_discovery.c:
- send_broadcasts(): re-enabled, can only support IPv4 by principle, split into fetch_broadcast_info() (to fetch the addresses once) and send_broadcasts() (actual sending)

DHT.c:
- DHT_load_state_callback(): enclosed a fprintf(stderr, ...) into #ifdef DEBUG

Lossless_UDP.c:
- change_handshake(): harden against strange sa_family_t definitions

Messenger.c:
- logging: fix ID to string conversion

util.c:
- logging: eliminate a signed-warning
2013-10-20 16:56:12 +02:00
Antonio Montes
de696c1db6 Removed unnecessary #if 2013-10-19 11:34:41 -07:00
Antonio Montes
3df81b07f3 fixed build errors on windows 2013-10-19 11:14:03 -07:00
Jin^eLD
07d334bbe3 Do not build tox_sync on win32 2013-10-16 18:03:33 +02:00
mannol
5bc2560904 tox A/V: integration of A/V code into tox
Also-by: Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
2013-10-13 16:40:15 +02:00
irungentoo
4aa507b664 Added function to get the piece size for sending files. 2013-10-08 18:55:35 -04:00
BtbN
8d40ddf417 Some configuration/build fixes, so building basicaly everything else than the library can be disabled 2013-10-07 02:01:16 +02:00
irungentoo
6ef2b5ead6 Code cleanups. 2013-10-06 17:40:23 -04:00
irungentoo
97f192969c Fixed warnings. 2013-10-05 11:24:30 -04:00
irungentoo
ac117322a9 Tox sync added.
Tox sync is a proof of concept bittorrent sync inspired application that
uses tox to sync the contents of two folders.

Currently only works on POSIX compilant operating systems.
2013-10-05 11:14:06 -04:00
irungentoo
fbd494a8b4 File sending added to public api. 2013-10-02 20:53:24 -04:00
irungentoo
6425cf3b53 File control packets can now be used by the person sending the file. 2013-10-02 20:08:14 -04:00
irungentoo
6182af8449 nTox updated with changes in core, some file sending things fixes. 2013-10-01 18:59:33 -04:00
irungentoo
3c7de51ba5 Basic ntox file sending. 2013-09-30 13:13:49 -04:00
irungentoo
0e318af9e2 Merge branch 'ClientData46' of https://github.com/FullName/ProjectTox-Core into FullName-ClientData46 2013-09-27 21:10:34 -04:00
Coren[m]
6fe25e4f6f Permit -Wshadow as useful warning. 2013-09-27 11:24:33 +02:00
Coren[m]
9de295374d expanded Client_data to hold two addresses (IPv4, IPv6) instead of one
Compilerflag: CLIENT_ONETOONE_IP (to define in DHT.h, default unset i.e. NEW case: two addresses)

Every function in DHT{_test}.c working on Client_data has been rewritten to store IPv4 addresses in assoc4, IPv6 addresses in assoc6.
Loading/Storing of states defined with other compiler switch is transparently adjusting to the differences.

DHT.h, DHT.c:
- introduction and handling of the structure changes

DHT_test.c, Messenger.c:
- logging adapted to new structures

util.h:
- LOGGING isn't undefined per default anymore
2013-09-27 03:27:52 +02:00
irungentoo
83c6e9dd35 Fixed the connection bug and cleaned up some stuff. 2013-09-22 11:08:23 -04:00
irungentoo
3e4599e33a Lossless UDP is now suitable for sending files.
Added some actual flow control and made send/recieve buffers grow when
necessary.
2013-09-21 09:03:54 -04:00
Coren[m]
330c1bee5c nTox: keep bootstrap()ping every 10 seconds, until we get a connection running (the initial one might get lost, it IS done via UDP after all)
nTox.c:
- main(): keep calling tox_bootstrap_from_address() every 10 seconds, until the connection is established
2013-09-21 02:02:27 +02:00
irungentoo
d2b9b059ba Forgot an else. 2013-09-18 11:19:32 -04:00
irungentoo
1a9ee5c95f Fixed bad code in nTox. 2013-09-18 11:11:10 -04:00
irungentoo
5a83c1296c astyled everything. 2013-09-17 16:28:39 -04:00
irungentoo
dd12d464de Functions to get name of peer in group chat added.
Group message callback modified.
2013-09-16 20:59:53 -04:00
Coren[m]
ab2805a23b Fix warnings of -Wall -Wextra 2013-09-16 10:37:22 +02:00
Coren[m]
6d3ac937af Merge remote-tracking branch 'upstream/master' into nTox 2013-09-15 19:07:54 +02:00
irungentoo
dde98eb345 DHT peer finding for new friends should now be slightly faster.
Also fixed the "[i] could not send message" bug in nTox.
2013-09-14 20:38:48 -04:00
irungentoo
20a8fb8a23 Fixed warnings. 2013-09-14 19:15:26 -04:00
irungentoo
12d1c5199b astyled everything. 2013-09-14 12:42:17 -04:00
Coren[m]
0db05eca49 Save datafile when adding a friend/accepting a friend request.
(Note to self: make clean is your friend. Those extra seconds are well spent.)
2013-09-14 18:39:59 +02:00
Coren[m]
f2ad7fd4ea Rename load_old_key_or_save_new_one() to load_data_or_init(). 2013-09-13 09:20:03 +02:00