-
-
Notifications
You must be signed in to change notification settings - Fork 983
/
settings_pack.hpp
2236 lines (1966 loc) · 95.5 KB
/
settings_pack.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2014-2022, Arvid Norberg
Copyright (c) 2016-2018, Alden Torres
Copyright (c) 2017, Andrei Kurushin
Copyright (c) 2017, Steven Siloti
Copyright (c) 2018, TheOriginalWinCat
Copyright (c) 2019, Amir Abrams
Copyright (c) 2020, Paul-Louis Ageneau
Copyright (c) 2022, Kevin Bracey
All rights reserved.
You may use, distribute and modify this code under the terms of the BSD license,
see LICENSE file.
*/
#ifndef TORRENT_SETTINGS_PACK_HPP_INCLUDED
#define TORRENT_SETTINGS_PACK_HPP_INCLUDED
#include "libtorrent/entry.hpp"
#include "libtorrent/string_view.hpp"
#include "libtorrent/flags.hpp"
#include <vector>
#include <memory>
// OVERVIEW
//
// You have some control over session configuration through the session::apply_settings()
// member function. To change one or more configuration options, create a settings_pack
// object and fill it with the settings to be set and pass it in to session::apply_settings().
//
// The settings_pack object is a collection of settings updates that are applied
// to the session when passed to session::apply_settings(). It's empty when
// constructed.
//
// You have control over proxy and authorization settings and also the user-agent
// that will be sent to the tracker. The user-agent will also be used to identify the
// client with other peers.
//
// Each configuration option is named with an enum value inside the
// settings_pack class. These are the available settings:
namespace libtorrent {
namespace aux {
struct session_impl;
struct session_settings;
struct session_settings_single_thread;
}
struct settings_pack;
struct bdecode_node;
TORRENT_EXTRA_EXPORT settings_pack load_pack_from_dict(bdecode_node const& settings);
TORRENT_EXTRA_EXPORT void save_settings_to_dict(settings_pack const& sett, entry::dictionary_type& out);
TORRENT_EXTRA_EXPORT settings_pack non_default_settings(aux::session_settings const& sett);
TORRENT_EXTRA_EXPORT void apply_pack(settings_pack const* pack, aux::session_settings& sett
, aux::session_impl* ses = nullptr);
TORRENT_EXTRA_EXPORT void apply_pack_impl(settings_pack const* pack
, aux::session_settings_single_thread& sett
, std::vector<void(aux::session_impl::*)()>* callbacks = nullptr);
TORRENT_EXTRA_EXPORT void run_all_updates(aux::session_impl& ses);
// converts a setting integer (from the enums string_types, int_types or
// bool_types) to a string, and vice versa.
TORRENT_EXPORT int setting_by_name(string_view name);
TORRENT_EXPORT char const* name_for_setting(int s);
// returns a settings_pack with every setting set to its default value
TORRENT_EXPORT settings_pack default_settings();
// the common interface to settings_pack and the internal representation of
// settings.
struct TORRENT_EXPORT settings_interface
{
virtual void set_str(int name, std::string val) = 0;
virtual void set_int(int name, int val) = 0;
virtual void set_bool(int name, bool val) = 0;
virtual bool has_val(int name) const = 0;
virtual std::string const& get_str(int name) const = 0;
virtual int get_int(int name) const = 0;
virtual bool get_bool(int name) const = 0;
template <typename Type, typename Tag>
// hidden
void set_int(int name, flags::bitfield_flag<Type, Tag> const val)
{ set_int(name, static_cast<int>(static_cast<Type>(val))); }
// hidden
// these are here just to suppress the warning about virtual destructors
// internal
settings_interface() = default;
settings_interface(settings_interface const&) = default;
settings_interface(settings_interface&&) = default;
settings_interface& operator=(settings_interface const&) = default;
settings_interface& operator=(settings_interface&&) = default;
protected:
~settings_interface() = default;
};
// The ``settings_pack`` struct, contains the names of all settings as
// enum values. These values are passed in to the ``set_str()``,
// ``set_int()``, ``set_bool()`` functions, to specify the setting to
// change.
//
// The ``settings_pack`` only stores values for settings that have been
// explicitly set on this object. However, it can still be queried for
// settings that have not been set and returns the default value for those
// settings.
//
// .. include:: settings-ref.rst
//
struct TORRENT_EXPORT settings_pack final : settings_interface
{
friend TORRENT_EXTRA_EXPORT void apply_pack_impl(settings_pack const*
, aux::session_settings_single_thread&
, std::vector<void(aux::session_impl::*)()>*);
// hidden
settings_pack() = default;
settings_pack(settings_pack const&) = default;
settings_pack(settings_pack&&) noexcept = default;
settings_pack& operator=(settings_pack const&) = default;
settings_pack& operator=(settings_pack&&) noexcept = default;
// set a configuration option in the settings_pack. ``name`` is one of
// the enum values from string_types, int_types or bool_types. They must
// match the respective type of the set_* function.
void set_str(int name, std::string val) override;
void set_int(int name, int val) override;
void set_bool(int name, bool val) override;
template <typename Type, typename Tag>
void set_int(int name, flags::bitfield_flag<Type, Tag> const val)
{ set_int(name, static_cast<int>(static_cast<Type>(val))); }
// queries whether the specified configuration option has a value set in
// this pack. ``name`` can be any enumeration value from string_types,
// int_types or bool_types.
bool has_val(int name) const override;
// clear the settings pack from all settings
void clear();
// clear a specific setting from the pack
void clear(int name);
// queries the current configuration option from the settings_pack.
// ``name`` is one of the enumeration values from string_types, int_types
// or bool_types. The enum value must match the type of the get_*
// function. If the specified setting field has not been set, the default
// value is returned.
std::string const& get_str(int name) const override;
int get_int(int name) const override;
bool get_bool(int name) const override;
// setting names (indices) are 16 bits. The two most significant
// bits indicate what type the setting has. (string, int, bool)
enum type_bases
{
string_type_base = 0x0000,
int_type_base = 0x4000,
bool_type_base = 0x8000,
type_mask = 0xc000,
index_mask = 0x3fff
};
// internal
template <typename Fun>
void for_each(Fun&& f) const
{
for (auto const& s : m_strings) f(s.first, s.second);
for (auto const& i : m_ints) f(i.first, i.second);
for (auto const& b : m_bools) f(b.first, b.second);
}
// hidden
enum string_types
{
// this is the client identification to the tracker. The recommended
// format of this string is: "client-name/client-version
// libtorrent/libtorrent-version". This name will not only be used when
// making HTTP requests, but also when sending extended headers to
// peers that support that extension. It may not contain \r or \n
user_agent = string_type_base,
// ``announce_ip`` is the ip address passed along to trackers as the
// ``&ip=`` parameter. If left as the default, that parameter is
// omitted.
//
// .. note::
// This setting is only meant for very special cases where a seed is
// running on the same host as the tracker, and the tracker accepts
// the IP parameter (which normal trackers don't). Do not set this
// option unless you also control the tracker.
announce_ip,
#if TORRENT_ABI_VERSION == 1
// ``mmap_cache`` may be set to a filename where the disk cache will
// be mmapped to. This could be useful, for instance, to map the disk
// cache from regular rotating hard drives onto an SSD drive. Doing
// that effectively introduces a second layer of caching, allowing the
// disk cache to be as big as can fit on an SSD drive (probably about
// one order of magnitude more than the available RAM). The intention
// of this setting is to set it up once at the start up and not change
// it while running. The setting may not be changed as long as there
// are any disk buffers in use. This default to the empty string,
// which means use regular RAM allocations for the disk cache. The
// file specified will be created and truncated to the disk cache size
// (``cache_size``). Any existing file with the same name will be
// replaced.
//
// This feature requires the ``mmap`` system call, on systems that
// don't have ``mmap`` this setting is ignored.
mmap_cache TORRENT_DEPRECATED_ENUM,
#else
deprecated_mmap_cache,
#endif
// this is the client name and version identifier sent to peers in the
// handshake message. If this is an empty string, the user_agent is
// used instead. This string must be a UTF-8 encoded unicode string.
handshake_client_version,
// This controls which IP address outgoing TCP peer connections are bound
// to, in addition to controlling whether such connections are also
// bound to a specific network interface/adapter (*bind-to-device*).
//
// This string is a comma-separated list of IP addresses and
// interface names. An empty string will not bind TCP sockets to a
// device, and let the network stack assign the local address.
//
// A list of names will be used to bind outgoing TCP sockets in a
// round-robin fashion. An IP address will simply be used to `bind()`
// the socket. An interface name will attempt to bind the socket to
// that interface. If that fails, or is unsupported, one of the IP
// addresses configured for that interface is used to `bind()` the
// socket to. If the interface or adapter doesn't exist, the
// outgoing peer connection will fail with an error message suggesting
// the device cannot be found. Adapter names on Unix systems are of
// the form "eth0", "eth1", "tun0", etc. This may be useful for
// clients that are multi-homed. Binding an outgoing connection to a
// local IP does not necessarily make the connection via the
// associated NIC/Adapter.
//
// When outgoing interfaces are specified, incoming connections or
// packets sent to a local interface or IP that's *not* in this list
// will be rejected with a peer_blocked_alert with
// ``invalid_local_interface`` as the reason.
//
// Note that these are just interface/adapter names or IP addresses.
// There are no ports specified in this list. IPv6 addresses without
// port should be specified without enclosing ``[``, ``]``.
outgoing_interfaces,
// a comma-separated list of (IP or device name, port) pairs. These are
// the listen ports that will be opened for accepting incoming uTP and
// TCP peer connections. These are also used for *outgoing* uTP and UDP
// tracker connections and DHT nodes.
//
// It is possible to listen on multiple interfaces and
// multiple ports. Binding to port 0 will make the operating system
// pick the port.
//
// .. note::
// There are reasons to stick to the same port across sessions,
// which would mean only using port 0 on the first start, and
// recording the port that was picked for subsequent startups.
// Trackers, the DHT and other peers will remember the port they see
// you use and hand that port out to other peers trying to connect
// to you, as well as trying to connect to you themselves.
//
// A port that has an "s" suffix will accept SSL peer connections. (note
// that SSL sockets are only available in builds with SSL support)
//
// A port that has an "l" suffix will be considered a local network.
// i.e. it's assumed to only be able to reach hosts in the same local
// network as the IP address (based on the netmask associated with the
// IP, queried from the operating system).
//
// if binding fails, the listen_failed_alert is posted. Once a
// socket binding succeeds (if it does), the listen_succeeded_alert
// is posted. There may be multiple failures before a success.
//
// If a device name that does not exist is configured, no listen
// socket will be opened for that interface. If this is the only
// interface configured, it will be as if no listen ports are
// configured.
//
// If no listen ports are configured (e.g. listen_interfaces is an
// empty string), networking will be disabled. No DHT will start, no
// outgoing uTP or tracker connections will be made. No incoming TCP
// or uTP connections will be accepted. (outgoing TCP connections
// will still be possible, depending on
// settings_pack::outgoing_interfaces).
//
// For example:
// ``[::1]:8888`` - will only accept connections on the IPv6 loopback
// address on port 8888.
//
// ``eth0:4444,eth1:4444`` - will accept connections on port 4444 on
// any IP address bound to device ``eth0`` or ``eth1``.
//
// ``[::]:0s`` - will accept SSL connections on a port chosen by the
// OS. And not accept non-SSL connections at all.
//
// ``0.0.0.0:6881,[::]:6881`` - binds to all interfaces on port 6881.
//
// ``10.0.1.13:6881l`` - binds to the local IP address, port 6881, but
// only allow talking to peers on the same local network. The netmask
// is queried from the operating system. Interfaces marked ``l`` are
// not announced to trackers, unless the tracker is also on the same
// local network.
//
// Windows OS network adapter device name must be specified with GUID.
// It can be obtained from "netsh lan show interfaces" command output.
// GUID must be uppercased string embraced in curly brackets.
// ``{E4F0B674-0DFC-48BB-98A5-2AA730BDB6D6}:7777`` - will accept
// connections on port 7777 on adapter with this GUID.
//
// For more information, see the `Multi-homed hosts`_ section.
//
// .. _`Multi-homed hosts`: manual-ref.html#multi-homed-hosts
listen_interfaces,
// when using a proxy, this is the hostname where the proxy is running
// see proxy_type. Note that when using a proxy, the
// settings_pack::listen_interfaces setting is overridden and only a
// single interface is created, just to contact the proxy. This
// means a proxy cannot be combined with SSL torrents or multiple
// listen interfaces. This proxy listen interface will not accept
// incoming TCP connections, will not map ports with any gateway and
// will not enable local service discovery. All traffic is supposed
// to be channeled through the proxy.
proxy_hostname,
// when using a proxy, these are the credentials (if any) to use when
// connecting to it. see proxy_type
proxy_username,
proxy_password,
// sets the i2p_ SAM bridge to connect to. set the port with the
// ``i2p_port`` setting. Unless this is set, i2p torrents are not
// supported. This setting is separate from the other proxy settings
// since i2p torrents and their peers are orthogonal. You can have
// i2p peers as well as regular peers via a proxy.
//
// .. _i2p: http://www.i2p2.de
i2p_hostname,
// this is the fingerprint for the client. It will be used as the
// prefix to the peer_id. If this is 20 bytes (or longer) it will be
// truncated to 20 bytes and used as the entire peer-id
//
// There is a utility function, generate_fingerprint() that can be used
// to generate a standard client peer ID fingerprint prefix.
peer_fingerprint,
// This is a comma-separated list of IP port-pairs. They will be added
// to the DHT node (if it's enabled) as back-up nodes in case we don't
// know of any.
//
// Changing these after the DHT has been started may not have any
// effect until the DHT is restarted.
dht_bootstrap_nodes,
// This is the STUN server used by WebTorrent to enable ICE NAT
// traversal for WebRTC. It must have the format ``hostname:port``.
webtorrent_stun_server,
max_string_setting_internal
};
// hidden
enum bool_types
{
// determines if connections from the same IP address as existing
// connections should be rejected or not. Rejecting multiple connections
// from the same IP address will prevent abusive
// behavior by peers. The logic for determining whether connections are
// to the same peer is more complicated with this enabled, and more
// likely to fail in some edge cases. It is not recommended to enable
// this feature.
allow_multiple_connections_per_ip = bool_type_base,
#if TORRENT_ABI_VERSION == 1
// if set to true, upload, download and unchoke limits are ignored for
// peers on the local network. This option is *DEPRECATED*, please use
// set_peer_class_filter() instead.
ignore_limits_on_local_network TORRENT_DEPRECATED_ENUM,
#else
deprecated_ignore_limits_on_local_network,
#endif
// ``send_redundant_have`` controls if have messages will be sent to
// peers that already have the piece. This is typically not necessary,
// but it might be necessary for collecting statistics in some cases.
send_redundant_have,
#if TORRENT_ABI_VERSION == 1
// if this is true, outgoing bitfields will never be fuil. If the
// client is seed, a few bits will be set to 0, and later filled in
// with have messages. This is to prevent certain ISPs from stopping
// people from seeding.
lazy_bitfields TORRENT_DEPRECATED_ENUM,
#else
deprecated_lazy_bitfield,
#endif
// ``use_dht_as_fallback`` determines how the DHT is used. If this is
// true, the DHT will only be used for torrents where all trackers in
// its tracker list has failed. Either by an explicit error message or
// a time out. If this is false, the DHT is used regardless of if the
// trackers fail or not.
use_dht_as_fallback,
// ``upnp_ignore_nonrouters`` indicates whether or not the UPnP
// implementation should ignore any broadcast response from a device
// whose address is not on our subnet. i.e.
// it's a way to not talk to other people's routers by mistake.
upnp_ignore_nonrouters,
// ``use_parole_mode`` specifies if parole mode should be used. Parole
// mode means that peers that participate in pieces that fail the hash
// check are put in a mode where they are only allowed to download
// whole pieces. If the whole piece a peer in parole mode fails the
// hash check, it is banned. If a peer participates in a piece that
// passes the hash check, it is taken out of parole mode.
use_parole_mode,
#if TORRENT_ABI_VERSION == 1
// enable and disable caching of blocks read from disk. the purpose of
// the read cache is partly read-ahead of requests but also to avoid
// reading blocks back from the disk multiple times for popular
// pieces.
use_read_cache TORRENT_DEPRECATED_ENUM,
use_write_cache TORRENT_DEPRECATED_ENUM,
// this will make the disk cache never flush a write piece if it would
// cause is to have to re-read it once we want to calculate the piece
// hash
dont_flush_write_cache TORRENT_DEPRECATED_ENUM,
// allocate separate, contiguous, buffers for read and write calls.
// Only used where writev/readv cannot be used will use more RAM but
// may improve performance
coalesce_reads TORRENT_DEPRECATED_ENUM,
coalesce_writes TORRENT_DEPRECATED_ENUM,
#else
deprecated_use_read_cache,
deprecated_use_write_cache,
deprecated_flush_write_cache,
deprecated_coalesce_reads,
deprecated_coalesce_writes,
#endif
// if true, prefer seeding torrents when determining which torrents to give
// active slots to. If false, give preference to downloading torrents
auto_manage_prefer_seeds,
// if ``dont_count_slow_torrents`` is true, torrents without any
// payload transfers are not subject to the ``active_seeds`` and
// ``active_downloads`` limits. This is intended to make it more
// likely to utilize all available bandwidth, and avoid having
// torrents that don't transfer anything block the active slots.
dont_count_slow_torrents,
// ``close_redundant_connections`` specifies whether libtorrent should
// close connections where both ends have no utility in keeping the
// connection open. For instance if both ends have completed their
// downloads, there's no point in keeping it open.
close_redundant_connections,
// If ``prioritize_partial_pieces`` is true, partial pieces are picked
// before pieces that are more rare. If false, rare pieces are always
// prioritized, unless the number of partial pieces is growing out of
// proportion.
prioritize_partial_pieces,
// if set to true, the estimated TCP/IP overhead is drained from the
// rate limiters, to avoid exceeding the limits with the total traffic
rate_limit_ip_overhead,
// ``announce_to_all_trackers`` controls how multi tracker torrents
// are treated. If this is set to true, all trackers in the same tier
// are announced to in parallel. If all trackers in tier 0 fails, all
// trackers in tier 1 are announced as well. If it's set to false, the
// behavior is as defined by the multi tracker specification.
//
// ``announce_to_all_tiers`` also controls how multi tracker torrents
// are treated. When this is set to true, one tracker from each tier
// is announced to. This is the uTorrent behavior. To be compliant
// with the Multi-tracker specification, set it to false.
announce_to_all_tiers,
announce_to_all_trackers,
// ``prefer_udp_trackers``: true means that trackers
// may be rearranged in a way that udp trackers are always tried
// before http trackers for the same hostname. Setting this to false
// means that the tracker's tier is respected and there's no
// preference of one protocol over another.
prefer_udp_trackers,
#if TORRENT_ABI_VERSION == 1
// ``strict_super_seeding`` when this is set to true, a piece has to
// have been forwarded to a third peer before another one is handed
// out. This is the traditional definition of super seeding.
strict_super_seeding TORRENT_DEPRECATED_ENUM,
#else
deprecated_strict_super_seeding,
#endif
#if TORRENT_ABI_VERSION == 1
// if this is set to true, the memory allocated for the disk cache
// will be locked in physical RAM, never to be swapped out. Every time
// a disk buffer is allocated and freed, there will be the extra
// overhead of a system call.
lock_disk_cache TORRENT_DEPRECATED_ENUM,
#else
deprecated_lock_disk_cache,
#endif
// when set to true, all data downloaded from peers will be assumed to
// be correct, and not tested to match the hashes in the torrent this
// is only useful for simulation and testing purposes (typically
// combined with disabled_storage)
disable_hash_checks,
// if this is true, i2p torrents are allowed to also get peers from
// other sources than the tracker, and connect to regular IPs, not
// providing any anonymization. This may be useful if the user is not
// interested in the anonymization of i2p, but still wants to be able
// to connect to i2p peers.
allow_i2p_mixed,
#if TORRENT_ABI_VERSION == 1
// ``low_prio_disk`` determines if the disk I/O should use a normal or
// low priority policy. True, means that it's
// low priority by default. Other processes doing disk I/O will
// normally take priority in this mode. This is meant to improve the
// overall responsiveness of the system while downloading in the
// background. For high-performance server setups, this might not be
// desirable.
low_prio_disk TORRENT_DEPRECATED_ENUM,
#else
deprecated_low_prio_disk,
#endif
#if TORRENT_ABI_VERSION <= 2
// ``volatile_read_cache``, if this is set to true, read cache blocks
// that are hit by peer read requests are removed from the disk cache
// to free up more space. This is useful if you don't expect the disk
// cache to create any cache hits from other peers than the one who
// triggered the cache line to be read into the cache in the first
// place.
volatile_read_cache TORRENT_DEPRECATED_ENUM,
#else
deprecated_volatile_read_cache,
#endif
#if TORRENT_ABI_VERSION == 1
// ``guided_read_cache`` enables the disk cache to adjust the size of
// a cache line generated by peers to depend on the upload rate you
// are sending to that peer. The intention is to optimize the RAM
// usage of the cache, to read ahead further for peers that you're
// sending faster to.
guided_read_cache TORRENT_DEPRECATED_ENUM,
#else
deprecated_guided_read_cache,
#endif
// ``no_atime_storage`` this is a Linux-only option and passes in the
// ``O_NOATIME`` to ``open()`` when opening files. This may lead to
// some disk performance improvements.
no_atime_storage,
// ``incoming_starts_queued_torrents``. If a torrent
// has been paused by the auto managed feature in libtorrent, i.e. the
// torrent is paused and auto managed, this feature affects whether or
// not it is automatically started on an incoming connection. The main
// reason to queue torrents, is not to make them unavailable, but to
// save on the overhead of announcing to the trackers, the DHT and to
// avoid spreading one's unchoke slots too thin. If a peer managed to
// find us, even though we're no in the torrent anymore, this setting
// can make us start the torrent and serve it.
incoming_starts_queued_torrents,
// when set to true, the downloaded counter sent to trackers will
// include the actual number of payload bytes downloaded including
// redundant bytes. If set to false, it will not include any redundancy
// bytes
report_true_downloaded,
// ``strict_end_game_mode`` controls when a
// block may be requested twice. If this is ``true``, a block may only
// be requested twice when there's at least one request to every piece
// that's left to download in the torrent. This may slow down progress
// on some pieces sometimes, but it may also avoid downloading a lot
// of redundant bytes. If this is ``false``, libtorrent attempts to
// use each peer connection to its max, by always requesting
// something, even if it means requesting something that has been
// requested from another peer already.
strict_end_game_mode,
#if TORRENT_ABI_VERSION == 1
// if ``broadcast_lsd`` is set to true, the local peer discovery (or
// Local Service Discovery) will not only use IP multicast, but also
// broadcast its messages. This can be useful when running on networks
// that don't support multicast. Since broadcast messages might be
// expensive and disruptive on networks, only every 8th announce uses
// broadcast.
broadcast_lsd TORRENT_DEPRECATED_ENUM,
#else
deprecated_broadcast_lsd,
#endif
// Enables incoming and outgoing, TCP and uTP peer connections.
// ``false`` is disabled and ``true`` is enabled. When outgoing
// connections are disabled, libtorrent will simply not make
// outgoing peer connections with the specific transport protocol.
// Disabled incoming peer connections will simply be rejected.
// These options only apply to peer connections, not tracker- or any
// other kinds of connections.
enable_outgoing_utp,
enable_incoming_utp,
enable_outgoing_tcp,
enable_incoming_tcp,
#if TORRENT_ABI_VERSION == 1
// ``ignore_resume_timestamps`` determines if the storage, when
// loading resume data files, should verify that the file modification
// time with the timestamps in the resume data. False, means timestamps
// are taken into account, and resume
// data is less likely to accepted (torrents are more likely to be
// fully checked when loaded). It might be useful to set this to true
// if your network is faster than your disk, and it would be faster to
// redownload potentially missed pieces than to go through the whole
// storage to look for them.
ignore_resume_timestamps TORRENT_DEPRECATED_ENUM,
#else
// hidden
deprecated_ignore_resume_timestamps,
#endif
// ``no_recheck_incomplete_resume`` determines if the storage should
// check the whole files when resume data is incomplete or missing or
// whether it should simply assume we don't have any of the data. If
// false, any existing files will be checked.
// By setting this setting to true, the files won't be checked, but
// will go straight to download mode.
no_recheck_incomplete_resume,
// ``anonymous_mode``: When set to true, the client tries to hide
// its identity to a certain degree.
//
// * A generic user-agent will be
// used for trackers (except for private torrents).
// * Your local IPv4 and IPv6 address won't be sent as query string
// parameters to private trackers.
// * If announce_ip is configured, it will not be sent to trackers
// * The client version will not be sent to peers in the extension
// handshake.
anonymous_mode,
// specifies whether downloads from web seeds is reported to the
// tracker or not. Turning it off also excludes web
// seed traffic from other stats and download rate reporting via the
// libtorrent API.
report_web_seed_downloads,
#if TORRENT_ABI_VERSION == 1
// set to true if uTP connections should be rate limited This option
// is *DEPRECATED*, please use set_peer_class_filter() instead.
rate_limit_utp TORRENT_DEPRECATED_ENUM,
#else
deprecated_rate_limit_utp,
#endif
#if TORRENT_ABI_VERSION == 1
// if this is true, the ``&ip=`` argument in tracker requests (unless
// otherwise specified) will be set to the intermediate IP address if
// the user is double NATed. If the user is not double NATed, this
// option does not have an affect
announce_double_nat TORRENT_DEPRECATED_ENUM,
#else
deprecated_announce_double_nat,
#endif
// ``seeding_outgoing_connections`` determines if seeding (and
// finished) torrents should attempt to make outgoing connections or
// not. It may be set to false in very
// specific applications where the cost of making outgoing connections
// is high, and there are no or small benefits of doing so. For
// instance, if no nodes are behind a firewall or a NAT, seeds don't
// need to make outgoing connections.
seeding_outgoing_connections,
// when this is true, libtorrent will not attempt to make outgoing
// connections to peers whose port is < 1024. This is a safety
// precaution to avoid being part of a DDoS attack
no_connect_privileged_ports,
// ``smooth_connects`` means the number of
// connection attempts per second may be limited to below the
// ``connection_speed``, in case we're close to bump up against the
// limit of number of connections. The intention of this setting is to
// more evenly distribute our connection attempts over time, instead
// of attempting to connect in batches, and timing them out in
// batches.
smooth_connects,
// always send user-agent in every web seed request. If false, only
// the first request per http connection will include the user agent
always_send_user_agent,
// ``apply_ip_filter_to_trackers`` determines
// whether the IP filter applies to trackers as well as peers. If this
// is set to false, trackers are exempt from the IP filter (if there
// is one). If no IP filter is set, this setting is irrelevant.
apply_ip_filter_to_trackers,
#if TORRENT_ABI_VERSION == 1
// ``use_disk_read_ahead`` if true will attempt to
// optimize disk reads by giving the operating system heads up of disk
// read requests as they are queued in the disk job queue.
use_disk_read_ahead TORRENT_DEPRECATED_ENUM,
#else
deprecated_use_disk_read_ahead,
#endif
#if TORRENT_ABI_VERSION == 1
// ``lock_files`` determines whether or not to lock files which
// libtorrent is downloading to or seeding from. This is implemented
// using ``fcntl(F_SETLK)`` on Unix systems and by not passing in
// ``SHARE_READ`` and ``SHARE_WRITE`` on windows. This might prevent
// 3rd party processes from corrupting the files under libtorrent's
// feet.
lock_files TORRENT_DEPRECATED_ENUM,
#else
deprecated_lock_files,
#endif
#if TORRENT_ABI_VERSION == 1
// ``contiguous_recv_buffer`` determines whether or not libtorrent
// should receive data from peers into a contiguous intermediate
// buffer, to then copy blocks into disk buffers from, or to make many
// smaller calls to ``read()``, each time passing in the specific
// buffer the data belongs in. When downloading at high rates, the
// latter may save some time copying data. When seeding at high rates,
// all incoming traffic consists of a very large number of tiny
// packets, and enabling ``contiguous_recv_buffer`` will provide
// higher performance. When this is enabled, it will only be used when
// seeding to peers, since that's when it provides performance
// improvements.
contiguous_recv_buffer TORRENT_DEPRECATED_ENUM,
#else
deprecated_contiguous_recv_buffer,
#endif
// when true, web seeds sending bad data will be banned
ban_web_seeds,
#if TORRENT_ABI_VERSION <= 2
// when set to false, the ``write_cache_line_size`` will apply across
// piece boundaries. this is a bad idea unless the piece picker also
// is configured to have an affinity to pick pieces belonging to the
// same write cache line as is configured in the disk cache.
allow_partial_disk_writes TORRENT_DEPRECATED_ENUM,
#else
deprecated_allow_partial_disk_writes,
#endif
#if TORRENT_ABI_VERSION == 1
// If true, disables any communication that's not going over a proxy.
// Enabling this requires a proxy to be configured as well, see
// proxy_type and proxy_hostname settings. The listen sockets are
// closed, and incoming connections will only be accepted through a
// SOCKS5 or I2P proxy (if a peer proxy is set up and is run on the
// same machine as the tracker proxy).
force_proxy TORRENT_DEPRECATED_ENUM,
#else
deprecated_force_proxy,
#endif
// if false, prevents libtorrent to advertise share-mode support
support_share_mode,
#if TORRENT_ABI_VERSION <= 2
// support for BEP 30 merkle torrents has been removed
// if this is false, don't advertise support for the Tribler merkle
// tree piece message
support_merkle_torrents TORRENT_DEPRECATED_ENUM,
#else
deprecated_support_merkle_torrents,
#endif
// if this is true, the number of redundant bytes is sent to the
// tracker
report_redundant_bytes,
// if this is true, libtorrent will fall back to listening on a port
// chosen by the operating system (i.e. binding to port 0). If a
// failure is preferred, set this to false.
listen_system_port_fallback,
#if TORRENT_ABI_VERSION == 1
// ``use_disk_cache_pool`` enables using a pool allocator for disk
// cache blocks. Enabling it makes the cache perform better at high
// throughput. It also makes the cache less likely and slower at
// returning memory back to the system, once allocated.
use_disk_cache_pool TORRENT_DEPRECATED_ENUM,
#else
deprecated_use_disk_cache_pool,
#endif
// when this is true, and incoming encrypted connections are enabled,
// &supportcrypt=1 is included in http tracker announces
announce_crypto_support,
// Starts and stops the UPnP service. When started, the listen port
// and the DHT port are attempted to be forwarded on local UPnP router
// devices.
//
// The upnp object returned by ``start_upnp()`` can be used to add and
// remove arbitrary port mappings. Mapping status is returned through
// the portmap_alert and the portmap_error_alert. The object will be
// valid until ``stop_upnp()`` is called. See upnp-and-nat-pmp_.
enable_upnp,
// Starts and stops the NAT-PMP service. When started, the listen port
// and the DHT port are attempted to be forwarded on the router
// through NAT-PMP.
//
// The natpmp object returned by ``start_natpmp()`` can be used to add
// and remove arbitrary port mappings. Mapping status is returned
// through the portmap_alert and the portmap_error_alert. The object
// will be valid until ``stop_natpmp()`` is called. See
// upnp-and-nat-pmp_.
enable_natpmp,
// Starts and stops Local Service Discovery. This service will
// broadcast the info-hashes of all the non-private torrents on the
// local network to look for peers on the same swarm within multicast
// reach.
enable_lsd,
// starts the dht node and makes the trackerless service available to
// torrents.
enable_dht,
// if the allowed encryption level is both, setting this to true will
// prefer RC4 if both methods are offered, plain text otherwise
prefer_rc4,
// if true, hostname lookups are done via the configured proxy (if
// any). This is only supported by SOCKS5 and HTTP.
proxy_hostnames,
// if true, peer connections are made (and accepted) over the
// configured proxy, if any. Web seeds as well as regular bittorrent
// peer connections are considered "peer connections". Anything
// transporting actual torrent payload (trackers and DHT traffic are
// not considered peer connections).
proxy_peer_connections,
// if this setting is true, torrents with a very high availability of
// pieces (and seeds) are downloaded sequentially. This is more
// efficient for the disk I/O. With many seeds, the download order is
// unlikely to matter anyway
auto_sequential,
// if true, tracker connections are made over the configured proxy, if
// any.
proxy_tracker_connections,
// Starts and stops the internal IP table route changes notifier.
//
// The current implementation supports multiple platforms, and it is
// recommended to have it enable, but you may want to disable it if
// it's supported but unreliable, or if you have a better way to
// detect the changes. In the later case, you should manually call
// ``session_handle::reopen_network_sockets`` to ensure network
// changes are taken in consideration.
enable_ip_notifier,
// when this is true, nodes whose IDs are derived from their source
// IP according to `BEP 42`_ are preferred in the routing table.
dht_prefer_verified_node_ids,
// 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.
//
// 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
dht_restrict_routing_ips,
// determines if DHT searches should prevent adding nodes with IPs with
// very close CIDR distance. This also defaults to true and helps
// mitigate certain attacks on the DHT.
dht_restrict_search_ips,
// 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.
dht_extended_routing_table,
// 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.
dht_aggressive_lookups,
// when set, perform lookups in a way that is slightly more expensive,
// but which minimizes the amount of information leaked about you.
dht_privacy_lookups,
// 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".
dht_enforce_node_id,
// ignore DHT messages from parts of the internet we wouldn't expect to
// see any traffic from
dht_ignore_dark_internet,
// when set, the other nodes won't keep this node in their routing
// 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.
dht_read_only,
// when this is true, create an affinity for downloading 4 MiB extents
// of adjacent pieces. This is an attempt to achieve better disk I/O
// throughput by downloading larger extents of bytes, for torrents with
// small piece sizes
piece_extent_affinity,
// when set to true, the certificate of HTTPS trackers and HTTPS web
// seeds will be validated against the system's certificate store
// (as defined by OpenSSL). If the system does not have a
// certificate store, this option may have to be disabled in order
// to get trackers and web seeds to work).
validate_https_trackers,
// when enabled, tracker and web seed requests are subject to
// certain restrictions.
//
// An HTTP(s) tracker requests to localhost (loopback)
// must have the request path start with "/announce". This is the
// conventional bittorrent tracker request. Any other HTTP(S)
// tracker request to loopback will be rejected. This applies to
// trackers that redirect to loopback as well.
//
// Web seeds that end up on the client's local network (i.e. in a
// private IP address range) may not include query string arguments.
// This applies to web seeds redirecting to the local network as
// well.
//
// Web seeds on global IPs (i.e. not local network) may not redirect
// to a local network address
ssrf_mitigation,
// when disabled, any tracker or web seed with an IDNA hostname
// (internationalized domain name) is ignored. This is a security
// precaution to avoid various unicode encoding attacks that might
// happen at the application level.
allow_idna,
// when set to true, enables the attempt to use SetFileValidData()
// to pre-allocate disk space. This system call will only work when
// running with Administrator privileges on Windows, and so this
// setting is only relevant in that scenario. Using
// SetFileValidData() poses a security risk, as it may reveal
// previously deleted information from the disk.
enable_set_file_valid_data,
// When using a SOCKS5 proxy, UDP traffic is routed through the
// proxy by sending a UDP ASSOCIATE command. If this option is true,
// the UDP ASSOCIATE command will include the IP address and
// listen port to the local UDP socket. This indicates to the proxy
// which source endpoint to expect our packets from. The benefit is
// that incoming packets can be forwarded correctly, before any
// outgoing packets are sent. The risk is that if there's a NAT
// between the client and the proxy, the IP address specified in the
// protocol may not be valid from the proxy's point of view.
socks5_udp_send_local_ep,
max_bool_setting_internal
};