2003-10-23 01:00:57 +02:00
|
|
|
/*
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
Copyright (c) 2006, Arvid Norberg
|
2003-10-23 01:00:57 +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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2003-10-26 18:35:23 +01:00
|
|
|
#ifndef TORRENT_SESSION_HPP_INCLUDED
|
2003-10-23 01:00:57 +02:00
|
|
|
#define TORRENT_SESSION_HPP_INCLUDED
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
|
|
|
|
2004-01-25 19:18:36 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(push, 1)
|
|
|
|
#endif
|
|
|
|
|
2003-10-23 01:00:57 +02:00
|
|
|
#include <boost/limits.hpp>
|
|
|
|
|
2004-01-25 19:18:36 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
|
|
|
|
2007-08-14 19:47:48 +02:00
|
|
|
#include "libtorrent/config.hpp"
|
2003-10-26 18:35:23 +01:00
|
|
|
#include "libtorrent/torrent_handle.hpp"
|
2003-10-23 01:00:57 +02:00
|
|
|
#include "libtorrent/entry.hpp"
|
2006-09-05 01:22:21 +02:00
|
|
|
#include "libtorrent/session_status.hpp"
|
2006-10-11 16:02:21 +02:00
|
|
|
#include "libtorrent/version.hpp"
|
|
|
|
#include "libtorrent/fingerprint.hpp"
|
2008-02-08 11:22:05 +01:00
|
|
|
#include "libtorrent/disk_io_thread.hpp"
|
2008-04-24 05:28:48 +02:00
|
|
|
#include "libtorrent/peer_id.hpp"
|
2009-11-26 06:45:43 +01:00
|
|
|
#include "libtorrent/alert.hpp" // alert::error_notification
|
|
|
|
#include "libtorrent/add_torrent_params.hpp"
|
2011-01-18 04:41:54 +01:00
|
|
|
#include "libtorrent/rss.hpp"
|
2006-10-11 16:02:21 +02:00
|
|
|
|
2007-03-16 06:29:23 +01:00
|
|
|
#include "libtorrent/storage.hpp"
|
2009-05-03 22:21:24 +02:00
|
|
|
|
2007-02-21 18:15:47 +01:00
|
|
|
#ifdef _MSC_VER
|
2004-01-02 21:46:24 +01:00
|
|
|
# include <eh.h>
|
2004-01-02 00:23:17 +01:00
|
|
|
#endif
|
2003-10-23 01:00:57 +02:00
|
|
|
|
|
|
|
namespace libtorrent
|
|
|
|
{
|
2011-01-29 11:37:21 +01:00
|
|
|
struct plugin;
|
2006-11-14 01:08:16 +01:00
|
|
|
struct torrent_plugin;
|
2005-10-13 09:59:05 +02:00
|
|
|
class torrent;
|
2010-08-29 00:05:20 +02:00
|
|
|
struct ip_filter;
|
2007-06-01 03:05:57 +02:00
|
|
|
class port_filter;
|
2007-05-05 02:29:33 +02:00
|
|
|
class connection_queue;
|
2008-04-07 01:18:35 +02:00
|
|
|
class natpmp;
|
|
|
|
class upnp;
|
2009-05-03 22:21:24 +02:00
|
|
|
class alert;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
2009-05-12 20:05:04 +02:00
|
|
|
session_settings min_memory_usage();
|
|
|
|
session_settings high_performance_seed();
|
|
|
|
|
2010-10-24 02:44:07 +02:00
|
|
|
void TORRENT_EXPORT TORRENT_CFG();
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
namespace aux
|
2003-10-23 01:00:57 +02:00
|
|
|
{
|
2003-11-05 18:42:27 +01:00
|
|
|
// workaround for microsofts
|
|
|
|
// hardware exceptions that makes
|
|
|
|
// it hard to debug stuff
|
2007-02-21 18:15:47 +01:00
|
|
|
#ifdef _MSC_VER
|
2011-02-21 06:24:41 +01:00
|
|
|
struct TORRENT_EXPORT eh_initializer
|
2003-11-05 18:42:27 +01:00
|
|
|
{
|
2011-02-21 06:24:41 +01:00
|
|
|
eh_initializer();
|
2004-01-02 00:23:17 +01:00
|
|
|
static void straight_to_debugger(unsigned int, _EXCEPTION_POINTERS*)
|
2003-11-05 18:42:27 +01:00
|
|
|
{ throw; }
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
struct eh_initializer {};
|
|
|
|
#endif
|
2006-10-11 16:02:21 +02:00
|
|
|
struct session_impl;
|
2003-10-23 01:00:57 +02:00
|
|
|
}
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
class TORRENT_EXPORT session_proxy
|
|
|
|
{
|
|
|
|
friend class session;
|
2006-10-15 15:46:52 +02:00
|
|
|
public:
|
|
|
|
session_proxy() {}
|
2006-10-11 16:02:21 +02:00
|
|
|
private:
|
|
|
|
session_proxy(boost::shared_ptr<aux::session_impl> impl)
|
|
|
|
: m_impl(impl) {}
|
|
|
|
boost::shared_ptr<aux::session_impl> m_impl;
|
|
|
|
};
|
2007-10-08 22:01:36 +02:00
|
|
|
|
2010-10-24 02:44:07 +02:00
|
|
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
|
|
#define TORRENT_LOGPATH_ARG_DEFAULT , std::string logpath = "."
|
|
|
|
#define TORRENT_LOGPATH_ARG , std::string logpath
|
|
|
|
#define TORRENT_LOGPATH , logpath
|
|
|
|
#else
|
|
|
|
#define TORRENT_LOGPATH_ARG_DEFAULT
|
|
|
|
#define TORRENT_LOGPATH_ARG
|
|
|
|
#define TORRENT_LOGPATH
|
|
|
|
#endif
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
class TORRENT_EXPORT session: public boost::noncopyable, aux::eh_initializer
|
2003-10-23 01:00:57 +02:00
|
|
|
{
|
|
|
|
public:
|
2003-10-25 03:31:06 +02:00
|
|
|
|
2006-07-26 12:21:25 +02:00
|
|
|
session(fingerprint const& print = fingerprint("LT"
|
2007-11-16 22:21:28 +01:00
|
|
|
, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
|
2008-09-22 01:19:58 +02:00
|
|
|
, int flags = start_default_features | add_default_plugins
|
2008-11-16 03:09:53 +01:00
|
|
|
, int alert_mask = alert::error_notification
|
2010-10-24 02:44:07 +02:00
|
|
|
TORRENT_LOGPATH_ARG_DEFAULT)
|
|
|
|
{
|
|
|
|
TORRENT_CFG();
|
|
|
|
init(std::make_pair(0, 0), "0.0.0.0", print, flags, alert_mask TORRENT_LOGPATH);
|
|
|
|
}
|
|
|
|
|
2004-02-26 01:27:06 +01:00
|
|
|
session(
|
2004-03-29 00:44:40 +02:00
|
|
|
fingerprint const& print
|
|
|
|
, std::pair<int, int> listen_port_range
|
2007-11-16 22:21:28 +01:00
|
|
|
, char const* listen_interface = "0.0.0.0"
|
2008-09-22 01:19:58 +02:00
|
|
|
, int flags = start_default_features | add_default_plugins
|
2008-11-16 03:09:53 +01:00
|
|
|
, int alert_mask = alert::error_notification
|
2010-10-24 02:44:07 +02:00
|
|
|
TORRENT_LOGPATH_ARG_DEFAULT)
|
|
|
|
{
|
|
|
|
TORRENT_CFG();
|
|
|
|
TORRENT_ASSERT(listen_port_range.first > 0);
|
|
|
|
TORRENT_ASSERT(listen_port_range.first < listen_port_range.second);
|
|
|
|
init(listen_port_range, listen_interface, print, flags, alert_mask TORRENT_LOGPATH);
|
|
|
|
}
|
2006-10-11 16:02:21 +02:00
|
|
|
|
2003-10-23 01:00:57 +02:00
|
|
|
~session();
|
|
|
|
|
2010-03-06 08:49:40 +01:00
|
|
|
enum save_state_flags_t
|
|
|
|
{
|
2010-08-23 08:27:18 +02:00
|
|
|
save_settings = 0x001,
|
2010-03-06 08:49:40 +01:00
|
|
|
save_dht_settings = 0x002,
|
2010-08-23 08:27:18 +02:00
|
|
|
save_dht_state = 0x004,
|
|
|
|
save_proxy = 0x008,
|
|
|
|
save_i2p_proxy = 0x010,
|
2010-03-06 08:49:40 +01:00
|
|
|
save_encryption_settings = 0x020,
|
2011-01-18 04:41:54 +01:00
|
|
|
save_as_map = 0x040,
|
|
|
|
save_feeds = 0x080
|
2010-08-23 08:27:18 +02:00
|
|
|
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2010-11-28 01:26:33 +01:00
|
|
|
,
|
2010-08-23 08:27:18 +02:00
|
|
|
save_dht_proxy = save_proxy,
|
|
|
|
save_peer_proxy = save_proxy,
|
|
|
|
save_web_proxy = save_proxy,
|
|
|
|
save_tracker_proxy = save_proxy
|
|
|
|
#endif
|
2010-03-06 08:49:40 +01:00
|
|
|
};
|
|
|
|
void save_state(entry& e, boost::uint32_t flags = 0xffffffff) const;
|
2009-12-03 06:11:57 +01:00
|
|
|
void load_state(lazy_entry const& e);
|
|
|
|
|
2011-02-01 10:48:28 +01:00
|
|
|
void get_torrent_status(std::vector<torrent_status>* ret
|
|
|
|
, boost::function<bool(torrent_status const&)> const& pred
|
|
|
|
, boost::uint32_t flags = 0) const;
|
|
|
|
void refresh_torrent_status(std::vector<torrent_status>* ret
|
|
|
|
, boost::uint32_t flags = 0) const;
|
|
|
|
|
2006-11-14 01:08:16 +01:00
|
|
|
// returns a list of all torrents in this session
|
2006-10-11 16:02:21 +02:00
|
|
|
std::vector<torrent_handle> get_torrents() const;
|
2006-11-14 01:08:16 +01:00
|
|
|
|
2009-03-17 10:34:44 +01:00
|
|
|
io_service& get_io_service();
|
|
|
|
|
2006-11-14 01:08:16 +01:00
|
|
|
// returns an invalid handle in case the torrent doesn't exist
|
|
|
|
torrent_handle find_torrent(sha1_hash const& info_hash) const;
|
2004-11-18 23:33:50 +01:00
|
|
|
|
2003-10-23 01:00:57 +02:00
|
|
|
// all torrent_handles must be destructed before the session is destructed!
|
2009-12-15 14:11:07 +01:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2008-04-24 05:28:48 +02:00
|
|
|
torrent_handle add_torrent(add_torrent_params const& params);
|
2009-12-15 14:11:07 +01:00
|
|
|
#endif
|
2009-02-23 02:21:19 +01:00
|
|
|
torrent_handle add_torrent(add_torrent_params const& params, error_code& ec);
|
2008-04-24 05:28:48 +02:00
|
|
|
|
2009-12-16 11:47:31 +01:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2008-08-03 17:14:08 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2008-04-24 05:28:48 +02:00
|
|
|
// deprecated in 0.14
|
2009-07-26 04:37:31 +02:00
|
|
|
TORRENT_DEPRECATED_PREFIX
|
2004-01-02 21:46:24 +01:00
|
|
|
torrent_handle add_torrent(
|
2005-10-16 18:58:41 +02:00
|
|
|
torrent_info const& ti
|
2009-10-26 02:29:39 +01:00
|
|
|
, std::string const& save_path
|
2005-05-13 02:39:39 +02:00
|
|
|
, entry const& resume_data = entry()
|
2007-10-08 22:01:36 +02:00
|
|
|
, storage_mode_t storage_mode = storage_mode_sparse
|
2007-08-22 07:31:42 +02:00
|
|
|
, bool paused = false
|
2007-09-01 05:00:31 +02:00
|
|
|
, storage_constructor_type sc = default_storage_constructor) TORRENT_DEPRECATED;
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
// deprecated in 0.14
|
2009-07-26 04:37:31 +02:00
|
|
|
TORRENT_DEPRECATED_PREFIX
|
2007-09-01 05:00:31 +02:00
|
|
|
torrent_handle add_torrent(
|
|
|
|
boost::intrusive_ptr<torrent_info> ti
|
2009-10-26 02:29:39 +01:00
|
|
|
, std::string const& save_path
|
2007-09-01 05:00:31 +02:00
|
|
|
, entry const& resume_data = entry()
|
2007-10-08 22:01:36 +02:00
|
|
|
, storage_mode_t storage_mode = storage_mode_sparse
|
2007-09-01 05:00:31 +02:00
|
|
|
, bool paused = false
|
2007-09-14 02:11:33 +02:00
|
|
|
, storage_constructor_type sc = default_storage_constructor
|
2008-04-24 05:28:48 +02:00
|
|
|
, void* userdata = 0) TORRENT_DEPRECATED;
|
2004-06-14 01:30:42 +02:00
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
// deprecated in 0.14
|
2009-07-26 04:37:31 +02:00
|
|
|
TORRENT_DEPRECATED_PREFIX
|
2004-06-14 01:30:42 +02:00
|
|
|
torrent_handle add_torrent(
|
|
|
|
char const* tracker_url
|
|
|
|
, sha1_hash const& info_hash
|
2006-11-14 01:08:16 +01:00
|
|
|
, char const* name
|
2009-10-26 02:29:39 +01:00
|
|
|
, std::string const& save_path
|
2005-05-13 02:39:39 +02:00
|
|
|
, entry const& resume_data = entry()
|
2007-10-08 22:01:36 +02:00
|
|
|
, storage_mode_t storage_mode = storage_mode_sparse
|
2007-08-22 07:37:49 +02:00
|
|
|
, bool paused = false
|
2007-09-14 02:11:33 +02:00
|
|
|
, storage_constructor_type sc = default_storage_constructor
|
2008-04-24 05:28:48 +02:00
|
|
|
, void* userdata = 0) TORRENT_DEPRECATED;
|
2009-12-16 11:47:31 +01:00
|
|
|
#endif
|
2008-08-03 17:14:08 +02:00
|
|
|
#endif
|
2004-01-02 21:46:24 +01:00
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
session_proxy abort() { return session_proxy(m_impl); }
|
|
|
|
|
2008-06-29 21:08:30 +02:00
|
|
|
void pause();
|
|
|
|
void resume();
|
|
|
|
bool is_paused() const;
|
|
|
|
|
2004-04-18 14:28:02 +02:00
|
|
|
session_status status() const;
|
2008-02-08 11:22:05 +01:00
|
|
|
cache_status get_cache_status() const;
|
|
|
|
|
|
|
|
void get_cache_info(sha1_hash const& ih
|
|
|
|
, std::vector<cached_piece_info>& ret) const;
|
2004-04-18 14:28:02 +02:00
|
|
|
|
2011-01-18 04:41:54 +01:00
|
|
|
feed_handle add_feed(feed_settings const& feed);
|
|
|
|
void remove_feed(feed_handle h);
|
|
|
|
void get_feeds(std::vector<feed_handle>& f) const;
|
|
|
|
|
2006-08-01 17:27:08 +02:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
2010-03-04 17:42:39 +01:00
|
|
|
void start_dht();
|
2006-08-01 17:27:08 +02:00
|
|
|
void stop_dht();
|
|
|
|
void set_dht_settings(dht_settings const& settings);
|
2010-03-04 17:42:39 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
// deprecated in 0.15
|
|
|
|
// use save_state and load_state instead
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
entry dht_state() const TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void start_dht(entry const& startup_state) TORRENT_DEPRECATED;
|
|
|
|
#endif
|
2006-08-01 17:27:08 +02:00
|
|
|
void add_dht_node(std::pair<std::string, int> const& node);
|
2006-09-27 19:20:18 +02:00
|
|
|
void add_dht_router(std::pair<std::string, int> const& node);
|
2009-10-24 23:55:16 +02:00
|
|
|
bool is_dht_running() const;
|
2006-08-01 17:27:08 +02:00
|
|
|
#endif
|
|
|
|
|
2007-06-06 02:41:20 +02:00
|
|
|
#ifndef TORRENT_DISABLE_ENCRYPTION
|
|
|
|
void set_pe_settings(pe_settings const& settings);
|
2010-07-14 06:16:38 +02:00
|
|
|
pe_settings get_pe_settings() const;
|
2007-06-06 02:41:20 +02:00
|
|
|
#endif
|
|
|
|
|
2006-11-14 01:08:16 +01:00
|
|
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
2007-09-14 02:11:33 +02:00
|
|
|
void add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext);
|
2011-01-29 11:37:21 +01:00
|
|
|
void add_extension(boost::shared_ptr<plugin> ext);
|
2006-11-14 01:08:16 +01:00
|
|
|
#endif
|
2004-11-01 00:16:08 +01:00
|
|
|
|
2008-04-05 06:53:22 +02:00
|
|
|
#ifndef TORRENT_DISABLE_GEO_IP
|
2008-04-22 02:05:23 +02:00
|
|
|
int as_for_ip(address const& addr);
|
2010-07-14 06:16:38 +02:00
|
|
|
void load_asnum_db(char const* file);
|
|
|
|
void load_country_db(char const* file);
|
2009-10-29 19:12:43 +01:00
|
|
|
#if TORRENT_USE_WSTRING
|
2010-07-14 06:16:38 +02:00
|
|
|
void load_country_db(wchar_t const* file);
|
|
|
|
void load_asnum_db(wchar_t const* file);
|
2009-03-31 10:12:35 +02:00
|
|
|
#endif
|
2008-04-05 06:53:22 +02:00
|
|
|
#endif
|
|
|
|
|
2010-03-04 17:42:39 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
// deprecated in 0.15
|
|
|
|
// use load_state and save_state instead
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void load_state(entry const& ses_state) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
entry state() const TORRENT_DEPRECATED;
|
|
|
|
#endif
|
2008-04-05 06:53:22 +02:00
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
void set_ip_filter(ip_filter const& f);
|
2010-07-14 06:16:38 +02:00
|
|
|
ip_filter get_ip_filter() const;
|
2009-07-21 03:52:37 +02:00
|
|
|
|
2007-06-01 03:05:57 +02:00
|
|
|
void set_port_filter(port_filter const& f);
|
2006-04-25 23:04:48 +02:00
|
|
|
void set_peer_id(peer_id const& pid);
|
2005-01-08 22:12:19 +01:00
|
|
|
void set_key(int key);
|
2007-06-09 01:02:31 +02:00
|
|
|
peer_id id() const;
|
2004-12-21 13:30:09 +01:00
|
|
|
|
2004-02-26 13:59:01 +01:00
|
|
|
bool is_listening() const;
|
|
|
|
|
|
|
|
// if the listen port failed in some way
|
|
|
|
// you can retry to listen on another port-
|
|
|
|
// range with this function. If the listener
|
|
|
|
// succeeded and is currently listening,
|
|
|
|
// a call to this function will shut down the
|
|
|
|
// listen port and reopen it using these new
|
|
|
|
// properties (the given interface and port range).
|
|
|
|
// As usual, if the interface is left as 0
|
|
|
|
// this function will return false on failure.
|
|
|
|
// If it fails, it will also generate alerts describing
|
|
|
|
// the error. It will return true on success.
|
2011-02-16 07:35:53 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
listen_reuse_address = 0x01,
|
|
|
|
listen_no_system_port = 0x02
|
|
|
|
};
|
2010-06-17 19:14:56 +02:00
|
|
|
|
2011-02-16 07:35:53 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
// deprecated in 0.16
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
2004-02-26 13:59:01 +01:00
|
|
|
bool listen_on(
|
|
|
|
std::pair<int, int> const& port_range
|
2010-06-17 19:14:56 +02:00
|
|
|
, const char* net_interface = 0
|
2011-02-16 07:35:53 +01:00
|
|
|
, int flags = 0) TORRENT_DEPRECATED;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void listen_on(
|
|
|
|
std::pair<int, int> const& port_range
|
|
|
|
, error_code& ec
|
|
|
|
, const char* net_interface = 0
|
2010-06-17 19:14:56 +02:00
|
|
|
, int flags = 0);
|
2004-02-26 13:59:01 +01:00
|
|
|
|
|
|
|
// returns the port we ended up listening on
|
|
|
|
unsigned short listen_port() const;
|
2004-02-18 01:08:20 +01:00
|
|
|
|
2007-10-13 05:33:33 +02:00
|
|
|
enum options_t
|
|
|
|
{
|
|
|
|
none = 0,
|
|
|
|
delete_files = 1
|
|
|
|
};
|
|
|
|
|
2008-09-22 01:19:58 +02:00
|
|
|
enum session_flags_t
|
|
|
|
{
|
|
|
|
add_default_plugins = 1,
|
|
|
|
start_default_features = 2
|
|
|
|
};
|
|
|
|
|
2007-10-13 05:33:33 +02:00
|
|
|
void remove_torrent(const torrent_handle& h, int options = none);
|
2003-10-23 01:00:57 +02:00
|
|
|
|
2006-05-21 01:24:19 +02:00
|
|
|
void set_settings(session_settings const& s);
|
2010-12-26 09:03:02 +01:00
|
|
|
session_settings settings() const;
|
2007-01-01 22:04:30 +01:00
|
|
|
|
2010-08-23 08:27:18 +02:00
|
|
|
void set_proxy(proxy_settings const& s);
|
|
|
|
proxy_settings proxy() const;
|
|
|
|
|
2011-04-06 08:27:42 +02:00
|
|
|
#ifdef TORRENT_STATS
|
|
|
|
void enable_stats_logging(bool s);
|
|
|
|
#endif
|
|
|
|
|
2010-08-23 08:27:18 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2010-10-26 01:11:58 +02:00
|
|
|
// deprecated in 0.16
|
|
|
|
// Get the number of uploads.
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
int num_uploads() const TORRENT_DEPRECATED;
|
|
|
|
|
|
|
|
// Get the number of connections. This number also contains the
|
|
|
|
// number of half open connections.
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
int num_connections() const TORRENT_DEPRECATED;
|
|
|
|
|
2010-10-07 08:02:35 +02:00
|
|
|
// deprecated in 0.15.
|
2010-08-23 08:27:18 +02:00
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_peer_proxy(proxy_settings const& s) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_web_seed_proxy(proxy_settings const& s) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_tracker_proxy(proxy_settings const& s) TORRENT_DEPRECATED;
|
2007-04-25 20:26:35 +02:00
|
|
|
|
2010-08-23 08:27:18 +02:00
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
proxy_settings peer_proxy() const TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
proxy_settings web_seed_proxy() const TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
proxy_settings tracker_proxy() const TORRENT_DEPRECATED;
|
2007-04-25 20:26:35 +02:00
|
|
|
|
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
2010-08-23 08:27:18 +02:00
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_dht_proxy(proxy_settings const& s) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
proxy_settings dht_proxy() const TORRENT_DEPRECATED;
|
|
|
|
#endif
|
2010-10-07 08:02:35 +02:00
|
|
|
#endif // TORRENT_NO_DEPRECATE
|
2007-04-25 20:26:35 +02:00
|
|
|
|
2009-08-20 05:19:12 +02:00
|
|
|
#if TORRENT_USE_I2P
|
|
|
|
void set_i2p_proxy(proxy_settings const& s);
|
2010-07-14 06:16:38 +02:00
|
|
|
proxy_settings i2p_proxy() const;
|
2009-08-20 05:19:12 +02:00
|
|
|
#endif
|
|
|
|
|
2010-10-09 21:09:38 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
// deprecated in 0.16
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
int upload_rate_limit() const TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
int download_rate_limit() const TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
int local_upload_rate_limit() const TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
int local_download_rate_limit() const TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
int max_half_open_connections() const TORRENT_DEPRECATED;
|
|
|
|
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_local_upload_rate_limit(int bytes_per_second) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_local_download_rate_limit(int bytes_per_second) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_upload_rate_limit(int bytes_per_second) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_download_rate_limit(int bytes_per_second) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_max_uploads(int limit) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_max_connections(int limit) TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
void set_max_half_open_connections(int limit) TORRENT_DEPRECATED;
|
|
|
|
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
int max_connections() const TORRENT_DEPRECATED;
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
int max_uploads() const TORRENT_DEPRECATED;
|
|
|
|
#endif
|
2008-11-08 08:40:55 +01:00
|
|
|
|
2011-03-14 03:59:46 +01:00
|
|
|
// pop one alert from the alert queue, or do nothing
|
|
|
|
// and return a NULL pointer if there are no alerts
|
|
|
|
// in the queue
|
2003-11-29 17:34:07 +01:00
|
|
|
std::auto_ptr<alert> pop_alert();
|
2011-03-14 03:59:46 +01:00
|
|
|
|
|
|
|
// pop all alerts in the alert queue and returns them
|
|
|
|
// in the supplied dequeue 'alerts'. The passed in
|
|
|
|
// queue must be empty when passed in.
|
|
|
|
// the responsibility of individual alerts returned
|
|
|
|
// in the dequeue is passed on to the caller of this function.
|
|
|
|
// when you're done with reacting to the alerts, you need to
|
|
|
|
// delete them all.
|
|
|
|
void pop_alerts(std::deque<alert*>* alerts);
|
|
|
|
|
2008-08-03 17:14:08 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2009-07-26 04:37:31 +02:00
|
|
|
TORRENT_DEPRECATED_PREFIX
|
2008-07-06 14:22:56 +02:00
|
|
|
void set_severity_level(alert::severity_t s) TORRENT_DEPRECATED;
|
2011-01-23 19:00:52 +01:00
|
|
|
|
|
|
|
TORRENT_DEPRECATED_PREFIX
|
|
|
|
size_t set_alert_queue_size_limit(size_t queue_size_limit_) TORRENT_DEPRECATED;
|
2008-08-03 17:14:08 +02:00
|
|
|
#endif
|
2008-07-06 14:22:56 +02:00
|
|
|
void set_alert_mask(int m);
|
2003-11-29 17:34:07 +01:00
|
|
|
|
2007-11-25 09:18:57 +01:00
|
|
|
alert const* wait_for_alert(time_duration max_wait);
|
2010-07-14 06:16:38 +02:00
|
|
|
void set_alert_dispatch(boost::function<void(std::auto_ptr<alert>)> const& fun);
|
2007-11-25 09:18:57 +01:00
|
|
|
|
2007-05-05 02:29:33 +02:00
|
|
|
connection_queue& get_connection_queue();
|
|
|
|
|
2007-05-31 02:21:54 +02:00
|
|
|
// starts/stops UPnP, NATPMP or LSD port mappers
|
|
|
|
// they are stopped by default
|
|
|
|
void start_lsd();
|
2008-04-07 01:18:35 +02:00
|
|
|
natpmp* start_natpmp();
|
|
|
|
upnp* start_upnp();
|
2007-05-31 02:21:54 +02:00
|
|
|
|
|
|
|
void stop_lsd();
|
|
|
|
void stop_natpmp();
|
|
|
|
void stop_upnp();
|
|
|
|
|
2003-10-23 01:00:57 +02:00
|
|
|
private:
|
|
|
|
|
2010-10-24 02:44:07 +02:00
|
|
|
void init(std::pair<int, int> listen_range, char const* listen_interface
|
|
|
|
, fingerprint const& id, int flags, int alert_mask TORRENT_LOGPATH_ARG);
|
|
|
|
|
2003-10-31 05:02:51 +01:00
|
|
|
// data shared between the main thread
|
|
|
|
// and the working thread
|
2006-10-11 16:02:21 +02:00
|
|
|
boost::shared_ptr<aux::session_impl> m_impl;
|
2003-10-23 01:00:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TORRENT_SESSION_HPP_INCLUDED
|
2005-11-01 19:30:39 +01:00
|
|
|
|