diff --git a/ChangeLog b/ChangeLog
index 32f501b6e..c2073f8cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/docs/index.rst b/docs/index.rst
index ccd1c56d0..7f18d4ccb 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -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
diff --git a/docs/template.txt b/docs/template.txt
index 92f2304c7..1cc78b5af 100644
--- a/docs/template.txt
+++ b/docs/template.txt
@@ -51,7 +51,7 @@
DHT security extension |
- mailing list archive |
+ mailing list archive |
contributing |
streaming |
diff --git a/docs/template2.txt b/docs/template2.txt
index e642ddb17..7b4687f89 100644
--- a/docs/template2.txt
+++ b/docs/template2.txt
@@ -62,7 +62,7 @@
DHT security extension |
- mailing list archive |
+ mailing list archive |
contributing |
streaming |
diff --git a/examples/session_view.cpp b/examples/session_view.cpp
index 6f06a4d5d..4c54c6629 100644
--- a/examples/session_view.cpp
+++ b/examples/session_view.cpp
@@ -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
diff --git a/examples/session_view.hpp b/examples/session_view.hpp
index 4c725564e..8287a895e 100644
--- a/examples/session_view.hpp
+++ b/examples/session_view.hpp
@@ -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");
diff --git a/include/libtorrent/http_tracker_connection.hpp b/include/libtorrent/http_tracker_connection.hpp
index 7cceb3a36..acb711209 100644
--- a/include/libtorrent/http_tracker_connection.hpp
+++ b/include/libtorrent/http_tracker_connection.hpp
@@ -86,9 +86,6 @@ namespace libtorrent {
std::shared_ptr 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(
diff --git a/include/libtorrent/i2p_stream.hpp b/include/libtorrent/i2p_stream.hpp
index 24557c859..6ce0a1e4f 100644
--- a/include/libtorrent/i2p_stream.hpp
+++ b/include/libtorrent/i2p_stream.hpp
@@ -142,7 +142,7 @@ private:
// send and receive buffer
aux::vector 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
diff --git a/src/http_connection.cpp b/src/http_connection.cpp
index ed1b98e56..f9d3e3d1c 100644
--- a/src/http_connection.cpp
+++ b/src/http_connection.cpp
@@ -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{}));
- 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{}));
+ 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());
#ifdef TORRENT_USE_OPENSSL
TORRENT_ASSERT(m_ssl == false);
- TORRENT_ASSERT(m_sock.get());
- TORRENT_ASSERT(m_sock.get()->get());
- m_sock.get()->get()->set_destination(destination);
- m_sock.get()->get()->set_command(i2p_stream::cmd_connect);
- m_sock.get()->get()->set_session_id(m_i2p_conn->session_id());
-#else
+#endif
m_sock.get()->set_destination(destination);
m_sock.get()->set_command(i2p_stream::cmd_connect);
m_sock.get()->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)
diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp
index d8e2b171d..b173025c7 100644
--- a/src/http_tracker_connection.cpp
+++ b/src/http_tracker_connection.cpp
@@ -66,9 +66,6 @@ namespace libtorrent {
, tracker_request const& req
, std::weak_ptr 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
diff --git a/src/i2p_stream.cpp b/src/i2p_stream.cpp
index 7dfb194b9..7bcd26d79 100644
--- a/src/i2p_stream.cpp
+++ b/src/i2p_stream.cpp
@@ -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().swap(m_buffer);
}
diff --git a/src/session.cpp b/src/session.cpp
index 6effa2496..8be7ec24a 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -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)
diff --git a/src/session_impl.cpp b/src/session_impl.cpp
index 5ba644e83..56c4dc310 100644
--- a/src/session_impl.cpp
+++ b/src/session_impl.cpp
@@ -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);
}
}
diff --git a/test/settings.cpp b/test/settings.cpp
index 1deb6b0e9..4567e49b0 100644
--- a/test/settings.cpp
+++ b/test/settings.cpp
@@ -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);
diff --git a/test/test_auto_unchoke.cpp b/test/test_auto_unchoke.cpp
index cfe338066..42a1a6c35 100644
--- a/test/test_auto_unchoke.cpp
+++ b/test/test_auto_unchoke.cpp
@@ -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);
diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp
index 389d81576..75d26c2a7 100644
--- a/test/test_fast_extension.cpp
+++ b/test/test_fast_extension.cpp
@@ -424,6 +424,9 @@ std::shared_ptr 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;
diff --git a/test/test_lsd.cpp b/test/test_lsd.cpp
index ddca0f2be..b85c708a6 100644
--- a/test/test_lsd.cpp
+++ b/test/test_lsd.cpp
@@ -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);
diff --git a/test/test_pex.cpp b/test/test_pex.cpp
index 34645e9cd..7606c3e7e 100644
--- a/test/test_pex.cpp
+++ b/test/test_pex.cpp
@@ -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);
diff --git a/test/test_priority.cpp b/test/test_priority.cpp
index 49e2ca612..ce0d57845 100644
--- a/test/test_priority.cpp
+++ b/test/test_priority.cpp
@@ -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);
diff --git a/test/test_privacy.cpp b/test/test_privacy.cpp
index bd9a59ff5..a297b4da0 100644
--- a/test/test_privacy.cpp
+++ b/test/test_privacy.cpp
@@ -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
diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp
index fee521035..dd503357a 100644
--- a/test/test_transfer.cpp
+++ b/test/test_transfer.cpp
@@ -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);
diff --git a/tools/clean.py b/tools/clean.py
index 1abf64f06..2e46e6550 100755
--- a/tools/clean.py
+++ b/tools/clean.py
@@ -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: