Commit Graph

75 Commits

Author SHA1 Message Date
irungentoo 4dc0af61c6 All time in core is now monotonic. 2014-05-03 11:58:45 -04:00
irungentoo deb8bfc350 Random number functions belong in crypto_core. 2014-05-01 19:42:44 -04:00
irungentoo 19a4b1e443 Improved the crypto_cmp function.
It now uses the NaCl functions when the length is appropriate.

Moved crypto defines to crypto_core.h
2014-05-01 08:06:24 -04:00
irungentoo 3863e01e22 Some more work done on the middle network protocol.
Handshake most likely has no more possible flaws to it, next thing
to do is to do the same with the data packets.

Wrote a couple more functions.
2014-04-29 20:45:32 -04:00
irungentoo 94545c3b50 Added some packet defines. 2014-04-28 20:27:23 -04:00
irungentoo 1bfe15ee88 Decided pretty much how the handshake would work.
Started writing the code.

Astyled some files.
2014-04-22 20:28:40 -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 f9bf7b074a Major protocol changes, this commit breaks all network compatibility.
Removed a bunch of useless space from various structs.

pack_nodes() and unpack_nodes() are now used to transmit lists of
nodes for the DHT and onion parts. They provide a way to transmit
both ipv6 and ipv4 nodes in the same packet in a portable way that
takes as little space as possible without compression.

Using pack_nodes, merged the send nodes and send nodes ipv6 packets
into one packet greatly reducing the risk of amplification attacks.
2014-04-15 18:09:07 -04:00
Steven Noonan ecf0ff3e7f sockets: support Mac OS X way of disabling SIGPIPE on a socket
Mac OS X doesn't have MSG_NOSIGNAL, so we need to use SO_NOSIGPIPE.

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
2014-04-13 04:01:38 -07:00
irungentoo bd0d24fc9c Added TCP_client.
Some work done on the TCP part.
2014-04-06 20:51:03 -04:00
irungentoo c8ab29632b Some code cleanups. 2014-04-02 18:02:53 -04:00
irungentoo 98cba889a7 TCP server now has onion functionality.
All the IP/Port related structs now have __attribute__ ((__packed__))
2014-03-29 22:19: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 e95494482f A bit of work done on the TCP relay server. 2014-03-15 22:11:36 -04:00
Maxim Biro e118319467 Some tox_wait_* improvements 2014-03-07 22:40:00 -05:00
Maxim Biro 5a142bb697 Renamed dht server to dht node 2014-02-22 17:07:15 -05:00
irungentoo 71b48516e8 Added custom userpackets.
A way to send and handle lossy UDP packets coming from friends.

Will be used for A/V.
2014-02-14 21:16:31 -05:00
irungentoo ad5d58b4a2 Added DHT bootstrap server info packets.
define DHT_SERVER_EXTRA_PACKETS to enable.
2014-02-01 18:45:37 -05:00
irungentoo 5da80263a5 Convert IPv4 in IPv6 to IPv6 address in recieve packet. 2014-01-30 13:59:10 -05:00
Sean 460e52c426 missing #endif 2014-01-25 19:49:37 -08:00
Sean 803c6f41d7 Moved to networking.h
Plan 9 requires u.h in every file
2014-01-25 18:48:49 -08:00
Ben Iofel 174cec7f15 proper windows preprocessor detection 2014-01-19 19:30:14 -05:00
irungentoo ad2037e165 Added the shell of onion.{c, h} 2013-12-24 16:22:56 -05:00
irungentoo c51b8a9eba Added function to save an encrypted version of the messenger.
Also added some tests.
2013-12-21 22:35:27 -05:00
irungentoo 24974ef816 Code cleanups.
No functionality changed.
2013-12-15 18:57:10 -05:00
irungentoo a4968bdbc5 Compatibility fixes.
AF_INET/AF_INET6 can vary across devices, we introduce TOX_AF_INET and
TOX_AF_INET6 to fix this.
2013-12-08 18:15:30 -05:00
irungentoo 1c45e59938 Added/updated some basic docs and cleaned up some things. 2013-12-07 19:06:41 -05:00
irungentoo 7cd43ecc76 Merge branch 'master' into harden 2013-12-06 22:51:17 -05:00
irungentoo cdfe09d221 Merge pull request #650 from FullName/ID-IP-basic
Significantly trimmed down version of an ID<=>IP cache.
2013-11-18 18:02:29 -08:00
irungentoo a82ad576a2 Fixed build error on windows. 2013-11-16 21:21:32 -05:00
Coren[m] 0d8329b3a9 Significantly trimmed down version of an ID<=>IP cache.
Besides acknowledging timeouts, the module isn't trying to do anything fancy with the data besides storing and retrieving.
2013-11-14 19:05:53 +01:00
irungentoo 415835ce3d Merge branch 'master' into harden
Also removed some old, useless loading code.
2013-10-28 16:01:29 -04:00
irungentoo f7040726a1 Increased port range. 2013-10-26 23:17:11 -04:00
irungentoo bb0ec76de3 Fixed build error with libsodium. 2013-10-24 19:13:19 -04:00
Coren[m] 0a4c3d7e2e Move unix_time(), id_cpy()/id_eq(), is_timeout() to util.*
unix_time():
- returns local value for current epoch
- value is updated explicitly with unix_time_update() called at new_DHT()/doMessenger()/do_DHT()

