merged RC_1_1 into master

This commit is contained in:
arvidn 2017-12-13 11:22:53 +01:00
commit 7b06a5ee6e
22 changed files with 99 additions and 75 deletions

View File

@ -81,6 +81,7 @@
* resume data no longer has timestamps of files
* require C++11 to build libtorrent
* fix i2p support
* fix loading resume data when in seed mode
* fix part-file creation race condition
* fix issue with initializing settings on session construction

View File

@ -83,7 +83,7 @@ libtorrent
.. _`HTTP seed`: http://www.getright.com/seedtorrent.html
.. _multitracker: http://bittorrent.org/beps/bep_0012.html
.. _mailing list: http://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
.. _archive: http://dir.gmane.org/gmane.network.bit-torrent.libtorrent
.. _archive: https://sourceforge.net/p/libtorrent/mailman/libtorrent-discuss/
.. _`who's using libtorrent?`: projects.html
.. _`report bugs`: https://github.com/arvidn/libtorrent/issues
.. _`github page`: https://github.com/arvidn/libtorrent

View File

@ -51,7 +51,7 @@
<td><a href="dht_sec.html">DHT security extension</a></td>
</tr>
<tr>
<td><a href="http://dir.gmane.org/gmane.network.bit-torrent.libtorrent">mailing list archive</a></td>
<td><a href="https://sourceforge.net/p/libtorrent/mailman/libtorrent-discuss/">mailing list archive</a></td>
<td><a href="contributing.html">contributing</a></td>
<td><a href="streaming.html">streaming</a></td>
</tr>

View File

@ -62,7 +62,7 @@
<td><a href="dht_sec.html">DHT security extension</a></td>
</tr>
<tr>
<td><a href="http://dir.gmane.org/gmane.network.bit-torrent.libtorrent">mailing list archive</a></td>
<td><a href="https://sourceforge.net/p/libtorrent/mailman/libtorrent-discuss/">mailing list archive</a></td>
<td><a href="contributing.html">contributing</a></td>
<td><a href="streaming.html">streaming</a></td>
</tr>

View File

