2006-04-25 23:04:48 +02:00
|
|
|
/*
|
|
|
|
|
2016-01-18 00:57:46 +01:00
|
|
|
Copyright (c) 2003-2016, Arvid Norberg
|
2006-04-25 23:04:48 +02:00
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in
|
|
|
|
the documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the author nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TORRENT_SESSION_SETTINGS_HPP_INCLUDED
|
|
|
|
#define TORRENT_SESSION_SETTINGS_HPP_INCLUDED
|
|
|
|
|
2007-04-25 20:26:35 +02:00
|
|
|
#include "libtorrent/config.hpp"
|
2015-06-07 06:23:30 +02:00
|
|
|
#include "libtorrent/settings_pack.hpp"
|
2015-08-25 04:18:10 +02:00
|
|
|
#include "libtorrent/aux_/proxy_settings.hpp"
|
2016-09-09 21:02:20 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
#include "libtorrent/version.hpp"
|
|
|
|
#endif
|
2006-05-21 01:24:19 +02:00
|
|
|
|
2010-10-10 04:22:57 +02:00
|
|
|
#include <string>
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
namespace libtorrent
|
|
|
|
{
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2014-02-03 03:41:24 +01:00
|
|
|
|
2016-04-30 06:24:45 +02:00
|
|
|
using aux::proxy_settings;
|
2014-07-06 21:18:00 +02:00
|
|
|
|
|
|
|
#endif
|
2008-04-24 05:28:48 +02:00
|
|
|
|
2013-07-24 18:27:17 +02:00
|
|
|
// structure used to hold configuration options for the DHT
|
|
|
|
//
|
2014-02-03 03:41:24 +01:00
|
|
|
// The ``dht_settings`` struct used to contain a ``service_port`` member to
|
|
|
|
// control which port the DHT would listen on and send messages from. This
|
|
|
|
// field is deprecated and ignored. libtorrent always tries to open the UDP
|
|
|
|
// socket on the same port as the TCP socket.
|
|
|
|
struct TORRENT_EXPORT dht_settings
|
2006-08-01 17:27:08 +02:00
|
|
|
{
|
2014-02-03 03:41:24 +01:00
|
|
|
// initialized dht_settings to the default values
|
2006-08-01 17:27:08 +02:00
|
|
|
dht_settings()
|
2009-10-26 23:44:49 +01:00
|
|
|
: max_peers_reply(100)
|
2006-08-01 17:27:08 +02:00
|
|
|
, search_branching(5)
|
2010-11-29 02:33:05 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2007-03-15 23:03:56 +01:00
|
|
|
, service_port(0)
|
2010-11-29 02:33:05 +01:00
|
|
|
#endif
|
2006-08-01 17:27:08 +02:00
|
|
|
, max_fail_count(20)
|
2011-05-23 07:07:52 +02:00
|
|
|
, max_torrents(2000)
|
|
|
|
, max_dht_items(700)
|
2015-12-19 08:09:06 +01:00
|
|
|
, max_peers(5000)
|
2009-09-27 05:38:41 +02:00
|
|
|
, max_torrent_search_reply(20)
|
2011-01-08 09:54:51 +01:00
|
|
|
, restrict_routing_ips(true)
|
|
|
|
, restrict_search_ips(true)
|
2012-09-22 23:40:16 +02:00
|
|
|
, extended_routing_table(true)
|
2013-01-20 08:54:54 +01:00
|
|
|
, aggressive_lookups(true)
|
2013-09-09 09:08:02 +02:00
|
|
|
, privacy_lookups(false)
|
2013-10-14 03:03:43 +02:00
|
|
|
, enforce_node_id(false)
|
2014-01-19 08:44:16 +01:00
|
|
|
, ignore_dark_internet(true)
|
2015-01-02 00:24:21 +01:00
|
|
|
, block_timeout(5 * 60)
|
|
|
|
, block_ratelimit(5)
|
2015-09-01 23:07:38 +02:00
|
|
|
, read_only(false)
|
2015-09-10 21:04:19 +02:00
|
|
|
, item_lifetime(0)
|
2016-01-17 21:09:27 +01:00
|
|
|
, upload_rate_limit(8000)
|
2006-08-01 17:27:08 +02:00
|
|
|
{}
|
2015-05-30 19:41:38 +02:00
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// the maximum number of peers to send in a reply to ``get_peers``
|
2006-08-01 17:27:08 +02:00
|
|
|
int max_peers_reply;
|
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// the number of concurrent search request the node will send when
|
|
|
|
// announcing and refreshing the routing table. This parameter is called
|
|
|
|
// alpha in the kademlia paper
|
2006-08-01 17:27:08 +02:00
|
|
|
int search_branching;
|
2015-05-30 19:41:38 +02:00
|
|
|
|
2010-11-29 02:33:05 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2014-02-03 03:41:24 +01:00
|
|
|
// the listen port for the dht. This is a UDP port. zero means use the
|
|
|
|
// same as the tcp interface
|
2006-08-01 17:27:08 +02:00
|
|
|
int service_port;
|
2010-11-29 02:33:05 +01:00
|
|
|
#endif
|
2015-05-30 19:41:38 +02:00
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// the maximum number of failed tries to contact a node before it is
|
|
|
|
// removed from the routing table. If there are known working nodes that
|
|
|
|
// are ready to replace a failing node, it will be replaced immediately,
|
|
|
|
// this limit is only used to clear out nodes that don't have any node
|
|
|
|
// that can replace them.
|
2006-08-01 17:27:08 +02:00
|
|
|
int max_fail_count;
|
2009-09-27 05:38:41 +02:00
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// the total number of torrents to track from the DHT. This is simply an
|
|
|
|
// upper limit to make sure malicious DHT nodes cannot make us allocate
|
2013-07-24 18:27:17 +02:00
|
|
|
// an unbounded amount of memory.
|
2011-01-19 06:57:44 +01:00
|
|
|
int max_torrents;
|
|
|
|
|
2011-05-23 07:07:52 +02:00
|
|
|
// max number of items the DHT will store
|
|
|
|
int max_dht_items;
|
2011-01-19 06:57:44 +01:00
|
|
|
|
2015-12-19 08:09:06 +01:00
|
|
|
// the max number of peers to store per torrent (for the DHT)
|
|
|
|
int max_peers;
|
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// the max number of torrents to return in a torrent search query to the
|
|
|
|
// DHT
|
2009-09-27 05:38:41 +02:00
|
|
|
int max_torrent_search_reply;
|
2011-01-08 09:54:51 +01:00
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// determines if the routing table entries should restrict entries to one
|
|
|
|
// per IP. This defaults to true, which helps mitigate some attacks on
|
|
|
|
// the DHT. It prevents adding multiple nodes with IPs with a very close
|
|
|
|
// CIDR distance.
|
2013-07-24 18:27:17 +02:00
|
|
|
//
|
2014-02-03 03:41:24 +01:00
|
|
|
// when set, nodes whose IP address that's in the same /24 (or /64 for
|
|
|
|
// IPv6) range in the same routing table bucket. This is an attempt to
|
|
|
|
// mitigate node ID spoofing attacks also restrict any IP to only have a
|
|
|
|
// single entry in the whole routing table
|
2011-01-08 09:54:51 +01:00
|
|
|
bool restrict_routing_ips;
|
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// determines if DHT searches should prevent adding nodes with IPs with
|
|
|
|
// very close CIDR distance. This also defaults to true and helps
|
2013-07-24 18:27:17 +02:00
|
|
|
// mitigate certain attacks on the DHT.
|
2011-01-08 09:54:51 +01:00
|
|
|
bool restrict_search_ips;
|
2012-09-22 23:40:16 +02:00
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// makes the first buckets in the DHT routing table fit 128, 64, 32 and
|
|
|
|
// 16 nodes respectively, as opposed to the standard size of 8. All other
|
|
|
|
// buckets have size 8 still.
|
2012-09-22 23:40:16 +02:00
|
|
|
bool extended_routing_table;
|
2013-01-20 08:54:54 +01:00
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// slightly changes the lookup behavior in terms of how many outstanding
|
|
|
|
// requests we keep. Instead of having branch factor be a hard limit, we
|
|
|
|
// always keep *branch factor* outstanding requests to the closest nodes.
|
|
|
|
// i.e. every time we get results back with closer nodes, we query them
|
|
|
|
// right away. It lowers the lookup times at the cost of more outstanding
|
|
|
|
// queries.
|
2013-01-20 08:54:54 +01:00
|
|
|
bool aggressive_lookups;
|
2013-09-09 09:08:02 +02:00
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// when set, perform lookups in a way that is slightly more expensive,
|
|
|
|
// but which minimizes the amount of information leaked about you.
|
2013-09-09 09:08:02 +02:00
|
|
|
bool privacy_lookups;
|
2013-10-14 03:03:43 +02:00
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// when set, node's whose IDs that are not correctly generated based on
|
|
|
|
// its external IP are ignored. When a query arrives from such node, an
|
|
|
|
// error message is returned with a message saying "invalid node ID".
|
2013-10-14 03:03:43 +02:00
|
|
|
bool enforce_node_id;
|
2014-01-19 08:44:16 +01:00
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// ignore DHT messages from parts of the internet we wouldn't expect to
|
|
|
|
// see any traffic from
|
2014-01-19 08:44:16 +01:00
|
|
|
bool ignore_dark_internet;
|
2015-01-02 00:24:21 +01:00
|
|
|
|
|
|
|
// the number of seconds a DHT node is banned if it exceeds the rate
|
|
|
|
// limit. The rate limit is averaged over 10 seconds to allow for bursts
|
|
|
|
// above the limit.
|
|
|
|
int block_timeout;
|
|
|
|
|
|
|
|
// the max number of packets per second a DHT node is allowed to send
|
|
|
|
// without getting banned.
|
|
|
|
int block_ratelimit;
|
2015-09-01 23:07:38 +02:00
|
|
|
|
2015-09-03 00:09:49 +02:00
|
|
|
// when set, the other nodes won't keep this node in their routing
|
2015-09-01 23:07:38 +02:00
|
|
|
// tables, it's meant for low-power and/or ephemeral devices that
|
|
|
|
// cannot support the DHT, it is also useful for mobile devices which
|
|
|
|
// are sensitive to network traffic and battery life.
|
|
|
|
// this node no longer responds to 'query' messages, and will place a
|
|
|
|
// 'ro' key (value = 1) in the top-level message dictionary of outgoing
|
|
|
|
// query messages.
|
|
|
|
bool read_only;
|
2015-09-10 21:04:19 +02:00
|
|
|
|
|
|
|
// the number of seconds a immutable/mutable item will be expired.
|
|
|
|
// default is 0, means never expires.
|
|
|
|
int item_lifetime;
|
2016-01-17 21:09:27 +01:00
|
|
|
|
|
|
|
// the number of bytes per second (on average) the DHT is allowed to send.
|
|
|
|
// If the incoming requests causes to many bytes to be sent in responses,
|
|
|
|
// incoming requests will be dropped until the quota has been replenished.
|
|
|
|
int upload_rate_limit;
|
2006-04-25 23:04:48 +02:00
|
|
|
};
|
2006-08-01 17:27:08 +02:00
|
|
|
|
2007-06-06 02:41:20 +02:00
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2013-08-08 03:03:54 +02:00
|
|
|
// The ``pe_settings`` structure is used to control the settings related
|
|
|
|
// to peer protocol encryption.
|
2014-02-03 03:41:24 +01:00
|
|
|
struct TORRENT_EXPORT pe_settings
|
2007-06-06 02:41:20 +02:00
|
|
|
{
|
2016-05-02 00:15:25 +02:00
|
|
|
// initializes the encryption settings with the default values
|
2007-06-06 02:41:20 +02:00
|
|
|
pe_settings()
|
|
|
|
: out_enc_policy(enabled)
|
|
|
|
, in_enc_policy(enabled)
|
|
|
|
, allowed_enc_level(both)
|
|
|
|
, prefer_rc4(false)
|
|
|
|
{}
|
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// the encoding policy options for use with pe_settings::out_enc_policy
|
|
|
|
// and pe_settings::in_enc_policy.
|
2007-06-06 02:41:20 +02:00
|
|
|
enum enc_policy
|
|
|
|
{
|
2014-02-03 03:41:24 +01:00
|
|
|
// Only encrypted connections are allowed. Incoming connections that
|
|
|
|
// are not encrypted are closed and if the encrypted outgoing
|
|
|
|
// connection fails, a non-encrypted retry will not be made.
|
2013-08-08 03:03:54 +02:00
|
|
|
forced,
|
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// encrypted connections are enabled, but non-encrypted connections
|
|
|
|
// are allowed. An incoming non-encrypted connection will be accepted,
|
|
|
|
// and if an outgoing encrypted connection fails, a non- encrypted
|
|
|
|
// connection will be tried.
|
2013-08-08 03:03:54 +02:00
|
|
|
enabled,
|
2015-12-19 08:09:06 +01:00
|
|
|
|
2013-08-08 03:03:54 +02:00
|
|
|
// only non-encrypted connections are allowed.
|
|
|
|
disabled
|
2007-06-06 02:41:20 +02:00
|
|
|
};
|
|
|
|
|
2014-02-03 03:41:24 +01:00
|
|
|
// the encryption levels, to be used with pe_settings::allowed_enc_level.
|
2007-06-06 02:41:20 +02:00
|
|
|
enum enc_level
|
|
|
|
{
|
2014-02-03 03:41:24 +01:00
|
|
|
// use only plaintext encryption
|
|
|
|
plaintext = 1,
|
2015-12-19 08:09:06 +01:00
|
|
|
// use only rc4 encryption
|
2014-02-03 03:41:24 +01:00
|
|
|
rc4 = 2,
|
|
|
|
// allow both
|
|
|
|
both = 3
|
2007-06-06 02:41:20 +02:00
|
|
|
};
|
|
|
|
|
2013-08-08 03:03:54 +02:00
|
|
|
// control the settings for incoming
|
|
|
|
// and outgoing connections respectively.
|
|
|
|
// see enc_policy enum for the available options.
|
2016-06-18 20:01:38 +02:00
|
|
|
std::uint8_t out_enc_policy;
|
|
|
|
std::uint8_t in_enc_policy;
|
2007-06-06 02:41:20 +02:00
|
|
|
|
2013-08-08 03:03:54 +02:00
|
|
|
// determines the encryption level of the
|
|
|
|
// connections. This setting will adjust which encryption scheme is
|
|
|
|
// offered to the other peer, as well as which encryption scheme is
|
|
|
|
// selected by the client. See enc_level enum for options.
|
2016-06-18 20:01:38 +02:00
|
|
|
std::uint8_t allowed_enc_level;
|
2013-08-08 03:03:54 +02:00
|
|
|
|
2007-06-06 02:41:20 +02:00
|
|
|
// if the allowed encryption level is both, setting this to
|
|
|
|
// true will prefer rc4 if both methods are offered, plaintext
|
|
|
|
// otherwise
|
|
|
|
bool prefer_rc4;
|
|
|
|
};
|
2014-07-06 21:18:00 +02:00
|
|
|
#endif // TORRENT_NO_DEPRECATE
|
2007-06-06 02:41:20 +02:00
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|