summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
AgeCommit message (Collapse)Author
2013-10-24Move unix_time(), id_cpy()/id_eq(), is_timeout() to util.*Coren[m]
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-20Main: Eliminate TOX_ENABLE_IPV6 (then always on), CLIENT_ONETOONE_IP (then ↵Coren[m]
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-12Improved hole punching.irungentoo
2013-09-30Speeded up/fixed NAT hole punching and peer finding.irungentoo
2013-09-28Fixed small issue.irungentoo
2013-09-28Behaviour with LAN ips is now better, also fixed possible bug.irungentoo
2013-09-28LAN ips can be sent to LAN ips.irungentoo
2013-09-28friend_iplist and route_tofriend behaviour fixes.irungentoo
2013-09-27Fixed possible problem.irungentoo
2013-09-27Astyled the code.irungentoo
2013-09-27don't lose globally valid addresses for locally valid onesCoren[m]
2013-09-27minimalistic increase in elegance ;)Coren[m]
DHT.c: - loops over assoc4/6 slightly more elegant
2013-09-27expanded Client_data to hold two addresses (IPv4, IPv6) instead of oneCoren[m]
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-25Fixed bug where hole punching was attempted even though theirungentoo
clients were connected. Increased the number of ports tried per interval of time. Also astyled the files.
2013-09-24Merge pull request #596 from FullName/ping.moveandcleanirungentoo
moved stuff that belongs into ping.[ch] there
2013-09-22Fix bug.stal
This makes it build on OS X again...
2013-09-21moved stuff that belongs into ping.[ch] thereCoren[m]
DHT.*, ping.*: - moved stuff from struct DHT into struct PING: toping, last_toping - moved functions add_toping(), do_toping() - made id_closest() publicly accessible - send_ping_request(): killed (Net_Crypto *c) parameter in favor of copying it into (PING *) on new_ping() group_chats.c: - killed local 1:1 copy in favor of DHT.c::id_closest()
2013-09-21honor the claim of sort_list(), that the result is in anti-intuitive order, ↵Coren[m]
and treat element zero as the furthest
2013-09-21Merge branch 'master' of https://github.com/irungentoo/ProjectTox-Core.git ↵Coren[m]
into ipv6.yield50%toipv4
2013-09-21reserving 50%+ for ipv4, take 2Coren[m]
DHT.c: - we have to actually count the number of addresses in the field, because sort_list() will move the stuff around - improved replace_good() substantially by throwing away the "furthest" client_id, not the one just a bit worse than the new one (but better than all the later ones in the field!)
2013-09-19reserve lower half of client lists for ipv4 for nowCoren[m]
also rename client_in_list() to client_or_ip_port_in_list(), it also checks for an identical ip/port and replaces the client_id, recycling the entry DHT.c: - rename client_in_list() to client_or_ip_port_in_list() - replace_bad(), replace_good(): if IPv6, only insert into the upper half of the given list - addto_lists(): convert ipv4-in-ipv6 mapped to ipv4
2013-09-17astyled everything.irungentoo
2013-09-17Tests of state loading/saving lead to two fixes for DHT.c and util.cCoren[m]
util.c: - fix in empty section at the end of the state, showed as bug when having an empty name DHT.c: - fix in saving less data than originally announced, showed as bug when not having reached any clients ever (no clients or only with timestamp of zero)
2013-09-16Toxcore should never print anything when built normally.irungentoo
2013-09-16Merge pull request #576 from FullName/MessengerLoadSaveirungentoo
State loading/saving: Instead of a blob, segment into sections marked with tags.
2013-09-16Fix warnings of -Wall -WextraCoren[m]
2013-09-16Merge remote-tracking branch 'upstream/master' into MessengerLoadSaveCoren[m]
Conflicts: toxcore/Messenger.c toxcore/util.c toxcore/util.h
2013-09-15Fixed portability problems.irungentoo
2013-09-15Fixed portablity problems.irungentoo
struct in6_addr member names can differ per platform.
2013-09-14DHT peer finding for new friends should now be slightly faster.irungentoo
Also fixed the "[i] could not send message" bug in nTox.
2013-09-14Fixed small problems, updated TODO.irungentoo
2013-09-14Fixed some warnings.irungentoo
2013-09-14Some fixes.irungentoo
2013-09-14DHT.c:Coren[m]
- get_close_nodes(): refactored the inner loop out into get_close_nodes_inner()
2013-09-14DHT.c:Coren[m]
- get_close_nodes()/sendnodes()/sendnodes_ipv6(): when selecting for SEND_NODES/SEND_NODES_IPV6, treat embedded IPv4-in-IPv6 addresses as being IPv4 Messenger.c: - added a named constant for sixty seconds friend/client dump - fix logging to convert client_id to printable before printing
2013-09-14Change sublength to 32 bits. Someone might have more than (sizeof(Friends) / ↵Coren[m]
65536) friends...
2013-09-13Merge remote-tracking branch 'upstream/master' into IntegrationCoren[m]
2013-09-13Merge remote-tracking branch 'upstream/master' into MessengerLoadSaveCoren[m]
2013-09-13State loading/saving: Instead of a blob, segment into sections marked with tags.Coren[m]
Primary rationale: The part that DHT saves changes if IP is expanded to IPv6. To let people keep their friends/name, change the datafile format now, while everybody is still on the same page. Loading/Saving rewritten to allow a part of the file to be incomprehensible to the loading routine. Added a magic cookie at the beginning to mark the file as tox's. Changes in some part of the datafile can be skipped and the remaining parts still be consumed. Allows a wide margin of forward compatibility (like the IP to IPv6 transition, but also e.g. a change in the key format). As long as the file is not completely garbled, the routine will read as much as possible. Only the KEY section is considered mandatory: a malformed key section leads to a negative result. util.*: - holds the driving function which jumps from section to section and calls back with section length and tag (type) Messenger.c,DHT.*: - new loading functions call the util-function with a callback, which subsequently consumes the sections - old routines are kept to fall back onto if the magic cookie at the beginning isn't present - saving is still done in one local routine
2013-09-13Nonce generation changes.irungentoo
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-13TOX_ENABLE_IPV6 is now #define'd per default. Added some logging and error ↵Coren[m]
messages.
2013-09-12network.*:Coren[m]
- addr_resolv(_or_parse_ip)(): added an optional parameter to return both an IPv6 and an IPv4 address if requested address family was AF_UNSPEC - logging of unhandled packets DHT.c: - bootstrap_from_address(): use the additional return from addr_resolv_or_parse_ip() to bootstrap in both network types at once Lossless_UDP_testclient.c: - main(): adapt to signature change of addr_resolve() Messenger.c. LAN_discovery.h: - lost a htons(), readded - moved LAN_DISCOVERY_INTERVAL #define into LAN_discovery.h LAN_discovery.c: - added IPv4-in-IPv6 local address test
2013-09-12tox.h:Coren[m]
- #define'd tox's network port (as range) - finally killed tox_new_ex() in favor of changing tox_new()'s signature - renamed tox_bootstrap() to tox_bootstrap_from_ip() network.h: - #define'd tox's network port (as range) - renamed SEND_NODES_EX to SEND_NODES_IPV6 - bind() loop uses #define'd port range DHT.c: - renamed SEND_NODES_EX to SEND_NODES_IPV6 - sending ipv6 node addresses even if can't use them ourselves nTox.c: - adapted to changed tox_new()
2013-09-11tox.h, DHT.h:Coren[m]
- tox_bootstrap_ex(), DHT_bootstrap_ex() renamed to tox_bootstrap_from_address(), DHT_bootstrap_from_address() - (handle_)sendnodes_ex() renamed to (handle_)sendnodes_ipv6() - only sending sendnodes_ipv6() if we're actually IPv6 enabled - changed comments to conform better nTox.c, Messenger_text.c, DHT_test.c, DHT_bootstrap.c: - fallout from *_ex() to *_from_address() DHT_bootstrap.c: - corrected a potentially wrong info message util.c: - fixed logfile name: now (funcptr) => now() (number) network.c: - addead comment about the necessity of bind() to succeed auto_test/messenger_test.c: - defaulting ipv6enabled to TOX_ENABLE_IPV6_DEFAULT LAN_discovery.c: - slight cleanup and comments for clarity
2013-09-11cmdline parsing:Coren[m]
- add missing includes (autobuild warnings)
2013-09-10tox.*, DHT.*:Coren[m]
- return to the caller if the string could be resolved into an IP other/DHT_bootstrap.c, testing/*_test.c, testing/nTox.c: - parse cmdline for --ipv4/--ipv6 switch to allow user a choice util.h: - proper old-style C-comment
2013-09-10DHT.c:Coren[m]
- client_in_list: split loop in two to avoid inserting a client_id duplicate - final pieces for IPv6 expansion: (handle_)sendnodes_ex(), called from hande_getnodes() resp. handler callback
2013-09-10big push, putting all the infrastructure in place behind TOX_ENABLE_IPV6Coren[m]
2013-09-09tox.*, DHT.*;Coren[m]
- second set of *_bootstrap_ex() functions to allow addresses instead of IPs network.h: - new message ID for sending/receiving IPv6 nodes DHT.*: - get_close_nodes(): - additional parameter to select which kind of nodes: IPv4 or IPv6 - sendnodes()/handle_sendnodes(): - the IPv4 message must remain intact even when the Node_format structure (which embeds IP_Port) is expanded - added Node4_format to keep the structure "alive" - copying in/out of wider to smaller format required in sendnodes()/handle_sendnodes() - switch of Node_format from Node4_format to Node46_format by define
2013-09-09network.*:Coren[m]
- IPAny_Port: analogous to IP_Port - ipport_equal: moved from DHT.c and adapted DHTc.: - ipport_equal renamed to ip4port_equal