is_timeout():
- uses the local value for current epoch

id_cpy()/id_eq() => id_copy()/id_equal():
- centralized duplicate definitions
- replaced (most) memcpy()/memcmp() of (*, *, CLIENT_ID_SIZE) with id_copy()/id_equal()
2013-10-24 22:32:28 +02:00
irungentoo 9bef5f5bff Adding encrypted data to send/getnode packets part 1. 2013-10-24 14:10:55 -04:00
irungentoo 8e0ab68d30 Removed define that could become confusing. 2013-10-24 13:34:04 -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
irungentoo dc1c019a2d Small fix. 2013-10-13 10:43:53 -04: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
Coren[m] 355c55f745 sendqueue_length no longer determines if we check for socket-can-write, but sendpacket() sets a timestamp if it happened
network.*:
- sendpacket(): checks result and on EAGAIN, stores time of this event
- networking_wait_prepare(): uses the time if set to check up to 500ms later for the socket to be writeable again
- networking_wait_cleanup(): clears the time if the socket was writeable
- fixed some accidental tabs

Messenger.*, tox.*:
- pass-through functions to reach networking_wait_cleanup()
- fixed some accidental tabs
2013-10-06 16:37:02 +02:00
Coren[m] 1331a32223 Broken *_wait() into *_wait_prepare() and *_wait_execute()
To allow the actual waiting to run without any locking, split it into preparing the data it uses and the execution of the wait.
The caller must provide with the buffer to store whatever data it requires to wait.
Completely eliminates any reliance on the existence of anything but that data in the actual wait routine.

Also fixed a few argument type warnings inside LOGGING.
2013-10-05 12:53:54 +02:00
Coren[m] 1f92ee274d Only add write-ready to select() if we have packets queued
Lossless_UDP.*:
- sendqueue_total() sums sendqueue() across all connections

network.*, Messenger.c:
- sendqueue_total() is collected and then used in deciding if we select() on write-readiness
2013-10-03 12:10:29 +02:00
Coren[m] 2af0d43ce8 Add tox_wait() for socket, allow tox.h include in tox.c
tox.*, Messenger.*, network.*;
- new function tox_wait() => waitMessenger() => networking_wait():
  - waits for a given amount of time for any sort of socket activity
  - mustn't change anything inside, mustn't poll or do other stuff
    - the point is to be able to call this asynchronously from a second thread
    - the outside shall follow up with an immediate tox_do() when there's socket activity

tox.*:
- allow inclusion of tox.h into tox.c, ensuring that the outside interface and the internal always match

util.c:
- squished a few warnings about questionable format strings
2013-10-02 16:38:54 +02:00
BtbN a7eb9b2c34 Fix inet_pton/ntop on win32 2013-09-22 20:26:39 +02:00
BtbN b9306d6d06 Fix compilation on windows for ipv6 code 2013-09-21 01:10:23 +02:00
irungentoo decdb7aa8c more portability fixes. 2013-09-15 10:17:09 -04:00
irungentoo 8c41244627 Fixed portablity problems.
struct in6_addr member names can differ per platform.
2013-09-15 09:31:27 -04:00
Coren[m] fa576e464e Merge remote-tracking branch 'upstream/master' into Integration 2013-09-13 19:44:14 +02:00
irungentoo 339dcd6070 Nonce generation changes.
Nonces don't need to be random, only different.

also random_int now gives same quality random numbers for both NaCl and
libsodium.
2013-09-13 10:42:14 -04:00