summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
AgeCommit message (Collapse)Author
2017-06-05Change way to iterate through assocDiadlo
2017-06-05Make work with assoc more genericDiadlo
2017-06-05Improve formatting and syntaxDiadlo
2017-06-05Cleanup punch_holesDiadlo
2017-06-05Add using id_equalDiadlo
2017-06-05Update crypto_size and check indexDiadlo
2017-06-05Extract 'update_client_data' to reduce code duplicationDiadlo
2017-06-05Extract 'update_client_with_reset' function to reduce code duplicationDiadlo
2017-06-05Extract 'update_client' functionDiadlo
To make 'client_or_ip_port_in_list' code easy to read
2017-06-05Extract variablesDiadlo
2017-06-05Change return type to be the same as return value typeDiadlo
Return value of 'addto_list' function is 'used' counter, which is uint32_t. It will be better to use the same return type.
2017-06-05Add using macros to improve codeDiadlo
2017-06-05Add 'index_of' functionsDiadlo
- Replace 'for' with long body - Replace friend_number function on index_of_friend_pk - Replace client_in_nodelist on index_of_node_pk
2017-06-05Extract SharedKey struct and use it as var instead of indexingDiadlo
2017-06-05Add using C99 'for' syntaxDiadlo
2017-06-04Add a monolith_test that includes all toxcore sources.iphydf
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-04-29check if already in close list in ping_node_from_getnodes_ok()zugz
fix index bounds check in add_to_close() and is_pk_in_close_list() add TODO to write test for bug which fixed by this commit
2017-03-26Add crypto_memzero for temp bufferDiadlo
2017-02-26Add part of platform-independent network API implementationDiadlo
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-21Use VLA macroMaxim Biro
2017-02-11remove statics used in onion comparison functionszugz
2017-01-28Add VLA compatibility macro for C89-ish compilers.iphydf
2017-01-26Replace redundant packet type check in handler with assert.Yuri
2017-01-21reduce thread-unsafe use of static variableszugz
- rework ip_ntoa() to avoid use of static variables - rework sort_client_list() to avoid use of static variables - move static 'lastdump' into Messenger struct - rework ID2String() to avoid use of static variables; rename to id_to_string() - fetch_broadcast_info(): attempt to mitigate risks from concurrent execution - current_time_monotonic(): attempt to mitigate risks from concurrent execution - comment on non-thread-safety of unix_time_update
2017-01-19Update license headers and remove redundant file name comment.iphydf
"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-11Remove `TOX_DEBUG` and have asserts always enabled.iphydf
These are cheap asserts. I've also replaced the fprintf's with `LOGGER_ERROR` calls.
2017-01-11Fix logging condition for IPv6 client timestamp updates.iphydf
2017-01-07Replace make_quick_sort with qsortendoffile78
2017-01-06Eliminate dead return statement.iphydf
Previously, the `ipv6` variable was initialised to `-1`, but that value was never read. Either it was set to 0 or 1, or the function would return before it was read. Thus, I've changed it to uninitialised `bool is_ipv4` (inverted semantics to avoid negative conditions `if (!is_ipv6)`). The `pack_ip_port` function is a bit unfortunate, but I'm not rewriting it until we have a binary writer (I'd be rewriting it twice).
2016-12-22Improve documentation of crypto_core.iphydf
2016-12-22Wrap all sodium/nacl functions in crypto_core.c.iphydf
2016-11-24add NAT hole punching level to Tox APIGregory Mullen (grayhatter)
2016-11-11Add DHT_create_packetendoffile78
2016-11-09Remove new_nonce function in favour of random_nonce.iphydf
`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-06Remove assocendoffile78
2016-11-03Move packing and unpacking DHT request packets to DHT module.iphydf
These definitely don't belong in a module called "crypto core". The DHT module seems like the best place to put them, since they are sent to DHT nodes.
2016-09-30Remove return after no-return situation (and other cleanups).iphydf
Cleanups: - Fix header guards to not use reserved names. - Avoid name shadowing. - Removed an unused variable found by avoiding name shadowing.
2016-09-24Make toxcore code C++ compatible.iphydf
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-16Ensure that all TODOs have an owner.iphydf
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-13Use <stdbool.h> and replace _Bool with bool.iphydf
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-13Add some astyle options to make it do more.iphydf
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-13Group #include directives in 3-4 groups.iphydf
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-12Remove `else` directly after `return`.iphydf
See #78.
2016-09-09Separate IP_Port packing from pack_nodes() and unpack_nodes()Jfreegman
Allows us to pack IP_Port structs that are part of arbitrarily structured data.
2016-09-06Improve static and const correctness.iphydf
- 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-06Make friend requests statelessGregory Mullen (grayhatter)
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-02Do not use `else` after `return`.iphydf
http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
2016-09-01Sort #includes in all source files.iphydf
2016-08-31Add braces to all if statements.iphydf
2016-08-27Move logging to a callback.iphydf
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.