00001 /* 00002 00003 Copyright (c) 2003, Arvid Norberg 00004 All rights reserved. 00005 00006 Redistribution and use in source and binary forms, with or without 00007 modification, are permitted provided that the following conditions 00008 are met: 00009 00010 * Redistributions of source code must retain the above copyright 00011 notice, this list of conditions and the following disclaimer. 00012 * Redistributions in binary form must reproduce the above copyright 00013 notice, this list of conditions and the following disclaimer in 00014 the documentation and/or other materials provided with the distribution. 00015 * Neither the name of the author nor the names of its 00016 contributors may be used to endorse or promote products derived 00017 from this software without specific prior written permission. 00018 00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00022 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00023 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 POSSIBILITY OF SUCH DAMAGE. 00030 00031 */ 00032 00033 #ifndef TORRENT_SESSION_SETTINGS_HPP_INCLUDED 00034 #define TORRENT_SESSION_SETTINGS_HPP_INCLUDED 00035 00036 #include "libtorrent/version.hpp" 00037 00038 namespace libtorrent 00039 { 00040 00041 struct TORRENT_EXPORT session_settings 00042 { 00043 session_settings(std::string const& user_agent_ = "libtorrent/" 00044 LIBTORRENT_VERSION) 00045 : proxy_port(0) 00046 , user_agent(user_agent_) 00047 , tracker_completion_timeout(60) 00048 , tracker_receive_timeout(20) 00049 , stop_tracker_timeout(10) 00050 , tracker_maximum_response_length(1024*1024) 00051 , piece_timeout(120) 00052 , request_queue_time(3.f) 00053 , max_allowed_in_request_queue(250) 00054 , max_out_request_queue(200) 00055 , whole_pieces_threshold(20) 00056 , peer_timeout(120) 00057 , urlseed_timeout(20) 00058 , urlseed_pipeline_size(5) 00059 , file_pool_size(40) 00060 , allow_multiple_connections_per_ip(false) 00061 #ifndef TORRENT_DISABLE_DHT 00062 , use_dht_as_fallback(true) 00063 #endif 00064 {} 00065 00066 std::string proxy_ip; 00067 int proxy_port; 00068 std::string proxy_login; 00069 std::string proxy_password; 00070 00071 // this is the user agent that will be sent to the tracker 00072 // when doing requests. It is used to identify the client. 00073 // It cannot contain \r or \n 00074 std::string user_agent; 00075 00076 // the number of seconds to wait until giving up on a 00077 // tracker request if it hasn't finished 00078 int tracker_completion_timeout; 00079 00080 // the number of seconds where no data is received 00081 // from the tracker until it should be considered 00082 // as timed out 00083 int tracker_receive_timeout; 00084 00085 // the time to wait when sending a stopped message 00086 // before considering a tracker to have timed out. 00087 // this is usually shorter, to make the client quit 00088 // faster 00089 int stop_tracker_timeout; 00090 00091 // if the content-length is greater than this value 00092 // the tracker connection will be aborted 00093 int tracker_maximum_response_length; 00094 00095 // the number of seconds from a request is sent until 00096 // it times out if no piece response is returned. 00097 int piece_timeout; 00098 00099 // the length of the request queue given in the number 00100 // of seconds it should take for the other end to send 00101 // all the pieces. i.e. the actual number of requests 00102 // depends on the download rate and this number. 00103 float request_queue_time; 00104 00105 // the number of outstanding block requests a peer is 00106 // allowed to queue up in the client. If a peer sends 00107 // more requests than this (before the first one has 00108 // been sent) the last request will be dropped. 00109 // the higher this is, the faster upload speeds the 00110 // client can get to a single peer. 00111 int max_allowed_in_request_queue; 00112 00113 // the maximum number of outstanding requests to 00114 // send to a peer. This limit takes precedence over 00115 // request_queue_time. 00116 int max_out_request_queue; 00117 00118 // if a whole piece can be downloaded in this number 00119 // of seconds, or less, the peer_connection will prefer 00120 // to request whole pieces at a time from this peer. 00121 // The benefit of this is to better utilize disk caches by 00122 // doing localized accesses and also to make it easier 00123 // to identify bad peers if a piece fails the hash check. 00124 int whole_pieces_threshold; 00125 00126 // the number of seconds to wait for any activity on 00127 // the peer wire before closing the connectiong due 00128 // to time out. 00129 int peer_timeout; 00130 00131 // same as peer_timeout, but only applies to url-seeds. 00132 // this is usually set lower, because web servers are 00133 // expected to be more reliable. 00134 int urlseed_timeout; 00135 00136 // controls the pipelining size of url-seeds 00137 int urlseed_pipeline_size; 00138 00139 // sets the upper limit on the total number of files this 00140 // session will keep open. The reason why files are 00141 // left open at all is that some anti virus software 00142 // hooks on every file close, and scans the file for 00143 // viruses. deferring the closing of the files will 00144 // be the difference between a usable system and 00145 // a completely hogged down system. Most operating 00146 // systems also has a limit on the total number of 00147 // file descriptors a process may have open. It is 00148 // usually a good idea to find this limit and set the 00149 // number of connections and the number of files 00150 // limits so their sum is slightly below it. 00151 int file_pool_size; 00152 00153 // false to not allow multiple connections from the same 00154 // IP address. true will allow it. 00155 bool allow_multiple_connections_per_ip; 00156 00157 #ifndef TORRENT_DISABLE_DHT 00158 // while this is true, the dht will note be used unless the 00159 // tracker is online 00160 bool use_dht_as_fallback; 00161 #endif 00162 }; 00163 00164 #ifndef TORRENT_DISABLE_DHT 00165 struct dht_settings 00166 { 00167 dht_settings() 00168 : max_peers_reply(50) 00169 , search_branching(5) 00170 , service_port(6881) 00171 , max_fail_count(20) 00172 {} 00173 00174 // the maximum number of peers to send in a 00175 // reply to get_peers 00176 int max_peers_reply; 00177 00178 // the number of simultanous "connections" when 00179 // searching the DHT. 00180 int search_branching; 00181 00182 // the listen port for the dht. This is a UDP port. 00183 int service_port; 00184 00185 // the maximum number of times a node can fail 00186 // in a row before it is removed from the table. 00187 int max_fail_count; 00188 }; 00189 #endif 00190 00191 } 00192 00193 #endif
1.5.6