Commit Graph

495 Commits

Author SHA1 Message Date
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
arvidn 28749466a2 fix build 2015-12-19 02:40:10 -05:00
arvidn 15ec839d33 extend the unit test of dht_storage 2015-12-19 02:09:06 -05:00
Steven Siloti c6f1e0bd7b export verify_message and incoming_error
Also move these functions to a new msg.cpp. They are useful for plugins
which implement DHT extensions.
2015-12-05 18:20:08 -08:00
arvidn 8732863a9a another fix to receiving malformed DHT error message 2015-12-03 01:08:27 -05:00
arvidn 7540a6e5cc correctly check incoming DHT error messages 2015-11-30 18:02:00 -05:00
arvidn 332799bff2 make alert types declared final and disable the log alert declarations when logging is disabled 2015-11-29 10:16:02 -05:00
Thomas Yuan 603ef84c65 Fix observer_size. 2015-11-23 11:06:20 -05:00
Steven Siloti 9c7edf803e add override and a TODO 2015-11-22 18:58:32 -08:00
Steven Siloti 9f7aa7f3a6 fix segfault in put_data
If less than three nodes are found to put an item to then traversal_algorithm::start
will add router nodes. This leads to a crash in put_data::invoke when it tries to
read a token from uninitialized memory in a null_observer.
2015-11-22 16:05:24 -08:00
Steven Siloti 1f13343a70 const correctness 2015-11-22 10:02:26 -08:00
Steven Siloti 8a984effa7 allow done() with a non-zero invoke count 2015-11-22 10:02:26 -08:00
Steven Siloti 6c5bed63d3 whitespace cleanup 2015-11-22 10:02:26 -08:00
Thomas Yuan ab70ad3e05 fix comments and unit test 2015-11-20 00:06:08 -05:00
Thomas Yuan 194ad410dc Make dht_put_alert more accurate. 2015-11-20 00:06:08 -05:00
Steven Siloti 86116caf4c fix assert after a DHT get/put request
If an observer is abandoned due to there being more than 100 results in a
traversal then the traversal may complete while the observer is still
outstanding. When the observer times out or is aborted it calls
traversal_algorithm::failed() which asserts because m_invoke_count has been
cleared to zero by traversal_algorithm::done().

To fix this add a check when abandoning observers to see if they have an
outstanding query. If they do then flag them as done to prevent them from
calling back into the traversal and decrement the invoke count.

Fixes #271
2015-11-16 21:05:32 -08:00
Steven Siloti ba1ccdec66 fix assert in dht::observer
This is was introduced by c2277b3ea5
"fix traversal_algorithm::done() being invoked more than once".
2015-11-14 18:30:42 -08:00
Steven Siloti c2277b3ea5 fix traversal_algorithm::done() being invoked more than once
A traversal can be done while there are still outstanding queries (i.e.
m_invoke_count is non-zero) if K good responses have already been received and
none of the outstanding queries are closer than the nodes which have responded.

When this happens and the outstanding queries eventually complete or timeout
they call traversal_algorithm::failed() or traversal_algorithm::finished() as
usual which will cause traversal_algorithm::done() to be called yet again.

The fix is to always set the done flag on all queried observers in
traversal_algorithm::done() so that the observers will refrain from calling
back into the traversal.

This also makes traversal_algorithm::abort() redundant since this was the only
thing it did before it called into done().
2015-11-09 20:47:33 -08:00
arvidn 3cc464805f update libsimulator submodule 2015-10-25 10:55:20 -04:00
arvidn a75dfe2eb6 silence warnings in boost headers in dht_storage 2015-10-25 09:30:56 -04:00
Steven Siloti 4151c8e366 assert that the signature is valid when assigning a mutable value to an item 2015-10-21 20:29:29 -07:00
Alden Torres 62b24d8b67 Add set_dht_storage to session API. 2015-10-02 09:00:07 -04:00
Arvid Norberg d7cdcf9369 Merge pull request #183 from thomas-yuan/ta_init
start 'find' from near nodes instead of all of nodes in routing table.
2015-09-30 00:43:14 -04:00
Alden Torres 197a443465 Fix of dht_storage_counters::peers counter. 2015-09-24 10:50:04 -04:00
Thomas Yuan 0d2644802d start 'find' from near nodes instead of all of nodes in routing table. 2015-09-23 17:04:33 -04:00
Thomas Yuan f9fa8ffdec Use ping instead of get_peers if current bucket is full. 2015-09-22 10:35:10 -04:00
Thomas Yuan 7fec9e488d make immutable/mutable items lifetime configurable. 2015-09-21 20:32:37 -04:00
Alden Torres 25ed70b977 Create dht_storage_counters to avoid internal counter in future public API. 2015-09-21 07:46:23 -04:00
Arvid Norberg 6bf1971452 Merge pull request #162 from thomas-yuan/bootstrap
Only re-bootstrap when there is no enough nodes in routing table.
2015-09-20 14:52:16 -04:00