Commit Graph

723 Commits

Author SHA1 Message Date
Arvid Norberg b74bdfa7db make dht logging deterministic (#1460)
make dht logging deterministic (ues an id instead of this-pointer to identify a traversal algorithm)

try with more DHT nodes
2016-12-27 07:12:57 -08:00
Pavel Pimenov c34a2541cc Log refactoring (#1446)
factor out common logging code in some dht traversal algorithms
2016-12-24 06:46:21 -08:00
Pavel Pimenov 6afb1f3e83 aux::to_hex(sha1) -> sha1.to_hex() (#1418)
generate hex strings into std::string instead of stack-allocated char arrays
2016-12-22 10:44:36 -05:00
Steven Siloti 916fc92c49 create separate function for reading a node from a list 2016-12-17 02:22:13 -05:00
Alden Torres 22b596945e enable /W4 warnings for msvc 2016-12-13 19:36:14 -05:00
Alden Torres f382936d56 headers, end of file, code cleanup 2016-12-12 23:36:45 -05:00
Steven Siloti ca07ee83a3 mark all converstion to bool operators as explicit 2016-12-12 01:34:36 -05:00
Alden Torres dd7179fb10 added a few consts to arguments and local variables 2016-12-10 18:19:14 -05:00
Alden Torres d5c4cd7280 fixed sign-compare warnings and some refactor (#1354)
fixed sign-compare warnings and some refactor. make sequence_number backed by std::int64_t
2016-11-27 08:46:53 -05:00
Alden Torres c30027e4a1 more integral type conversion warning fixes, now only needs shorten-64-to-32 (#1349)
more integral type conversion warning fixes, now only needs shorten-64-to-32
2016-11-25 11:17:25 -05:00
Alden Torres 86251adb1b more fixes of integral type conversion warnings 2016-11-21 20:22:18 -05:00
Alden Torres 84e0362180 more fixes in signed compare warnings (#1345)
more fixes in signed compare warnings
2016-11-21 01:49:56 -05:00
arvidn 0e33e62627 merged RC_1_1 into master 2016-11-20 11:18:16 -05:00
arvidn 4df1ecbe25 re-enable some warnings and fix code 2016-11-20 01:05:16 -05:00
Alden Torres 4c7e24ea35 more use of std::make_shared, fixing warnings of over-aligned 2016-11-18 00:28:29 -05:00
Andrei Kurushin 0a31e26344 fix logging=off build 2016-11-16 23:14:28 -05:00
Alden Torres 6751a1eeb1 removed spaces in template types and more c++11 auto/loop refactor 2016-10-26 00:08:00 -04:00
Arvid Norberg 6148984426 remove whitespace at end of line (#1245) 2016-10-22 11:47:24 -04:00
Arvid Norberg 25195a7260 back port DHT fixes from master (#1209)
back port DHT fixes from master
2016-10-14 23:47:59 -04:00
Angel Leon 9cdf0ee50c Boolean simplifications (oct 13th 2016) (#1211)
boolean simplifications
2016-10-14 16:13:18 -04:00
Arvid Norberg 540b5b28d7 use signed counters in traversa_algorithm, and add some more asserts (#1208)
use signed counters in traversal_algorithm, and add some more asserts
2016-10-14 08:03:09 -04:00
Arvid Norberg e0c8ad738d include target in DHT lookups, when queried from the session (#1207) 2016-10-12 23:39:00 -04:00
Arvid Norberg 6bb2d7c017 Sanitize 1.1 (#1197)
enable address sanitizer
2016-10-09 17:00:20 -04:00
Alden Torres 9343f2fbfb minor header cleanup and refactor (#1179) 2016-10-04 07:43:34 -07:00
Alden Torres 1974dca150 minor refactor of dht_default_storage (#1166)
refactor of dht_default_storage structures
2016-09-30 20:42:57 -04:00
Alden Torres 331a8d53c0 refactor to use move with dht_state (#1163)
refactor to use move with dht_state
2016-09-29 08:25:51 -04:00
Alden Torres af92e91a90 missing inc dht counter and minor cleanup (#1164) 2016-09-28 23:25:08 -04:00
Steven Siloti 85dd682551 fix adding a node with unknown id (#1161)
Commit a414e4c3 broke adding nodes with unknown id to the routing table by
causing them to be evicted when they responded with their real id. This should
have been caught by test_bootstrap, but a typo caused that test to silently
exit early.
2016-09-28 13:28:21 -04:00
Alden Torres 8caebbd026 alerts refactor to use span, don't break ABI when logging, fix compilation (#1159)
alerts to use span, don't break ABI when logging, fix compilation
2016-09-27 23:21:18 -04:00
Alden Torres 31ce1e5a2c dht headers and minor cleanup (#1157) 2016-09-26 18:04:42 -04:00
Alden Torres 4693fcf3f1 dht source code and headers cleanup (#1150) 2016-09-24 22:20:20 -04:00
Arvid Norberg 48a647a169 String view entry (#1147)
make entry support string_view in its interface, and make it efficient when in in C++14
2016-09-24 06:10:54 -07:00
Steven Siloti 2e0140b6f6 fix peer picking algorithm (#1141)
fix peer picking algorithm. The old code was always picking the first to_pick peers from the set.
2016-09-24 06:08:52 -07:00
Arvid Norberg 24b271b7c1 Merge pull request #1133 from ssiloti/peer-picker
fix DHT peer picking algorithm. The old code was always picking the first to_pick peers from the set.

* use a sorted vector to store peer announcments

Given the frequency of linear scans being done, std::set is clearly
sub-optimal for storing announced peers. A std::vector is the obvious
choice, which I also decided to make sorted. A sorted vector trades
better performance in announce_peer for slower purging, the latter
being mitigated by batching.

* shrink peers vectors with too much excess capacity
2016-09-23 13:48:00 -07:00
Steven Siloti 35cfc6b5d3 shrink peers vectors with too much excess capacity 2016-09-23 07:30:36 -07:00
Steven Siloti 89942bf3d4 use a sorted vector to store peer announcments
Given the frequency of linear scans being done, std::set is clearly
sub-optimal for storing announced peers. A std::vector is the obvious
choice, which I also decided to make sorted. A sorted vector trades
better performance in announce_peer for slower purging, the latter
being mitigated by batching.
2016-09-22 21:54:10 -07:00
Alden Torres c7ec987a1b refactor in msg verify_message and minor cleanup (#1131) 2016-09-21 23:04:05 -07:00
Steven Siloti 23e11af899 fix peer picking algorithm
The old code was always picking the first to_pick peers from the set.
2016-09-21 20:21:34 -07:00
Steven Siloti c75b243490 remove redundant protocol parameter (#1128) 2016-09-21 20:00:39 -07:00
Steven Siloti dad0000015 send write token if peer is alraedy stored 2016-09-20 19:35:24 -07:00
Steven Siloti e2fefb074a always drop the announcing peer when at capacity 2016-09-19 21:51:10 -07:00
Steven Siloti 6e24bbe77a only send a write token if we have storage space available 2016-09-19 21:51:10 -07:00
Alden Torres db14df5d0d dht code related refactor and cleanup (#1107)
dht code related refactor and cleanup
2016-09-18 20:08:15 -04:00
Arvid Norberg 80ba45e1fb clean up read_endpoint_list (#1102) 2016-09-18 10:12:54 -04:00
Alden Torres 6c31ea3d44 created dht state and session params refactor (#1100)
created dht state and session params refactor
2016-09-17 09:42:04 -04:00
Alden Torres d9489878a0 rpc_manager log optimization and minor refactor (#1095)
more on log optimization
2016-09-16 08:21:07 -04:00
Alden Torres 0507764d04 consts and refactor, hash_address returns the hash (#1093)
consts and refactor
2016-09-15 21:13:43 -04:00
Steven Siloti 3d3367387a check the address family of peers in get_peers (#1090) 2016-09-14 11:29:27 -04:00
Alden Torres c25bae163d avoid warnings with clang and minor dht_tracker code changes (#1092) 2016-09-14 11:28:50 -04:00
Alden Torres 65cdc15543 more on log, consts, refs and cleanup in dht related code (#1082)
more on log, consts, refs and cleanup in dht related code. moving print_state out of main source code
2016-09-13 08:18:47 -04:00
Alden Torres 3fa74c6fd5 more consts refs and formatting (#1080) 2016-09-12 09:20:15 -04:00
arvidn fbf926da1f Merge branch 'master' of https://github.com/arvidn/libtorrent 2016-09-11 21:02:35 -04:00
arvidn 33414de68d merged RC_1_1 into master 2016-09-11 21:01:03 -04:00
Alden Torres 1a0c6f5e61 more dht log optimizations (#1079) 2016-09-11 20:49:15 -04:00
Alden Torres 4d4eb66c8b some refactor, more const refs and span use (#1078)
some refactor, more const refs and span use
2016-09-11 01:58:48 -04:00
Alden Torres 5480e2eedc some consts refs and refactor (#1075)
some consts refs and refactor
2016-09-09 15:02:20 -04:00
Alden Torres 99da5c8017 dht log optimization, consts and refactor (#1073)
dht log optimization and refactor
2016-09-08 19:13:46 -04:00
Alden Torres 5e69dc700c minor cleanup and refactor (#1069) 2016-09-06 18:34:03 -04:00
Alden Torres b313de3925 some refactor and cleanup (#1065) 2016-09-05 22:25:20 -04:00
Alden Torres 29a4075555 refactor to use std::shared_ptr with dht observer (#1057)
refactor to use std::shared_ptr with dht observer
2016-09-02 21:05:11 -04:00
Alden Torres fd4c09d7b2 refactor to use std::shared_ptr with traversal_algorithm (#1056)
refactor to use std::shared_ptr with traversal_algorithm. use a more stable linaro gcc link
2016-09-02 16:42:55 -04:00
Alden Torres 585a760588 headers cleanup (#1054)
headers cleanup
2016-09-01 15:04:58 -04:00
Steven Siloti 29e6cbbdae fix exit condition when parsing nodes (#1046)
fix exit condition when parsing nodes
2016-09-01 00:49:21 -04:00
Arvid Norberg 44a761e5c8 Merge pull request #1047 from ssiloti/rpcm-cleanup
rpc_manager: remove unused timer
2016-08-31 02:04:00 -04:00
Steven Siloti 134d62ab08 rpc_manager: remove unused timer 2016-08-30 19:40:11 -07:00
Alden Torres 658fa46f0a no warnings in random with openssl-1.1 and minor refactor 2016-08-30 21:23:08 -04:00
arvidn b554909486 hint DHT bootstrap nodes of actual bootstrap request 2016-08-30 21:15:35 -04:00
Alden Torres e2487c4d24 more use of std::shared_ptr refactor 2016-08-30 10:10:53 -04:00
Alden Torres 2ac45d17ef ed25519 api refactor (#1041) 2016-08-30 02:37:51 -04:00
Alden Torres 32f5f8f257 better integration and API for ed25519 (#1037)
better integration and API for ed25519. using shared_ptr in ed25519_add_scalar
2016-08-29 20:28:42 -04:00
Alden Torres c05e29c48e trivial cleanup and minor changes (#1033) 2016-08-26 00:14:11 -04:00
Steven Siloti 3a665a1040 fix inconsistant prefix calulcation (#1030)
The special case for calculating the prefix in the last bucket was being
applied to the condidate node but not the existing nodes in the bucket.
2016-08-25 19:26:48 -04:00
Alden Torres 73d6ba6ae3 using span in torrent_handle and no optional in torrent_info (#1023) 2016-08-22 11:02:51 -04:00
Alden Torres f51e782905 using string_view in node::incoming_request and plugin::on_dht_request (#1001)
use string_view in node::incoming_request. changed plugin::on_dht_request to use string_view
2016-08-15 16:17:13 -04:00
arvidn 8c8c3d5587 replace boost::function with std::function 2016-08-13 07:07:26 -04:00
Arvid Norberg e36e5efaba use boost::string_ref (#996)
use boost::string_ref/boost::string_view in various parts of the code, in file_storage, some file functions and in bdecode.
2016-08-13 07:04:53 -04:00
Arvid Norberg 71f5510d62 make the random function produce proper random distributions, based o… (#981)
make the random function produce proper random distributions, based on uniform_int_distribution of C++11. also clean up piece_picker's priority_range to return two results instead of taking pointers to out-parameters. fix recent pe-crypto regression exposed by this change
2016-08-06 13:18:48 -04:00
Alden Torres 0b3c64ee87 added TORRENT_EXPORT to avoid link weak symbol warning (#975) 2016-08-02 00:15:26 -04:00
arvidn 0126f6f2c6 fix timestamp arithmetic overflow 2016-07-30 00:38:17 -04:00
arvidn e5ecd73751 fix rebase 2016-07-29 18:47:05 -04:00
arvidn 83dba91168 use span for to_hex and from_hex functions 2016-07-29 18:42:18 -04:00
Steven Siloti 0343bb382e always check m_log before using it 2016-07-29 13:32:28 -07:00
Steven Siloti 44ce5c71e7 cleanup ip logging 2016-07-28 20:08:24 -07:00
Steven Siloti 6ebc61cef9 reject nodes with our id after checking for an existing entry
This allows us to evict nodes which start reporting our id as theirs.
2016-07-27 21:10:34 -07:00
Steven Siloti 9d75198f7f re-ping nodes in a bucket when one changes id 2016-07-27 21:10:34 -07:00
Steven Siloti a414e4c3fa remove nodes which change their id
This is based on a suggestion from the8472 to prevent malicious nodes from
polluting the routing table.

https://github.com/the8472/mldht/blob/sanitizing-docs/docs/sanitizing-algorithms.rst
2016-07-27 21:10:33 -07:00
arvidn 680a09cfa5 merged RC_1_1 into master 2016-07-26 02:14:58 -04:00
Steven Siloti 3321ca10f1 update our id in the rpc manager when it changes (#942)
update our id in the rpc manager when it changes
2016-07-24 21:30:36 -04:00
Arvid Norberg 9c2325ff6b modernize and improve type-safety of the DHT put implementation and test (#929)
modernize and improve type-safety of the DHT put implementation and tests. use unique_ptr instead of malloc for dht put items.
2016-07-23 15:57:04 -07:00
Alden Torres f57612b82d rename of aux::array_view to span (#933) 2016-07-22 09:31:42 -07:00
Arvid Norberg 7bf49c0a1c modernize hasher to use array_view (#931)
modernize hasher to use array_view as well as adding array_view support to entry
2016-07-22 07:29:39 -07:00
arvidn b8bfc13d59 merge fix 2016-07-20 11:48:44 -07:00
arvidn e405f0e02f merged RC_1_1 into master 2016-07-20 11:34:29 -07:00
Sivachandran 8f3bd1052e fix mutable dht_get_item failure when salt is non-empty (#909) 2016-07-18 07:12:10 -07:00
Arvid Norberg 8c03718117 apply modernization transforms to headers too. nullptr, explicit constructors, = default (#903) 2016-07-10 14:27:42 -04:00
Arvid Norberg a740a49fd6 modernize misc (#898)
modernize misc
2016-07-10 07:34:45 -04:00
Arvid Norberg e782783814 modernize use override (#895) 2016-07-09 20:10:38 -04:00
Arvid Norberg 770935cd46 modernize-use-nullptr (#894) 2016-07-09 16:26:26 -04:00
Arvid Norberg 1facf0eef6 clean-up more defines (#872)
clean-up more defines. remove TORRENT_DEBUG and TORRENT_DISABLE_INVARIANT_CHECKS (instead use TORRENT_USE_ASSERTS and TORRENT_USE_INVARIANT_CHECKS)
2016-07-01 19:46:59 -04:00
Arvid Norberg 6aabe3762b general modernization (#836)
general modernization. use nullptr instead of NULL, use std::tuple instead of boost::tuple, transition some unordered set/map from boost to std. some clean-up of includes
2016-06-20 11:32:06 -04:00
Arvid Norberg ed077c8358 use cstdint intead of boost/cstdint.hpp (#833)
use cstdint intead of boost/cstdint.hpp
2016-06-18 14:01:38 -04:00
Arvid Norberg ead11737b4 fix uses of defines for whether or not asserts are active (#832) 2016-06-18 08:31:07 -04:00
arvidn dfc2206b9f merged RC_1_1 into master 2016-06-11 01:00:41 -04:00
Arvid Norberg 5ecd00c5c5 fix osx build (#804)
fix osx build with asserts enabled
2016-06-11 00:48:13 -04:00
arvidn f4a95131c5 improve asserts in dht_storage 2016-06-10 00:55:17 -04:00
Alden Torres 9d3cf5e68b changed min_distance_exp for correctness and clarity (#789)
changed min_distance_exp for correctness and clarity
2016-06-06 18:22:33 -04:00
Arvid Norberg 223f24ca27 some cleanup and transition to std::unique_ptr (#786)
some cleanup and transition to std::unique_ptr
2016-06-05 14:07:24 -04:00
Alden Torres db65eb320a making dht counters additive (#783)
make dht counters additive to support both IPv4 and IPv6
2016-06-04 14:04:29 -04:00
Arvid Norberg 8c8f5bb03b deprecated public to_hex() and from_hex() functions (#784) 2016-06-04 10:01:43 -04:00
Alden Torres 7c4d92a627 Share the DHT storage for both IPv4 and IPv6 (#762) 2016-06-03 19:44:16 -04:00
arvidn 420b5f51e6 merged RC_1_1 into master 2016-05-27 12:35:53 -07:00
Arvid Norberg 96999ad67f replace uses of boost::bind with std::bind and lambdas (#745) 2016-05-25 00:31:52 -04:00
arvidn 98eabc63e9 using _WIN32 appears safer than WIN32 2016-05-23 23:02:52 -04:00
Arvid Norberg 748af6eec1 general cleanup. remove valgrind markup, log_hash_failures and C headers (#752)
general cleanup. remove valgrind markup, log_hash_failures and C headers
2016-05-23 08:15:39 -04:00
Arvid Norberg 584d74e2f0 fix union storage hacks (#670)
remove union storage hacks
2016-05-21 21:04:47 -04:00
arvidn aa0d29b67d merged RC_1_1 into master 2016-05-19 01:28:22 -04:00
Arvid Norberg e8380e1d0b factor out includes from config.hpp into the files actually using it. primarily, printf family of functions, since C++11 version is used now. This removes the need for an snprintf-wrapper on windows (#732) 2016-05-17 09:24:06 -04:00
Arvid Norberg 53bd03558c Dht stats 1.1 (#720)
fix missing dht stats counter updates
2016-05-12 21:27:11 -04:00
Arvid Norberg c6369194f0 simplify and optimize DHT routing table IP distance comparison (#696) 2016-05-03 23:22:25 -04:00
Arvid Norberg 077e9bb10c improve node-id operations (#693)
improve node-id operations, to operate on 32 bits at a time instead of 8. move out some code into sha1_hash.cpp, from the header file
2016-05-03 08:29:27 -04:00
Arvid Norberg c91a700c07 Msvc warnings (#685)
fix msvc warnings and build examples with warnings-as-errors
2016-05-02 12:36:21 -04:00
Steven Siloti ff0675e64e use standard array container (#676) 2016-04-30 23:10:47 -04:00
Arvid Norberg 20b41ad0b9 Threads (#671)
use std::thread, std::mutex, std::condition_variable instead of pulling them in from boost.asio internals.
2016-04-30 18:54:23 -04:00
Arvid Norberg 4e97bf556c use override and final keywords (unconditionally) (#668)
use override and final keywords instead of macros.
2016-04-30 11:05:54 -04:00
Arvid Norberg c557432431 attempt to run cppcheck on travis (#644)
run cppcheck on travis
2016-04-26 18:09:11 -04:00
Arvid Norberg 3c785b96fc Merge pull request #268 from ssiloti/dht-ipv6
Support DHT over IPv6
2016-04-25 19:19:48 -04:00
Andrei Kurushin 62eb956c54 fix x64 build with VS2015 UP2 compiler (#640)
fix VS2015 compiler warnings for: address-model=64, deprecated-functions=on, link=shared
2016-04-25 17:22:09 -04:00
Steven Siloti 2d9a6b76f1 use asio::protcol instead of an enum/bool 2016-04-24 15:18:47 -07:00
Steven Siloti d3ecc4c906 reduce the number of peers in a get_peers response with IPv6
Since IPv6 addresses are bigger we need to compensate to avoid generating
packets larger than 1500 bytes.
2016-04-24 14:26:57 -07:00
Steven Siloti 2abd9867ce IPv6 DHT support
Fixes #110
2016-04-24 14:26:57 -07:00
Steven Siloti 356d2506bd extend dht_observer to support IPv6 external addresses 2016-04-24 14:26:57 -07:00
Steven Siloti 11fa4f3e47 support IPv6 in node_entry and m_ips 2016-04-24 14:26:57 -07:00
Arvid Norberg 7251575d98 This patch does: (#633)
1. simplifies and regularizies creation of listen sockets based on the listen
   interfaces setting.
2. simplifies and improves the behavior of UDP sockets, which are now explicitly
   opened per listen interface
3. transitions udp tracker, DHT and uTP socket manager over to using the new
   udp sockets
4. greatly simplified udp_socket to only wrap a single underlying socket (as
   opposed to one IPv4 and IPv6 socket)
5. improved behavior of bind-to-device
6. introduce an array_view type to make udp packet passing code simpler
7. simplify and make setting of DF flag more robust
8. simplify and regularize port mapping of listen sockets
2016-04-24 15:26:28 -04:00
Andrei Kurushin 7b5d48c02a fix default release build with VS2015 UP2 compiler warnings (#624)
* fix default release build with VS2015 UP2 compiler warnings
this will allow to successfully build:
bjam toolset=msvc-14.0 release deprecated-functions=off character-set=unicode link=static warnings-as-errors=on
2016-04-17 16:56:07 -04:00
arvidn 6d85c7c5f0 merge RC_1_1 into master 2016-03-08 01:10:48 -05:00
Alden Torres 4998bfedc6 Documentation typos 2016-03-04 10:43:25 -05:00
arvidn d5203c67d9 add DHT rate limit test (simulation). introduce a new counter for dropped incoming dht messages. 2016-01-18 14:34:42 -05:00
arvidn 06b52f1421 some cleanup of the dht_socket_interface and fix tests and simulations to build with the dht disabled 2016-01-18 14:34:42 -05:00
arvidn 297b8943d0 move the DHT rate limiter into the dht_tracker class and remove the rate_limited_udp_socket type. This further simplifies the udp socket (preparing for moving it into the listen_socket structure) 2016-01-18 14:34:41 -05:00
arvidn 1f9f588e75 merge copyright year update and changelog from RC_1_0 2016-01-17 18:57:46 -05:00
arvidn f4d643bd2d instead of restarting the whole DHT when changing external IP, just rebuild the routing table and change the node IDs 2016-01-11 21:17:25 -05:00
Alden Torres 0f442f59f3 Avoid pass IPv6 address to current implementation of DHT while adding a node 2016-01-09 18:46:19 -05:00
arvidn e06daa68a4 overhaul the dht simulator (setup_dht) to be more flexible and cheaper to run thousands of nodes 2016-01-09 01:08:52 -05:00
arvidn d954ae1b18 simplify dht routing table add 2016-01-02 20:03:18 -05:00
arvidn 07ddb010c5 split buckets when exceeding the next bucket's size, to make sure we split before risking discarding nodes because the next bucket is smaller 2016-01-02 00:45:44 -05:00
arvidn e3ba811ae4 improve name of m_timer in dht_tracker 2016-01-01 16:42:44 -05:00
arvidn 01e6b93854 simplify and improve unit test for distance_exp. make some immutable variables const in the DHT implementation. instead of waking up periodically just to check if it's time to refresh the DHT secret key, set the timer to only wake up to refresh the key. If we don't have a DHT observer (to ask for our external IP) or if we don't know our external IP, don't generate a node ID based on 0.0.0.0, just generate a random ID instead. Simplified and improved node replacement logic in the routing table a little bit 2016-01-01 16:42:37 -05:00
Arvid Norberg ffb78f0378 Merge pull request #312 from ssiloti/export-verify-message
export verify_message and incoming_error
2015-12-30 22:51:38 -05:00
Steven Siloti ac01ccc43a add templated wrapper around verify_message
It was too easy to forget to update the ret and size parameters
when the size of desec changed. With this change we now automatically
get the size of desc and enforce that ret has the same size.

It would be nice if we could use bdecode_node ret[static Size] from C99
but that is not widely supported.
2015-12-29 20:35:36 -08:00
arvidn 626baade75 fix dht_storage bug 2015-12-19 22:06:25 -05:00