replaced http_settings with session_settings and introduced more settings
This commit is contained in:
parent
d891214358
commit
e6bb265d94
|
@ -1,3 +1,6 @@
|
|||
* exposed more settings for tweaking parameters in the piece-picker,
|
||||
downloader and uploader.
|
||||
* tweaked default settings to improve high bandwidth transfers.
|
||||
* improved the piece picker performance and made it possible to download
|
||||
popular pieces in sequence to improve disk performance.
|
||||
* added the possibility to control upload and download limits per peer.
|
||||
|
@ -9,8 +12,9 @@
|
|||
* changed the extensions protocol to use the new one, which is also
|
||||
implemented by uTorrent.
|
||||
* factorized the peer_connection and added web_peer_connection which is
|
||||
able to download from http-sources. (currently only for single file torrents).
|
||||
* converted the network code to use asio
|
||||
able to download from http-sources.
|
||||
* converted the network code to use asio (resulted in slight api changes
|
||||
dealing with network addresses).
|
||||
* made libtorrent build in vc7 (patches from Allen Zhao)
|
||||
* fixed bug caused when binding outgoing connections to a non-local interface.
|
||||
* add_torrent() will now throw if called while the session object is
|
||||
|
|
|
@ -54,7 +54,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/bencode.hpp"
|
||||
#include "libtorrent/session.hpp"
|
||||
#include "libtorrent/http_settings.hpp"
|
||||
#include "libtorrent/identify_client.hpp"
|
||||
#include "libtorrent/alert_types.hpp"
|
||||
|
||||
|
@ -511,8 +510,8 @@ int main(int ac, char* av[])
|
|||
if (vm.count("input-file") > 0)
|
||||
input = vm["input-file"].as< std::vector<std::string> >();
|
||||
|
||||
http_settings settings;
|
||||
settings.user_agent = "client_test";
|
||||
session_settings settings;
|
||||
settings.user_agent = "client_test " LIBTORRENT_VERSION;
|
||||
|
||||
std::deque<std::string> events;
|
||||
|
||||
|
@ -530,7 +529,7 @@ int main(int ac, char* av[])
|
|||
ses.set_upload_rate_limit(upload_limit);
|
||||
ses.listen_on(std::make_pair(listen_port, listen_port + 10)
|
||||
, bind_to_interface.c_str());
|
||||
ses.set_http_settings(settings);
|
||||
ses.set_settings(settings);
|
||||
if (log_level == "debug")
|
||||
ses.set_severity_level(alert::debug);
|
||||
else if (log_level == "warning")
|
||||
|
|
|
@ -10,7 +10,6 @@ libtorrent/escape_string.hpp \
|
|||
libtorrent/file.hpp \
|
||||
libtorrent/fingerprint.hpp \
|
||||
libtorrent/hasher.hpp \
|
||||
libtorrent/http_settings.hpp \
|
||||
libtorrent/http_tracker_connection.hpp \
|
||||
libtorrent/identify_client.hpp \
|
||||
libtorrent/invariant_check.hpp \
|
||||
|
|
|
@ -53,7 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/http_settings.hpp"
|
||||
#include "libtorrent/session_settings.hpp"
|
||||
#include "libtorrent/peer_id.hpp"
|
||||
#include "libtorrent/peer.hpp"
|
||||
#include "libtorrent/tracker_manager.hpp"
|
||||
|
@ -118,7 +118,7 @@ namespace libtorrent
|
|||
, unsigned short port
|
||||
, std::string request
|
||||
, boost::weak_ptr<request_callback> c
|
||||
, const http_settings& stn
|
||||
, session_settings const& stn
|
||||
, std::string const& password = "");
|
||||
|
||||
private:
|
||||
|
@ -160,7 +160,7 @@ namespace libtorrent
|
|||
std::string m_server_message;
|
||||
std::string m_server_protocol;
|
||||
|
||||
const http_settings& m_settings;
|
||||
session_settings const& m_settings;
|
||||
std::string m_password;
|
||||
int m_code;
|
||||
|
||||
|
|
|
@ -221,6 +221,8 @@ namespace libtorrent
|
|||
void connection_failed(boost::shared_ptr<stream_socket> const& s
|
||||
, tcp::endpoint const& a, char const* message);
|
||||
|
||||
void set_settings(session_settings const& s);
|
||||
|
||||
// this maps sockets to their peer_connection
|
||||
// object. It is the complete list of all connected
|
||||
// peers.
|
||||
|
@ -272,7 +274,6 @@ namespace libtorrent
|
|||
|
||||
// the settings for the client
|
||||
session_settings m_settings;
|
||||
http_settings m_http_settings;
|
||||
|
||||
// set to true when the session object
|
||||
// is being destructed and the thread
|
||||
|
@ -319,8 +320,6 @@ namespace libtorrent
|
|||
};
|
||||
}
|
||||
|
||||
struct http_settings;
|
||||
|
||||
struct TORRENT_EXPORT session_status
|
||||
{
|
||||
bool has_incoming_connections;
|
||||
|
@ -413,7 +412,8 @@ namespace libtorrent
|
|||
|
||||
void remove_torrent(const torrent_handle& h);
|
||||
|
||||
void set_http_settings(const http_settings& s);
|
||||
void set_settings(session_settings const& s);
|
||||
session_settings const& settings();
|
||||
void set_upload_rate_limit(int bytes_per_second);
|
||||
void set_download_rate_limit(int bytes_per_second);
|
||||
void set_max_uploads(int limit);
|
||||
|
|
|
@ -33,13 +33,22 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef TORRENT_SESSION_SETTINGS_HPP_INCLUDED
|
||||
#define TORRENT_SESSION_SETTINGS_HPP_INCLUDED
|
||||
|
||||
#include "libtorrent/version.hpp"
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
struct TORRENT_EXPORT session_settings
|
||||
{
|
||||
session_settings()
|
||||
: piece_timeout(120)
|
||||
session_settings(std::string const& user_agent_ = "libtorrent "
|
||||
LIBTORRENT_VERSION)
|
||||
: proxy_port(0)
|
||||
, user_agent(user_agent_)
|
||||
, tracker_completion_timeout(60)
|
||||
, tracker_receive_timeout(20)
|
||||
, stop_tracker_timeout(10)
|
||||
, tracker_maximum_response_length(1024*1024)
|
||||
, piece_timeout(120)
|
||||
, request_queue_time(3.f)
|
||||
, sequenced_download_threshold(7)
|
||||
, max_allowed_in_request_queue(250)
|
||||
|
@ -47,6 +56,35 @@ namespace libtorrent
|
|||
, whole_pieces_threshold(20)
|
||||
{}
|
||||
|
||||
std::string proxy_ip;
|
||||
int proxy_port;
|
||||
std::string proxy_login;
|
||||
std::string proxy_password;
|
||||
|
||||
// this is the user agent that will be sent to the tracker
|
||||
// when doing requests. It is used to identify the client.
|
||||
// It cannot contain \r or \n
|
||||
std::string user_agent;
|
||||
|
||||
// the number of seconds to wait until giving up on a
|
||||
// tracker request if it hasn't finished
|
||||
int tracker_completion_timeout;
|
||||
|
||||
// the number of seconds where no data is received
|
||||
// from the tracker until it should be considered
|
||||
// as timed out
|
||||
int tracker_receive_timeout;
|
||||
|
||||
// the time to wait when sending a stopped message
|
||||
// before considering a tracker to have timed out.
|
||||
// this is usually shorter, to make the client quit
|
||||
// faster
|
||||
int stop_tracker_timeout;
|
||||
|
||||
// if the content-length is greater than this value
|
||||
// the tracker connection will be aborted
|
||||
int tracker_maximum_response_length;
|
||||
|
||||
// the number of seconds from a request is sent until
|
||||
// it times out if no piece response is returned.
|
||||
int piece_timeout;
|
||||
|
|
|
@ -57,7 +57,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/http_settings.hpp"
|
||||
#include "libtorrent/session_settings.hpp"
|
||||
#include "libtorrent/peer_id.hpp"
|
||||
#include "libtorrent/peer.hpp"
|
||||
#include "libtorrent/config.hpp"
|
||||
|
@ -218,7 +218,7 @@ namespace libtorrent
|
|||
{
|
||||
public:
|
||||
|
||||
tracker_manager(const http_settings& s)
|
||||
tracker_manager(const session_settings& s)
|
||||
: m_settings(s) {}
|
||||
|
||||
void queue_request(
|
||||
|
@ -239,7 +239,7 @@ namespace libtorrent
|
|||
typedef std::list<boost::intrusive_ptr<tracker_connection> >
|
||||
tracker_connections_t;
|
||||
tracker_connections_t m_connections;
|
||||
const http_settings& m_settings;
|
||||
session_settings const& m_settings;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/socket.hpp"
|
||||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/http_settings.hpp"
|
||||
#include "libtorrent/session_settings.hpp"
|
||||
#include "libtorrent/peer_id.hpp"
|
||||
#include "libtorrent/peer.hpp"
|
||||
#include "libtorrent/tracker_manager.hpp"
|
||||
|
@ -72,7 +72,7 @@ namespace libtorrent
|
|||
, std::string const& hostname
|
||||
, unsigned short port
|
||||
, boost::weak_ptr<request_callback> c
|
||||
, const http_settings& stn);
|
||||
, session_settings const& stn);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace libtorrent
|
|||
|
||||
int m_transaction_id;
|
||||
boost::int64_t m_connection_id;
|
||||
const http_settings& m_settings;
|
||||
session_settings const& m_settings;
|
||||
int m_attempts;
|
||||
std::vector<char> m_buffer;
|
||||
};
|
||||
|
|
|
@ -1120,7 +1120,7 @@ namespace libtorrent
|
|||
|
||||
handshake["m"] = extension_list;
|
||||
handshake["p"] = m_ses.m_listen_interface.port();
|
||||
handshake["v"] = m_ses.m_http_settings.user_agent;
|
||||
handshake["v"] = m_ses.m_settings.user_agent;
|
||||
handshake["reqq"] = m_ses.m_settings.max_allowed_in_request_queue;
|
||||
|
||||
std::vector<char> msg;
|
||||
|
|
|
@ -237,7 +237,7 @@ namespace libtorrent
|
|||
, unsigned short port
|
||||
, std::string request
|
||||
, boost::weak_ptr<request_callback> c
|
||||
, const http_settings& stn
|
||||
, session_settings const& stn
|
||||
, std::string const& auth)
|
||||
: tracker_connection(man, req, d, c)
|
||||
, m_man(man)
|
||||
|
|
|
@ -409,7 +409,7 @@ namespace libtorrent { namespace detail
|
|||
std::pair<int, int> listen_port_range
|
||||
, const fingerprint& cl_fprint
|
||||
, char const* listen_interface)
|
||||
: m_tracker_manager(m_http_settings)
|
||||
: m_tracker_manager(m_settings)
|
||||
, m_listen_port_range(listen_port_range)
|
||||
, m_listen_interface(address::from_string(listen_interface), listen_port_range.first)
|
||||
, m_abort(false)
|
||||
|
@ -468,6 +468,23 @@ namespace libtorrent { namespace detail
|
|||
, m_extension_enabled + n, true) != m_extension_enabled + n;
|
||||
}
|
||||
|
||||
void session_impl::set_settings(session_settings const& s)
|
||||
{
|
||||
if (m_settings.sequenced_download_threshold
|
||||
!= s.sequenced_download_threshold)
|
||||
{
|
||||
for (torrent_map::iterator i = m_torrents.begin()
|
||||
, end(m_torrents.end()); i != end; ++i)
|
||||
{
|
||||
torrent& t = *i->second;
|
||||
if (t.valid_metadata())
|
||||
t.picker().set_sequenced_download_threshold(
|
||||
s.sequenced_download_threshold);
|
||||
}
|
||||
}
|
||||
m_settings = s;
|
||||
}
|
||||
|
||||
void session_impl::open_listen_port()
|
||||
{
|
||||
try
|
||||
|
@ -931,7 +948,7 @@ namespace libtorrent { namespace detail
|
|||
}
|
||||
}
|
||||
m_timer.expires_from_now(boost::posix_time::seconds(
|
||||
m_http_settings.stop_tracker_timeout));
|
||||
m_settings.stop_tracker_timeout));
|
||||
m_timer.async_wait(bind(&demuxer::interrupt, &m_selector));
|
||||
}
|
||||
|
||||
|
@ -1371,10 +1388,15 @@ namespace libtorrent
|
|||
return m_impl.m_listen_socket;
|
||||
}
|
||||
|
||||
void session::set_http_settings(const http_settings& s)
|
||||
void session::set_settings(session_settings const& s)
|
||||
{
|
||||
session_impl::mutex_t::scoped_lock l(m_impl.m_mutex);
|
||||
m_impl.m_http_settings = s;
|
||||
m_impl.set_settings(s);
|
||||
}
|
||||
|
||||
session_settings const& session::settings()
|
||||
{
|
||||
return m_impl.m_settings;
|
||||
}
|
||||
|
||||
session::~session()
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace libtorrent
|
|||
, std::string const& hostname
|
||||
, unsigned short port
|
||||
, boost::weak_ptr<request_callback> c
|
||||
, const http_settings& stn)
|
||||
, session_settings const& stn)
|
||||
: tracker_connection(man, req, d, c)
|
||||
, m_man(man)
|
||||
, m_name_lookup(d)
|
||||
|
|
|
@ -145,8 +145,8 @@ namespace libtorrent
|
|||
if (m_first_request)
|
||||
{
|
||||
request += "\r\nUser-Agent: ";
|
||||
request += escape_string(m_ses.m_http_settings.user_agent.c_str()
|
||||
, m_ses.m_http_settings.user_agent.size());
|
||||
request += escape_string(m_ses.m_settings.user_agent.c_str()
|
||||
, m_ses.m_settings.user_agent.size());
|
||||
}
|
||||
request += "\r\nRange: bytes=";
|
||||
request += boost::lexical_cast<std::string>(r.piece
|
||||
|
@ -180,8 +180,8 @@ namespace libtorrent
|
|||
if (m_first_request)
|
||||
{
|
||||
request += "\r\nUser-Agent: ";
|
||||
request += escape_string(m_ses.m_http_settings.user_agent.c_str()
|
||||
, m_ses.m_http_settings.user_agent.size());
|
||||
request += escape_string(m_ses.m_settings.user_agent.c_str()
|
||||
, m_ses.m_settings.user_agent.size());
|
||||
}
|
||||
request += "\r\nRange: bytes=";
|
||||
request += boost::lexical_cast<std::string>(f.offset);
|
||||
|
|
Loading…
Reference in New Issue