2003-10-23 01:00:57 +02:00
|
|
|
/*
|
|
|
|
|
2006-10-11 22:57:54 +02:00
|
|
|
Copyright (c) 2006, Arvid Norberg, Magnus Jonsson
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2007-03-17 18:15:16 +01:00
|
|
|
#include "libtorrent/pch.hpp"
|
|
|
|
|
2003-10-23 01:00:57 +02:00
|
|
|
#include <ctime>
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <iterator>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <set>
|
2003-10-25 03:31:06 +02:00
|
|
|
#include <cctype>
|
2003-10-27 16:43:33 +01:00
|
|
|
#include <algorithm>
|
2003-10-23 01:00:57 +02:00
|
|
|
|
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/lexical_cast.hpp>
|
|
|
|
#include <boost/filesystem/convenience.hpp>
|
2003-11-28 18:29:27 +01:00
|
|
|
#include <boost/filesystem/exception.hpp>
|
2003-12-15 18:46:47 +01:00
|
|
|
#include <boost/limits.hpp>
|
2004-01-17 21:04:19 +01:00
|
|
|
#include <boost/bind.hpp>
|
2003-10-23 01:00:57 +02:00
|
|
|
|
2004-01-25 19:18:36 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
|
|
|
|
2008-09-22 01:19:58 +02:00
|
|
|
#include "libtorrent/extensions/ut_pex.hpp"
|
|
|
|
#include "libtorrent/extensions/ut_metadata.hpp"
|
|
|
|
#include "libtorrent/extensions/smart_ban.hpp"
|
2003-10-23 01:00:57 +02:00
|
|
|
#include "libtorrent/peer_id.hpp"
|
|
|
|
#include "libtorrent/torrent_info.hpp"
|
2004-01-31 11:46:15 +01:00
|
|
|
#include "libtorrent/tracker_manager.hpp"
|
2003-10-23 01:00:57 +02:00
|
|
|
#include "libtorrent/bencode.hpp"
|
|
|
|
#include "libtorrent/hasher.hpp"
|
|
|
|
#include "libtorrent/entry.hpp"
|
|
|
|
#include "libtorrent/session.hpp"
|
2003-12-16 14:33:29 +01:00
|
|
|
#include "libtorrent/fingerprint.hpp"
|
2004-01-07 01:48:02 +01:00
|
|
|
#include "libtorrent/entry.hpp"
|
2004-01-18 20:12:18 +01:00
|
|
|
#include "libtorrent/alert_types.hpp"
|
2004-01-25 19:18:36 +01:00
|
|
|
#include "libtorrent/invariant_check.hpp"
|
2004-01-26 02:08:59 +01:00
|
|
|
#include "libtorrent/file.hpp"
|
2006-04-25 23:04:48 +02:00
|
|
|
#include "libtorrent/bt_peer_connection.hpp"
|
2005-07-06 02:58:23 +02:00
|
|
|
#include "libtorrent/ip_filter.hpp"
|
2006-04-25 23:04:48 +02:00
|
|
|
#include "libtorrent/socket.hpp"
|
2006-10-11 16:02:21 +02:00
|
|
|
#include "libtorrent/aux_/session_impl.hpp"
|
2006-08-01 17:27:08 +02:00
|
|
|
#include "libtorrent/kademlia/dht_tracker.hpp"
|
2003-10-23 01:00:57 +02:00
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
using boost::shared_ptr;
|
|
|
|
using boost::weak_ptr;
|
|
|
|
using boost::bind;
|
|
|
|
using boost::mutex;
|
2006-10-11 16:02:21 +02:00
|
|
|
using libtorrent::aux::session_impl;
|
2004-10-14 03:17:04 +02:00
|
|
|
|
2007-12-27 07:37:18 +01:00
|
|
|
#ifdef TORRENT_MEMDEBUG
|
|
|
|
void start_malloc_debug();
|
|
|
|
void stop_malloc_debug();
|
|
|
|
#endif
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
namespace libtorrent
|
|
|
|
{
|
|
|
|
|
2007-09-29 22:35:55 +02:00
|
|
|
std::string log_time()
|
|
|
|
{
|
|
|
|
static const ptime start = time_now();
|
|
|
|
char ret[200];
|
|
|
|
std::sprintf(ret, "%d", total_milliseconds(time_now() - start));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-12-31 00:02:21 +01:00
|
|
|
namespace aux
|
|
|
|
{
|
|
|
|
filesystem_init::filesystem_init()
|
|
|
|
{
|
2007-04-23 19:14:40 +02:00
|
|
|
#if BOOST_VERSION < 103400
|
2006-12-31 00:02:21 +01:00
|
|
|
using namespace boost::filesystem;
|
|
|
|
if (path::default_name_check_writable())
|
|
|
|
path::default_name_check(no_check);
|
2007-04-23 19:14:40 +02:00
|
|
|
#endif
|
2006-12-31 00:02:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
session::session(
|
|
|
|
fingerprint const& id
|
|
|
|
, std::pair<int, int> listen_port_range
|
2007-11-16 22:21:28 +01:00
|
|
|
, char const* listen_interface
|
2008-09-22 01:19:58 +02:00
|
|
|
, int flags
|
2008-02-17 23:51:03 +01:00
|
|
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
2007-11-16 22:21:28 +01:00
|
|
|
, fs::path logpath
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
: m_impl(new session_impl(listen_port_range, id, listen_interface
|
2008-02-17 23:51:03 +01:00
|
|
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
2007-11-16 22:21:28 +01:00
|
|
|
, logpath
|
|
|
|
#endif
|
2008-09-22 01:19:58 +02:00
|
|
|
))
|
2006-10-11 16:02:21 +02:00
|
|
|
{
|
2007-12-27 07:37:18 +01:00
|
|
|
#ifdef TORRENT_MEMDEBUG
|
|
|
|
start_malloc_debug();
|
|
|
|
#endif
|
2006-10-11 16:02:21 +02:00
|
|
|
// turn off the filename checking in boost.filesystem
|
2007-10-05 02:30:00 +02:00
|
|
|
TORRENT_ASSERT(listen_port_range.first > 0);
|
|
|
|
TORRENT_ASSERT(listen_port_range.first < listen_port_range.second);
|
2006-10-11 16:02:21 +02:00
|
|
|
#ifndef NDEBUG
|
|
|
|
// this test was added after it came to my attention
|
|
|
|
// that devstudios managed c++ failed to generate
|
|
|
|
// correct code for boost.function
|
|
|
|
boost::function0<void> test = boost::ref(*m_impl);
|
2007-10-05 02:30:00 +02:00
|
|
|
TORRENT_ASSERT(!test.empty());
|
2006-10-11 16:02:21 +02:00
|
|
|
#endif
|
2008-09-22 01:19:58 +02:00
|
|
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
|
|
if (flags & add_default_plugins)
|
|
|
|
{
|
|
|
|
add_extension(create_ut_pex_plugin);
|
|
|
|
add_extension(create_ut_metadata_plugin);
|
|
|
|
add_extension(create_smart_ban_plugin);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (flags & start_default_features)
|
|
|
|
{
|
|
|
|
start_upnp();
|
2008-10-24 10:11:17 +02:00
|
|
|
start_natpmp();
|
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
|
|
|
start_dht();
|
|
|
|
#endif
|
|
|
|
start_lsd();
|
2008-09-22 01:19:58 +02:00
|
|
|
}
|
2006-10-11 16:02:21 +02:00
|
|
|
}
|
|
|
|
|
2007-11-16 22:21:28 +01:00
|
|
|
session::session(fingerprint const& id
|
2008-09-22 01:19:58 +02:00
|
|
|
, int flags
|
2008-02-17 23:51:03 +01:00
|
|
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
2007-11-16 22:21:28 +01:00
|
|
|
, fs::path logpath
|
|
|
|
#endif
|
|
|
|
)
|
2008-02-17 23:51:03 +01:00
|
|
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
2007-11-16 22:21:28 +01:00
|
|
|
: m_impl(new session_impl(std::make_pair(0, 0), id, "0.0.0.0", logpath))
|
|
|
|
#else
|
|
|
|
: m_impl(new session_impl(std::make_pair(0, 0), id, "0.0.0.0"))
|
|
|
|
#endif
|
2006-10-11 16:02:21 +02:00
|
|
|
{
|
2007-12-27 07:37:18 +01:00
|
|
|
#ifdef TORRENT_MEMDEBUG
|
|
|
|
start_malloc_debug();
|
|
|
|
#endif
|
2006-10-11 16:02:21 +02:00
|
|
|
#ifndef NDEBUG
|
|
|
|
boost::function0<void> test = boost::ref(*m_impl);
|
2007-10-05 02:30:00 +02:00
|
|
|
TORRENT_ASSERT(!test.empty());
|
2006-10-11 16:02:21 +02:00
|
|
|
#endif
|
2008-09-22 01:19:58 +02:00
|
|
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
|
|
if (flags & add_default_plugins)
|
|
|
|
{
|
|
|
|
add_extension(create_ut_pex_plugin);
|
|
|
|
add_extension(create_ut_metadata_plugin);
|
|
|
|
add_extension(create_smart_ban_plugin);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (flags & start_default_features)
|
|
|
|
{
|
|
|
|
start_upnp();
|
|
|
|
start_natpmp();
|
2008-10-24 10:11:17 +02:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
|
|
|
start_dht();
|
|
|
|
#endif
|
|
|
|
start_lsd();
|
2008-09-22 01:19:58 +02:00
|
|
|
}
|
2006-10-11 16:02:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
session::~session()
|
|
|
|
{
|
2007-12-27 07:37:18 +01:00
|
|
|
#ifdef TORRENT_MEMDEBUG
|
|
|
|
stop_malloc_debug();
|
|
|
|
#endif
|
2007-10-05 02:30:00 +02:00
|
|
|
TORRENT_ASSERT(m_impl);
|
2006-10-11 16:02:21 +02:00
|
|
|
// if there is at least one destruction-proxy
|
|
|
|
// abort the session and let the destructor
|
|
|
|
// of the proxy to syncronize
|
|
|
|
if (!m_impl.unique())
|
|
|
|
m_impl->abort();
|
|
|
|
}
|
|
|
|
|
2008-09-22 01:19:58 +02:00
|
|
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
2007-09-14 02:11:33 +02:00
|
|
|
void session::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext)
|
2006-10-11 16:02:21 +02:00
|
|
|
{
|
2006-11-14 01:08:16 +01:00
|
|
|
m_impl->add_extension(ext);
|
2006-10-11 16:02:21 +02:00
|
|
|
}
|
2008-09-22 01:19:58 +02:00
|
|
|
#endif
|
2006-10-11 16:02:21 +02:00
|
|
|
|
2008-04-05 06:53:22 +02:00
|
|
|
#ifndef TORRENT_DISABLE_GEO_IP
|
|
|
|
bool session::load_asnum_db(char const* file)
|
|
|
|
{
|
|
|
|
return m_impl->load_asnum_db(file);
|
|
|
|
}
|
2008-04-11 10:46:43 +02:00
|
|
|
|
|
|
|
bool session::load_country_db(char const* file)
|
|
|
|
{
|
|
|
|
return m_impl->load_country_db(file);
|
|
|
|
}
|
2008-04-22 02:05:23 +02:00
|
|
|
|
|
|
|
int session::as_for_ip(address const& addr)
|
|
|
|
{
|
|
|
|
aux::session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
|
|
|
return m_impl->as_for_ip(addr);
|
|
|
|
}
|
|
|
|
|
2008-04-05 06:53:22 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void session::load_state(entry const& ses_state)
|
|
|
|
{
|
|
|
|
m_impl->load_state(ses_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
entry session::state() const
|
|
|
|
{
|
|
|
|
return m_impl->state();
|
|
|
|
}
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
void session::set_ip_filter(ip_filter const& f)
|
|
|
|
{
|
|
|
|
m_impl->set_ip_filter(f);
|
|
|
|
}
|
|
|
|
|
2007-06-01 03:05:57 +02:00
|
|
|
void session::set_port_filter(port_filter const& f)
|
|
|
|
{
|
|
|
|
m_impl->set_port_filter(f);
|
|
|
|
}
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
void session::set_peer_id(peer_id const& id)
|
|
|
|
{
|
|
|
|
m_impl->set_peer_id(id);
|
|
|
|
}
|
2007-06-09 01:02:31 +02:00
|
|
|
|
|
|
|
peer_id session::id() const
|
|
|
|
{
|
|
|
|
return m_impl->get_peer_id();
|
|
|
|
}
|
2006-10-11 16:02:21 +02:00
|
|
|
|
|
|
|
void session::set_key(int key)
|
|
|
|
{
|
|
|
|
m_impl->set_key(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<torrent_handle> session::get_torrents() const
|
|
|
|
{
|
|
|
|
return m_impl->get_torrents();
|
|
|
|
}
|
2006-11-14 01:08:16 +01:00
|
|
|
|
|
|
|
torrent_handle session::find_torrent(sha1_hash const& info_hash) const
|
|
|
|
{
|
|
|
|
return m_impl->find_torrent_handle(info_hash);
|
|
|
|
}
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
torrent_handle session::add_torrent(add_torrent_params const& params)
|
|
|
|
{
|
|
|
|
return m_impl->add_torrent(params);
|
|
|
|
}
|
2006-10-11 16:02:21 +02:00
|
|
|
|
2008-08-03 17:14:08 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2006-10-11 16:02:21 +02:00
|
|
|
// if the torrent already exists, this will throw duplicate_torrent
|
|
|
|
torrent_handle session::add_torrent(
|
|
|
|
torrent_info const& ti
|
2007-06-10 22:46:09 +02:00
|
|
|
, fs::path const& save_path
|
2006-10-11 16:02:21 +02:00
|
|
|
, entry const& resume_data
|
2007-10-08 22:01:36 +02:00
|
|
|
, storage_mode_t storage_mode
|
2007-08-22 07:31:42 +02:00
|
|
|
, bool paused
|
2007-03-16 06:29:23 +01:00
|
|
|
, storage_constructor_type sc)
|
2007-09-01 05:00:31 +02:00
|
|
|
{
|
|
|
|
boost::intrusive_ptr<torrent_info> tip(new torrent_info(ti));
|
2008-04-24 05:28:48 +02:00
|
|
|
add_torrent_params p(sc);
|
|
|
|
p.ti = tip;
|
|
|
|
p.save_path = save_path;
|
2008-07-01 01:14:31 +02:00
|
|
|
std::vector<char> buf;
|
|
|
|
if (resume_data.type() != entry::undefined_t)
|
|
|
|
{
|
|
|
|
bencode(std::back_inserter(buf), resume_data);
|
|
|
|
p.resume_data = &buf;
|
|
|
|
}
|
2008-04-24 05:28:48 +02:00
|
|
|
p.storage_mode = storage_mode;
|
|
|
|
p.paused = paused;
|
|
|
|
return m_impl->add_torrent(p);
|
2007-09-01 05:00:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
torrent_handle session::add_torrent(
|
|
|
|
boost::intrusive_ptr<torrent_info> ti
|
|
|
|
, fs::path const& save_path
|
|
|
|
, entry const& resume_data
|
2007-10-08 22:01:36 +02:00
|
|
|
, storage_mode_t storage_mode
|
2007-09-01 05:00:31 +02:00
|
|
|
, bool paused
|
2007-09-14 02:11:33 +02:00
|
|
|
, storage_constructor_type sc
|
|
|
|
, void* userdata)
|
2006-10-11 16:02:21 +02:00
|
|
|
{
|
2008-04-24 05:28:48 +02:00
|
|
|
add_torrent_params p(sc);
|
|
|
|
p.ti = ti;
|
|
|
|
p.save_path = save_path;
|
2008-07-01 01:14:31 +02:00
|
|
|
std::vector<char> buf;
|
|
|
|
if (resume_data.type() != entry::undefined_t)
|
|
|
|
{
|
|
|
|
bencode(std::back_inserter(buf), resume_data);
|
|
|
|
p.resume_data = &buf;
|
|
|
|
}
|
2008-04-24 05:28:48 +02:00
|
|
|
p.storage_mode = storage_mode;
|
|
|
|
p.paused = paused;
|
|
|
|
p.userdata = userdata;
|
|
|
|
return m_impl->add_torrent(p);
|
2006-10-11 16:02:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
torrent_handle session::add_torrent(
|
|
|
|
char const* tracker_url
|
|
|
|
, sha1_hash const& info_hash
|
2006-11-14 01:08:16 +01:00
|
|
|
, char const* name
|
2007-06-10 22:46:09 +02:00
|
|
|
, fs::path const& save_path
|
2006-10-11 16:02:21 +02:00
|
|
|
, entry const& e
|
2007-10-08 22:01:36 +02:00
|
|
|
, storage_mode_t storage_mode
|
2007-08-22 07:31:42 +02:00
|
|
|
, bool paused
|
2007-09-14 02:11:33 +02:00
|
|
|
, storage_constructor_type sc
|
|
|
|
, void* userdata)
|
2006-10-11 16:02:21 +02:00
|
|
|
{
|
2008-04-24 05:28:48 +02:00
|
|
|
add_torrent_params p(sc);
|
|
|
|
p.tracker_url = tracker_url;
|
|
|
|
p.info_hash = info_hash;
|
|
|
|
p.save_path = save_path;
|
|
|
|
p.paused = paused;
|
|
|
|
p.userdata = userdata;
|
|
|
|
return m_impl->add_torrent(p);
|
2006-10-11 16:02:21 +02:00
|
|
|
}
|
2008-08-03 17:14:08 +02:00
|
|
|
#endif
|
2006-10-11 16:02:21 +02:00
|
|
|
|
2007-10-13 05:33:33 +02:00
|
|
|
void session::remove_torrent(const torrent_handle& h, int options)
|
2006-10-11 16:02:21 +02:00
|
|
|
{
|
2007-10-13 05:33:33 +02:00
|
|
|
m_impl->remove_torrent(h, options);
|
2006-10-11 16:02:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool session::listen_on(
|
|
|
|
std::pair<int, int> const& port_range
|
|
|
|
, const char* net_interface)
|
|
|
|
{
|
|
|
|
return m_impl->listen_on(port_range, net_interface);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned short session::listen_port() const
|
|
|
|
{
|
|
|
|
return m_impl->listen_port();
|
|
|
|
}
|
|
|
|
|
|
|
|
session_status session::status() const
|
|
|
|
{
|
|
|
|
return m_impl->status();
|
|
|
|
}
|
|
|
|
|
2008-06-29 21:08:30 +02:00
|
|
|
void session::pause() { m_impl->pause(); }
|
|
|
|
void session::resume() { m_impl->resume(); }
|
|
|
|
bool session::is_paused() const { return m_impl->is_paused(); }
|
|
|
|
|
2008-02-08 11:22:05 +01:00
|
|
|
void session::get_cache_info(sha1_hash const& ih
|
|
|
|
, std::vector<cached_piece_info>& ret) const
|
|
|
|
{
|
|
|
|
m_impl->m_disk_thread.get_cache_info(ih, ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
cache_status session::get_cache_status() const
|
|
|
|
{
|
|
|
|
return m_impl->m_disk_thread.status();
|
|
|
|
}
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
|
|
|
|
|
|
|
void session::start_dht(entry const& startup_state)
|
|
|
|
{
|
|
|
|
m_impl->start_dht(startup_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::stop_dht()
|
|
|
|
{
|
|
|
|
m_impl->stop_dht();
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::set_dht_settings(dht_settings const& settings)
|
|
|
|
{
|
|
|
|
m_impl->set_dht_settings(settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
entry session::dht_state() const
|
|
|
|
{
|
|
|
|
return m_impl->dht_state();
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::add_dht_node(std::pair<std::string, int> const& node)
|
|
|
|
{
|
|
|
|
m_impl->add_dht_node(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::add_dht_router(std::pair<std::string, int> const& node)
|
|
|
|
{
|
|
|
|
m_impl->add_dht_router(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-06-06 02:41:20 +02:00
|
|
|
#ifndef TORRENT_DISABLE_ENCRYPTION
|
|
|
|
void session::set_pe_settings(pe_settings const& settings)
|
|
|
|
{
|
|
|
|
m_impl->set_pe_settings(settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
pe_settings const& session::get_pe_settings() const
|
|
|
|
{
|
|
|
|
return m_impl->get_pe_settings();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
bool session::is_listening() const
|
|
|
|
{
|
|
|
|
return m_impl->is_listening();
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::set_settings(session_settings const& s)
|
|
|
|
{
|
|
|
|
m_impl->set_settings(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
session_settings const& session::settings()
|
|
|
|
{
|
|
|
|
return m_impl->settings();
|
|
|
|
}
|
|
|
|
|
2007-04-25 20:26:35 +02:00
|
|
|
void session::set_peer_proxy(proxy_settings const& s)
|
|
|
|
{
|
|
|
|
m_impl->set_peer_proxy(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::set_web_seed_proxy(proxy_settings const& s)
|
|
|
|
{
|
|
|
|
m_impl->set_web_seed_proxy(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::set_tracker_proxy(proxy_settings const& s)
|
|
|
|
{
|
|
|
|
m_impl->set_tracker_proxy(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
proxy_settings const& session::peer_proxy() const
|
|
|
|
{
|
|
|
|
return m_impl->peer_proxy();
|
|
|
|
}
|
|
|
|
|
|
|
|
proxy_settings const& session::web_seed_proxy() const
|
|
|
|
{
|
|
|
|
return m_impl->web_seed_proxy();
|
|
|
|
}
|
|
|
|
|
|
|
|
proxy_settings const& session::tracker_proxy() const
|
|
|
|
{
|
|
|
|
return m_impl->tracker_proxy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef TORRENT_DISABLE_DHT
|
|
|
|
void session::set_dht_proxy(proxy_settings const& s)
|
|
|
|
{
|
|
|
|
m_impl->set_dht_proxy(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
proxy_settings const& session::dht_proxy() const
|
|
|
|
{
|
|
|
|
return m_impl->dht_proxy();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
void session::set_max_uploads(int limit)
|
|
|
|
{
|
|
|
|
m_impl->set_max_uploads(limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::set_max_connections(int limit)
|
|
|
|
{
|
|
|
|
m_impl->set_max_connections(limit);
|
|
|
|
}
|
|
|
|
|
2007-09-10 03:57:40 +02:00
|
|
|
int session::max_half_open_connections() const
|
|
|
|
{
|
|
|
|
return m_impl->max_half_open_connections();
|
|
|
|
}
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
void session::set_max_half_open_connections(int limit)
|
|
|
|
{
|
|
|
|
m_impl->set_max_half_open_connections(limit);
|
|
|
|
}
|
|
|
|
|
2007-01-02 00:51:24 +01:00
|
|
|
int session::upload_rate_limit() const
|
|
|
|
{
|
|
|
|
return m_impl->upload_rate_limit();
|
|
|
|
}
|
|
|
|
|
|
|
|
int session::download_rate_limit() const
|
|
|
|
{
|
|
|
|
return m_impl->download_rate_limit();
|
|
|
|
}
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
void session::set_upload_rate_limit(int bytes_per_second)
|
|
|
|
{
|
|
|
|
m_impl->set_upload_rate_limit(bytes_per_second);
|
2004-03-28 19:45:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void session::set_download_rate_limit(int bytes_per_second)
|
|
|
|
{
|
2006-10-11 16:02:21 +02:00
|
|
|
m_impl->set_download_rate_limit(bytes_per_second);
|
2003-11-09 19:17:09 +01:00
|
|
|
}
|
|
|
|
|
2007-01-01 22:04:30 +01:00
|
|
|
int session::num_uploads() const
|
|
|
|
{
|
|
|
|
return m_impl->num_uploads();
|
|
|
|
}
|
|
|
|
|
|
|
|
int session::num_connections() const
|
|
|
|
{
|
|
|
|
return m_impl->num_connections();
|
|
|
|
}
|
|
|
|
|
2003-11-29 17:34:07 +01:00
|
|
|
std::auto_ptr<alert> session::pop_alert()
|
|
|
|
{
|
2006-10-11 16:02:21 +02:00
|
|
|
return m_impl->pop_alert();
|
2003-11-29 17:34:07 +01:00
|
|
|
}
|
|
|
|
|
2007-11-25 09:18:57 +01:00
|
|
|
alert const* session::wait_for_alert(time_duration max_wait)
|
|
|
|
{
|
|
|
|
return m_impl->wait_for_alert(max_wait);
|
|
|
|
}
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
void session::set_alert_mask(int m)
|
|
|
|
{
|
|
|
|
m_impl->set_alert_mask(m);
|
|
|
|
}
|
|
|
|
|
2008-10-07 09:12:32 +02:00
|
|
|
size_t session::set_alert_queue_size_limit(size_t queue_size_limit_)
|
2008-10-07 07:46:42 +02:00
|
|
|
{
|
|
|
|
return m_impl->set_alert_queue_size_limit(queue_size_limit_);
|
|
|
|
}
|
|
|
|
|
2008-08-03 17:14:08 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2003-12-22 08:14:35 +01:00
|
|
|
void session::set_severity_level(alert::severity_t s)
|
2003-12-21 18:28:27 +01:00
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
int m = 0;
|
|
|
|
switch (s)
|
|
|
|
{
|
|
|
|
case alert::debug: m = alert::all_categories; break;
|
|
|
|
case alert::info: m = alert::all_categories & ~(alert::debug_notification
|
2008-10-22 03:12:14 +02:00
|
|
|
| alert::progress_notification | alert::dht_notification); break;
|
2008-07-06 14:22:56 +02:00
|
|
|
case alert::warning: m = alert::all_categories & ~(alert::debug_notification
|
2008-10-22 03:12:14 +02:00
|
|
|
| alert::status_notification | alert::progress_notification
|
|
|
|
| alert::dht_notification); break;
|
2008-07-06 14:22:56 +02:00
|
|
|
case alert::critical: m = alert::error_notification | alert::storage_notification; break;
|
|
|
|
case alert::fatal: m = alert::error_notification; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_impl->set_alert_mask(m);
|
2003-12-22 08:14:35 +01:00
|
|
|
}
|
2008-08-03 17:14:08 +02:00
|
|
|
#endif
|
2003-10-25 03:31:06 +02:00
|
|
|
|
2007-05-31 02:21:54 +02:00
|
|
|
void session::start_lsd()
|
|
|
|
{
|
|
|
|
m_impl->start_lsd();
|
|
|
|
}
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
natpmp* session::start_natpmp()
|
2007-05-31 02:21:54 +02:00
|
|
|
{
|
2008-04-06 21:17:58 +02:00
|
|
|
return m_impl->start_natpmp();
|
2007-05-31 02:21:54 +02:00
|
|
|
}
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
upnp* session::start_upnp()
|
2007-05-31 02:21:54 +02:00
|
|
|
{
|
2008-04-06 21:17:58 +02:00
|
|
|
return m_impl->start_upnp();
|
2007-05-31 02:21:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void session::stop_lsd()
|
|
|
|
{
|
|
|
|
m_impl->stop_lsd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::stop_natpmp()
|
|
|
|
{
|
|
|
|
m_impl->stop_natpmp();
|
|
|
|
}
|
|
|
|
|
|
|
|
void session::stop_upnp()
|
|
|
|
{
|
|
|
|
m_impl->stop_upnp();
|
|
|
|
}
|
|
|
|
|
2007-05-05 02:29:33 +02:00
|
|
|
connection_queue& session::get_connection_queue()
|
|
|
|
{
|
|
|
|
return m_impl->m_half_open;
|
|
|
|
}
|
2003-10-23 01:00:57 +02:00
|
|
|
}
|
2006-10-11 22:57:54 +02:00
|
|
|
|