@ -73,9 +73,9 @@ void session_view::render()
float seconds = (m_timestamp[0] - m_timestamp[1]) / 1000000.f;
int download_rate = int((m_cnt[0][m_recv_payload_idx] - m_cnt[1][m_recv_payload_idx])
int download_rate = int((m_cnt[0][m_recv_idx] - m_cnt[1][m_recv_idx])
/ seconds);
int upload_rate = int((m_cnt[0][m_sent_payload_idx] - m_cnt[1][m_sent_payload_idx])
int upload_rate = int((m_cnt[0][m_sent_idx] - m_cnt[1][m_sent_idx])
/ seconds);
pos += std::snprintf(str, sizeof(str), "%s%s fail: %s down: %s (%s) "
@ -85,7 +85,7 @@ void session_view::render()
, esc("1")
, add_suffix(m_cnt[0][m_failed_bytes_idx]).c_str()
, color(add_suffix(download_rate, "/s"), col_green).c_str()
, color(add_suffix(m_cnt[0][m_recv_payload_idx]), col_green).c_str()
, color(add_suffix(m_cnt[0][m_recv_idx]), col_green).c_str()
, color(to_string(int(m_cnt[0][m_limiter_up_queue_idx]), 3), col_red).c_str()
, color(to_string(int(m_cnt[0][m_limiter_down_queue_idx]), 3), col_green).c_str()
, int(m_cnt[0][m_num_peers_idx])
@ -107,7 +107,7 @@ void session_view::render()
, esc("1")
, add_suffix(m_cnt[0][m_wasted_bytes_idx]).c_str()
, color(add_suffix(upload_rate, "/s"), col_red).c_str()
, color(add_suffix(m_cnt[0][m_sent_payload_idx]), col_red).c_str()
, color(add_suffix(m_cnt[0][m_sent_idx]), col_red).c_str()
, color(to_string(int(m_cnt[0][m_queued_reads_idx]), 3), col_red).c_str()
, color(to_string(int(m_cnt[0][m_queued_writes_idx]), 3), col_green).c_str()
, int((m_cnt[0][m_blocks_written_idx] - m_cnt[0][m_write_ops_idx]) * 100

View File

@ -75,8 +75,8 @@ private:
int const m_wasted_bytes_idx = lt::find_metric_idx("net.recv_redundant_bytes");
int const m_failed_bytes_idx = lt::find_metric_idx("net.recv_failed_bytes");
int const m_num_peers_idx = lt::find_metric_idx("peer.num_peers_connected");
int const m_recv_payload_idx = lt::find_metric_idx("net.recv_payload_bytes");
int const m_sent_payload_idx = lt::find_metric_idx("net.sent_payload_bytes");
int const m_recv_idx = lt::find_metric_idx("net.recv_bytes");
int const m_sent_idx = lt::find_metric_idx("net.sent_bytes");
int const m_unchoked_idx = lt::find_metric_idx("peer.num_peers_up_unchoked");
int const m_unchoke_slots_idx = lt::find_metric_idx("ses.num_unchoke_slots");
int const m_limiter_up_queue_idx = lt::find_metric_idx("net.limiter_up_queue");

View File

@ -86,9 +86,6 @@ namespace libtorrent {
std::shared_ptr<http_connection> m_tracker_connection;
address m_tracker_ip;
#if TORRENT_USE_I2P
i2p_connection* m_i2p_conn;
#endif
};
TORRENT_EXTRA_EXPORT tracker_response parse_tracker_response(

View File

@ -142,7 +142,7 @@ private:
// send and receive buffer
aux::vector<char> m_buffer;
char const* m_id;
int m_command; // 0 = connect, 1 = accept
command_t m_command;
std::string m_dest;
std::string m_name_lookup;
@ -155,7 +155,7 @@ private:
read_name_lookup_response
};
int m_state;
state_t m_state;
#if TORRENT_USE_ASSERTS
int m_magic;
#endif

View File

@ -278,9 +278,12 @@ void http_connection::start(std::string const& hostname, int port
error_code err;
if (m_sock.is_open()) m_sock.close(err);
aux::proxy_settings const* proxy = ps;
#if TORRENT_USE_I2P
bool is_i2p = false;
char const* top_domain = strrchr(hostname.c_str(), '.');
aux::proxy_settings i2p_proxy;
if (top_domain && top_domain == ".i2p"_sv && i2p_conn)
{
// this is an i2p name, we need to use the sam connection
@ -291,23 +294,16 @@ void http_connection::start(std::string const& hostname, int port
// because i2p is sloooooow
m_completion_timeout *= 4;
m_read_timeout *= 4;
}
#endif
#if TORRENT_USE_I2P
if (is_i2p && i2p_conn->proxy().type != settings_pack::i2p_proxy)
{
m_timer.get_io_service().post(std::bind(&http_connection::callback
, me, error_code(errors::no_i2p_router), span<char>{}));
return;
}
if (is_i2p && i2p_conn->proxy().type != settings_pack::i2p_proxy)
{
m_timer.get_io_service().post(std::bind(&http_connection::callback
, me, error_code(errors::no_i2p_router), span<char>{}));
return;
}
#endif
aux::proxy_settings const* proxy = ps;
#if TORRENT_USE_I2P
aux::proxy_settings i2p_proxy;
if (is_i2p)
{
i2p_proxy = i2p_conn->proxy();
proxy = &i2p_proxy;
}
@ -479,25 +475,21 @@ void http_connection::close(bool force)
#if TORRENT_USE_I2P
void http_connection::connect_i2p_tracker(char const* destination)
{
TORRENT_ASSERT(m_sock.get<i2p_stream>());
#ifdef TORRENT_USE_OPENSSL
TORRENT_ASSERT(m_ssl == false);
TORRENT_ASSERT(m_sock.get<socket_type>());
TORRENT_ASSERT(m_sock.get<socket_type>()->get<i2p_stream>());
m_sock.get<socket_type>()->get<i2p_stream>()->set_destination(destination);
m_sock.get<socket_type>()->get<i2p_stream>()->set_command(i2p_stream::cmd_connect);
m_sock.get<socket_type>()->get<i2p_stream>()->set_session_id(m_i2p_conn->session_id());
#else
#endif
m_sock.get<i2p_stream>()->set_destination(destination);
m_sock.get<i2p_stream>()->set_command(i2p_stream::cmd_connect);
m_sock.get<i2p_stream>()->set_session_id(m_i2p_conn->session_id());
#endif
ADD_OUTSTANDING_ASYNC("http_connection::on_connect");
TORRENT_ASSERT(!m_connecting);
m_connecting = true;
m_sock.async_connect(tcp::endpoint(), std::bind(&http_connection::on_connect
, shared_from_this(), _1));
}
void http_connection::on_i2p_resolve(error_code const& e
, char const* destination)
void http_connection::on_i2p_resolve(error_code const& e, char const* destination)
{
COMPLETE_ASYNC("http_connection::on_i2p_resolve");
if (e)

View File

@ -66,9 +66,6 @@ namespace libtorrent {
, tracker_request const& req
, std::weak_ptr<request_callback> c)
: tracker_connection(man, req, ios, c)
#if TORRENT_USE_I2P
, m_i2p_conn(nullptr)
#endif
{}
void http_tracker_connection::start()
@ -90,7 +87,7 @@ namespace libtorrent {
}
#if TORRENT_USE_I2P
bool i2p = is_i2p_url(url);
bool const i2p = is_i2p_url(url);
#else
static const bool i2p = false;
#endif

View File

@ -220,7 +220,7 @@ namespace libtorrent {
: proxy_base(io_service)
, m_id(nullptr)
, m_command(cmd_create_session)
, m_state(0)
, m_state(read_hello_response)
{
#if TORRENT_USE_ASSERTS
m_magic = 0x1337;
@ -422,7 +422,9 @@ namespace libtorrent {
case cmd_connect:
send_connect(std::move(h));
break;
default:
case cmd_none:
case cmd_name_lookup:
case cmd_incoming:
h(e);
std::vector<char>().swap(m_buffer);
}

View File

@ -61,6 +61,26 @@ namespace aux {
constexpr torrent_list_index_t session_interface::torrent_checking_auto_managed;
}
namespace {
#if defined TORRENT_ASIO_DEBUGGING
void wait_for_asio_handlers()
{
int counter = 0;
while (log_async())
{
std::this_thread::sleep_for(seconds(1));
++counter;
std::printf("\x1b[2J\x1b[0;0H\x1b[33m==== Waiting to shut down: %d ==== \x1b[0m\n\n"
, counter);
}
async_dec_threads();
std::fprintf(stderr, "\n\nEXPECTS NO MORE ASYNC OPS\n\n\n");
}
#endif
} // anonymous namespace
settings_pack min_memory_usage()
{
settings_pack set;
@ -385,22 +405,13 @@ namespace {
// to keep the session_impl alive
m_impl->get_io_service().dispatch([=] { ptr->abort(); });
#if defined TORRENT_ASIO_DEBUGGING
int counter = 0;
while (log_async())
{
std::this_thread::sleep_for(seconds(1));
++counter;
std::printf("\x1b[2J\x1b[0;0H\x1b[33m==== Waiting to shut down: %d ==== \x1b[0m\n\n"
, counter);
}
async_dec_threads();
std::fprintf(stderr, "\n\nEXPECTS NO MORE ASYNC OPS\n\n\n");
#endif
if (m_thread && m_thread.unique())
{
#if defined TORRENT_ASIO_DEBUGGING
wait_for_asio_handlers();
#endif
m_thread->join();
}
}
session_proxy session::abort()
@ -426,7 +437,12 @@ namespace {
session_proxy::~session_proxy()
{
if (m_thread && m_thread.unique())
{
#if defined TORRENT_ASIO_DEBUGGING
wait_for_asio_handlers();
#endif
m_thread->join();
}
}
session_params::session_params(settings_pack sp)

View File

@ -6523,25 +6523,17 @@ namespace {
if (m_settings.get_bool(settings_pack::rate_limit_utp))
{
// allow the global or local peer class to limit uTP peers
m_peer_class_type_filter.add(peer_class_type_filter::utp_socket
, m_local_peer_class);
m_peer_class_type_filter.add(peer_class_type_filter::utp_socket
m_peer_class_type_filter.allow(peer_class_type_filter::utp_socket
, m_global_class);
m_peer_class_type_filter.add(peer_class_type_filter::ssl_utp_socket
, m_local_peer_class);
m_peer_class_type_filter.add(peer_class_type_filter::ssl_utp_socket
m_peer_class_type_filter.allow(peer_class_type_filter::ssl_utp_socket
, m_global_class);
}
else
{
// don't add the global or local peer class to limit uTP peers
m_peer_class_type_filter.remove(peer_class_type_filter::utp_socket
, m_local_peer_class);
m_peer_class_type_filter.remove(peer_class_type_filter::utp_socket
m_peer_class_type_filter.disallow(peer_class_type_filter::utp_socket
, m_global_class);
m_peer_class_type_filter.remove(peer_class_type_filter::ssl_utp_socket
, m_local_peer_class);
m_peer_class_type_filter.remove(peer_class_type_filter::ssl_utp_socket
m_peer_class_type_filter.disallow(peer_class_type_filter::ssl_utp_socket
, m_global_class);
}
}

View File

@ -55,6 +55,9 @@ lt::settings_pack settings()
pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled);
pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled);
pack.set_int(settings_pack::allowed_enc_level, settings_pack::pe_both);
#ifndef TORRENT_NO_DEPRECATE
pack.set_bool(settings_pack::rate_limit_utp, true);
#endif
pack.set_int(settings_pack::alert_mask, mask);

View File

@ -73,6 +73,9 @@ void test_swarm()
pack.set_bool(settings_pack::enable_natpmp, false);
pack.set_bool(settings_pack::enable_upnp, false);
pack.set_bool(settings_pack::enable_dht, false);
#ifndef TORRENT_NO_DEPRECATE
pack.set_bool(settings_pack::rate_limit_utp, true);
#endif
pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_forced);
pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_forced);

View File

@ -424,6 +424,9 @@ std::shared_ptr<torrent_info> setup_peer(tcp::socket& s, sha1_hash& ih
sett.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled);
sett.set_bool(settings_pack::enable_outgoing_utp, false);
sett.set_bool(settings_pack::enable_incoming_utp, false);
#ifndef TORRENT_NO_DEPRECATE
sett.set_bool(settings_pack::rate_limit_utp, true);
#endif
ses.reset(new lt::session(sett, lt::session::add_default_plugins));
error_code ec;

View File

@ -58,6 +58,9 @@ void test_lsd()
pack.set_bool(settings_pack::enable_upnp, false);
pack.set_bool(settings_pack::enable_natpmp, false);
pack.set_str(settings_pack::listen_interfaces, "127.0.0.1:48100");
#ifndef TORRENT_NO_DEPRECATE
pack.set_bool(settings_pack::rate_limit_utp, true);
#endif
lt::session ses1(pack);

View File

@ -75,6 +75,9 @@ void test_pex()
pack.set_bool(settings_pack::enable_dht, false);
pack.set_bool(settings_pack::enable_upnp, false);
pack.set_bool(settings_pack::enable_natpmp, false);
#ifndef TORRENT_NO_DEPRECATE
pack.set_bool(settings_pack::rate_limit_utp, true);
#endif
pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_forced);
pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_forced);

View File

@ -107,6 +107,9 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false)
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48075");
pack.set_int(settings_pack::alert_mask, mask);
#ifndef TORRENT_NO_DEPRECATE
pack.set_bool(settings_pack::rate_limit_utp, true);
#endif
lt::session ses1(pack);

View File

@ -92,12 +92,12 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, int flags)
#endif
std::printf("\n=== TEST == proxy: %s anonymous-mode: %s\n\n"
, proxy_name[proxy_type], (flags & force_proxy_mode) ? "yes" : "no");
int http_port = start_web_server();
int udp_port = start_udp_tracker();
int dht_port = start_dht();
int peer_port = start_peer();
int const http_port = start_web_server();
int const udp_port = start_udp_tracker();
int const dht_port = start_dht();
int const peer_port = start_peer();
int prev_udp_announces = num_udp_announces();
int const prev_udp_announces = num_udp_announces();
auto const alert_mask = alert::all_categories
& ~alert::progress_notification
@ -132,7 +132,7 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, int flags)
// in non-anonymous mode we circumvent/ignore the proxy if it fails
// wheras in anonymous mode, we just fail
sett.set_str(settings_pack::proxy_hostname, "non-existing.com");
sett.set_int(settings_pack::proxy_type, (settings_pack::proxy_type_t)proxy_type);
sett.set_int(settings_pack::proxy_type, proxy_type);
sett.set_int(settings_pack::proxy_port, 4444);
lt::session* s = new lt::session(sett);
@ -281,10 +281,12 @@ TORRENT_TEST(http_pt)
test_proxy(settings_pack::http_pw, expect_udp_connection | expect_dht_msg);
}
#if TORRENT_USE_I2P
TORRENT_TEST(i2p)
{
test_proxy(settings_pack::i2p_proxy, expect_udp_connection | expect_dht_msg);
}
#endif
// using anonymous mode
@ -322,8 +324,10 @@ TORRENT_TEST(anon_http_pw)
test_proxy(settings_pack::http_pw, force_proxy_mode | expect_udp_reject);
}
#if TORRENT_USE_I2P
TORRENT_TEST(anon_i2p)
{
test_proxy(settings_pack::i2p_proxy, force_proxy_mode);
}
#endif

View File

@ -161,6 +161,9 @@ void test_transfer(int proxy_type, settings_pack const& sett
pack.set_bool(settings_pack::enable_natpmp, false);
pack.set_bool(settings_pack::enable_lsd, false);
pack.set_bool(settings_pack::enable_dht, false);
#ifndef TORRENT_NO_DEPRECATE
pack.set_bool(settings_pack::rate_limit_utp, true);
#endif
lt::session ses1(pack);

View File

@ -42,6 +42,7 @@ def clean():
'.',
'tools',
'src',
'simulation',
os.path.join('src', 'kademlia'),
os.path.join('include', 'libtorrent'),
os.path.join('include', os.path.join('libtorrent', '_aux')),
@ -49,7 +50,8 @@ def clean():
os.path.join('bindings', 'python'),
os.path.join('bindings', os.path.join('python', 'src')),
os.path.join('bindings', 'c'),
os.path.join('bindings', os.path.join('c', 'src'))
os.path.join('bindings', os.path.join('c', 'src')),
os.path.join('simulation', 'libsimulator')
]
for d in directories: