From dcea457675aa0e8e0497ae34774366b4c2b5bf6c Mon Sep 17 00:00:00 2001 From: Nuno Teixeira Date: Sat, 29 Mar 2025 12:15:00 +0000 Subject: [PATCH] net-p2p/{lib,r}torrent: Update to 0.15.2 ChangeLog: https://github.com/rakshasa/rtorrent/releases/tag/v0.15.2 --- net-p2p/libtorrent/Makefile | 4 +- net-p2p/libtorrent/distinfo | 6 +- .../files/patch-Fixed_DhtController | 305 ++++++++++++++++++ net-p2p/libtorrent/files/patch-configure | 14 + net-p2p/libtorrent/pkg-plist | 14 +- net-p2p/rtorrent/Makefile | 4 +- net-p2p/rtorrent/distinfo | 6 +- net-p2p/rtorrent/files/patch-Fixed_RpcManager | 63 ++++ net-p2p/rtorrent/files/patch-configure | 15 + 9 files changed, 416 insertions(+), 15 deletions(-) create mode 100644 net-p2p/libtorrent/files/patch-Fixed_DhtController create mode 100644 net-p2p/libtorrent/files/patch-configure create mode 100644 net-p2p/rtorrent/files/patch-Fixed_RpcManager create mode 100644 net-p2p/rtorrent/files/patch-configure diff --git a/net-p2p/libtorrent/Makefile b/net-p2p/libtorrent/Makefile index 8343fd58a04d..5ed69ce3f817 100644 --- a/net-p2p/libtorrent/Makefile +++ b/net-p2p/libtorrent/Makefile @@ -1,5 +1,5 @@ PORTNAME= libtorrent -DISTVERSION= 0.15.1 +DISTVERSION= 0.15.2 CATEGORIES= net-p2p MASTER_SITES= https://github.com/rakshasa/rtorrent/releases/download/v${DISTVERSION}/ @@ -10,7 +10,7 @@ WWW= https://github.com/rakshasa/libtorrent LICENSE= GPLv2+ LICENSE_FILE= ${WRKSRC}/COPYING -USES= compiler:c++14-lang cpe libtool localbase:ldflags pathfix \ +USES= compiler:c++17-lang cpe libtool localbase:ldflags pathfix \ pkgconfig ssl USE_LDCONFIG= yes diff --git a/net-p2p/libtorrent/distinfo b/net-p2p/libtorrent/distinfo index 1f51b2b7bcbe..381d37068636 100644 --- a/net-p2p/libtorrent/distinfo +++ b/net-p2p/libtorrent/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1735748325 -SHA256 (libtorrent-0.15.1.tar.gz) = ef96bcc1fe8c56108db2f323e562fb982af1e5f3f21086986d133518df874301 -SIZE (libtorrent-0.15.1.tar.gz) = 805722 +TIMESTAMP = 1743202037 +SHA256 (libtorrent-0.15.2.tar.gz) = 4636b10776f123c09a6de1a1a18dd6427e7a87535682defad31530c463005f2e +SIZE (libtorrent-0.15.2.tar.gz) = 867838 diff --git a/net-p2p/libtorrent/files/patch-Fixed_DhtController b/net-p2p/libtorrent/files/patch-Fixed_DhtController new file mode 100644 index 000000000000..23b76bb2f605 --- /dev/null +++ b/net-p2p/libtorrent/files/patch-Fixed_DhtController @@ -0,0 +1,305 @@ +commit 01fc34516ef9fcff3cffc9d224c6870a8eb7eff6 +Author: rakshasa +Date: Sat Mar 29 07:32:25 2025 +0100 + + Fixed DhtController::m_router check and log unit tests. + +diff --git src/torrent/tracker/dht_controller.cc src/torrent/tracker/dht_controller.cc +index 2d0afcf6..c43e1dd7 100644 +--- src/torrent/tracker/dht_controller.cc ++++ src/torrent/tracker/dht_controller.cc +@@ -101,13 +101,13 @@ DhtController::set_receive_requests(bool state) { + + void + DhtController::add_node(const sockaddr* sa, int port) { +- if (!m_router) ++ if (m_router) + m_router->contact(sa, port); + } + + void + DhtController::add_node(const std::string& host, int port) { +- if (!m_router) ++ if (m_router) + m_router->add_contact(host, port); + } + +@@ -121,11 +121,17 @@ DhtController::store_cache(Object* container) { + + DhtController::statistics_type + DhtController::get_statistics() const { ++ if (!m_router) ++ throw internal_error("DhtController::get_statistics called but DHT not initialized."); ++ + return m_router->get_statistics(); + } + + void + DhtController::reset_statistics() { ++ if (!m_router) ++ throw internal_error("DhtController::reset_statistics called but DHT not initialized."); ++ + m_router->reset_statistics(); + } + +@@ -133,6 +139,9 @@ DhtController::reset_statistics() { + + void + DhtController::set_upload_throttle(Throttle* t) { ++ if (!m_router) ++ throw internal_error("DhtController::set_upload_throttle() called but DHT not initialized."); ++ + if (m_router->is_active()) + throw internal_error("DhtController::set_upload_throttle() called while DHT server active."); + +@@ -141,6 +150,9 @@ DhtController::set_upload_throttle(Throttle* t) { + + void + DhtController::set_download_throttle(Throttle* t) { ++ if (!m_router) ++ throw internal_error("DhtController::set_download_throttle() called but DHT not initialized."); ++ + if (m_router->is_active()) + throw internal_error("DhtController::set_download_throttle() called while DHT server active."); + +diff --git src/torrent/utils/log.cc src/torrent/utils/log.cc +index a587cdfe..1c7a4362 100644 +--- src/torrent/utils/log.cc ++++ src/torrent/utils/log.cc +@@ -45,12 +45,12 @@ struct log_gz_output { + gzFile gz_file; + }; + +-typedef std::vector log_cache_list; +-typedef std::vector > log_child_list; +-typedef std::vector log_slot_list; +-typedef std::vector > log_output_list; ++typedef std::vector log_cache_list; ++typedef std::vector> log_child_list; ++typedef std::vector log_slot_list; ++typedef std::vector> log_output_list; + +-log_output_list log_outputs; ++log_output_list log_outputs LIBTORRENT_EXPORT; + log_child_list log_children; + log_cache_list log_cache; + log_group_list log_groups; +@@ -105,10 +105,10 @@ log_rebuild_cache() { + continue; + } + +- log_cache_list::iterator cache_itr = ++ log_cache_list::iterator cache_itr = + std::find_if(log_cache.begin(), log_cache.end(), + std::bind(&log_cache_entry::equal_outputs, std::placeholders::_1, use_outputs)); +- ++ + if (cache_itr == log_cache.end()) { + cache_itr = log_cache.insert(log_cache.end(), log_cache_entry()); + cache_itr->outputs = use_outputs; +@@ -282,13 +282,11 @@ log_add_group_output(int group, const char* name) { + log_output_list::iterator itr = log_find_output_name(name); + size_t index = std::distance(log_outputs.begin(), itr); + +- if (itr == log_outputs.end()) { +- throw input_error("Log name not found."); +- } ++ if (itr == log_outputs.end()) ++ throw input_error("Log name not found: '" + std::string(name) + "'"); + +- if (index >= log_group::max_size_outputs()) { ++ if (index >= log_group::max_size_outputs()) + throw input_error("Cannot add more log group outputs."); +- } + + log_groups[group].set_output_at(index, true); + log_rebuild_cache(); +@@ -346,7 +344,7 @@ log_gz_file_write(std::shared_ptr& outfile, const char* data, siz + int buffer_length = snprintf(buffer, 64, GROUPFMT, + cachedTime.seconds(), + log_level_char[group % 6]); +- ++ + if (buffer_length > 0) + gzwrite(outfile->gz_file, buffer, buffer_length); + +@@ -355,7 +353,7 @@ log_gz_file_write(std::shared_ptr& outfile, const char* data, siz + + } else if (group == -1) { + gzwrite(outfile->gz_file, "---DUMP---\n", sizeof("---DUMP---\n") - 1); +- ++ + if (length != 0) + gzwrite(outfile->gz_file, data, length); + +diff --git src/torrent/utils/log_buffer.h src/torrent/utils/log_buffer.h +index 025192c1..41f9d5ef 100644 +--- src/torrent/utils/log_buffer.h ++++ src/torrent/utils/log_buffer.h +@@ -8,6 +8,8 @@ + #include + #include + ++#include ++ + namespace torrent { + + struct log_entry { +@@ -23,7 +25,7 @@ struct log_entry { + std::string message; + }; + +-class [[gnu::visibility("default")]] log_buffer : private std::deque { ++class LIBTORRENT_EXPORT log_buffer : private std::deque { + public: + typedef std::deque base_type; + typedef std::function slot_void; +@@ -47,7 +49,7 @@ public: + m_max_size(200) {} + + unsigned int max_size() const { return m_max_size; } +- ++ + // Always lock before calling any function. + void lock() { m_lock.lock(); } + void unlock() { m_lock.unlock(); } +@@ -66,7 +68,7 @@ private: + + typedef std::unique_ptr> log_buffer_ptr; + +-[[gnu::visibility("default")]] log_buffer_ptr log_open_log_buffer(const char* name); ++log_buffer_ptr log_open_log_buffer(const char* name) LIBTORRENT_EXPORT; + + } + +diff --git test/Makefile.am test/Makefile.am +index d0d98da9..87ae61d2 100644 +--- test/Makefile.am ++++ test/Makefile.am +@@ -9,6 +9,9 @@ TESTS = \ + + check_PROGRAMS = $(TESTS) + ++# This can cause duplicate symbols, so export anything that causes issues. ++ ++# LibTorrent_Test_LDADD = ../src/libtorrent.la + LibTorrent_Test_LDADD = \ + ../src/libtorrent.la \ + ../src/libtorrent_other.la \ +diff --git test/helpers/progress_listener.cc test/helpers/progress_listener.cc +index 7a6ed047..e7f000fc 100644 +--- test/helpers/progress_listener.cc ++++ test/helpers/progress_listener.cc +@@ -10,6 +10,8 @@ + #include "torrent/utils/log.h" + #include "torrent/utils/log_buffer.h" + ++#include ++ + static std::string + get_test_path(const test_list_type& tl) { + if (tl.size() < 2) +diff --git test/helpers/test_fixture.cc test/helpers/test_fixture.cc +index 4d8d7214..3d766ea0 100644 +--- test/helpers/test_fixture.cc ++++ test/helpers/test_fixture.cc +@@ -1,18 +1,20 @@ +-#include "config.h" +- +-#include "test_fixture.h" +- +-#include "torrent/utils/log.h" +- +-void +-test_fixture::setUp() { +- mock_init(); +- +- log_add_group_output(torrent::LOG_CONNECTION_BIND, "test_output"); +- log_add_group_output(torrent::LOG_CONNECTION_FD, "test_output"); +-} +- +-void +-test_fixture::tearDown() { +- mock_cleanup(); +-} ++#include "config.h" ++ ++#include "test_fixture.h" ++ ++#include "torrent/utils/log.h" ++ ++#include ++ ++void ++test_fixture::setUp() { ++ mock_init(); ++ ++ log_add_group_output(torrent::LOG_CONNECTION_BIND, "test_output"); ++ log_add_group_output(torrent::LOG_CONNECTION_FD, "test_output"); ++} ++ ++void ++test_fixture::tearDown() { ++ mock_cleanup(); ++} +diff --git test/torrent/utils/test_log.cc test/torrent/utils/test_log.cc +index 8ab8ed87..214866a8 100644 +--- test/torrent/utils/test_log.cc ++++ test/torrent/utils/test_log.cc +@@ -9,8 +9,8 @@ + #include + #include + +-#include +-#include ++#include "torrent/exceptions.h" ++#include "torrent/utils/log.h" + + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_log, "torrent/utils"); + +@@ -97,12 +97,12 @@ test_log::test_print() { + open_output("test_print_1", 0x1); + open_output("test_print_2", 0x2); + torrent::log_add_group_output(0, "test_print_1"); +- ++ + LTUNIT_ASSERT_OUTPUT(0, 0x1, "foo_bar", "foo_bar"); + LTUNIT_ASSERT_OUTPUT(0, 0x1, "foo 123 bar", "foo %i %s", 123, "bar"); + + torrent::log_add_group_output(0, "test_print_2"); +- ++ + LTUNIT_ASSERT_OUTPUT(0, 0x1|0x2, "test_multiple", "test_multiple"); + } + +@@ -144,7 +144,7 @@ test_log::test_file_output() { + + torrent::log_open_file_output("test_file", filename.c_str()); + torrent::log_add_group_output(GROUP_PARENT_1, "test_file"); +- ++ + lt_log_print(GROUP_PARENT_1, "test_file"); + + torrent::log_cleanup(); // To ensure we flush the buffers. +@@ -152,7 +152,7 @@ test_log::test_file_output() { + std::ifstream temp_file(filename.c_str()); + + CPPUNIT_ASSERT(temp_file.good()); +- ++ + char buffer[256]; + temp_file.getline(buffer, 256); + +diff --git test/torrent/utils/test_log_buffer.cc test/torrent/utils/test_log_buffer.cc +index 58412750..60732273 100644 +--- test/torrent/utils/test_log_buffer.cc ++++ test/torrent/utils/test_log_buffer.cc +@@ -3,7 +3,7 @@ + #include "test_log_buffer.h" + + #include "globals.h" +-#include ++#include "torrent/utils/log_buffer.h" + + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_log_buffer, "torrent/utils"); + diff --git a/net-p2p/libtorrent/files/patch-configure b/net-p2p/libtorrent/files/patch-configure new file mode 100644 index 000000000000..3e660da1b9b1 --- /dev/null +++ b/net-p2p/libtorrent/files/patch-configure @@ -0,0 +1,14 @@ +Fixed configure script compatibility issue. +Applied manually on configure from 2943255ebaf5c7a574e8c14b474fb6cf2562f77a + +--- configure.orig 2025-03-28 22:55:28 UTC ++++ configure +@@ -17383,7 +17383,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + CXX="$CXX" + else + result=`echo "${values_to_check}" | $GREP -Fvx -- "${unwanted_values}" | $GREP -v '^$'` +- CXX=${result//$'\n'/ } ++ CXX=$(echo "$result" | tr -d '\n') + fi + + diff --git a/net-p2p/libtorrent/pkg-plist b/net-p2p/libtorrent/pkg-plist index 6c38cf673ae7..05694e95a727 100644 --- a/net-p2p/libtorrent/pkg-plist +++ b/net-p2p/libtorrent/pkg-plist @@ -14,7 +14,6 @@ include/torrent/data/file_manager.h include/torrent/data/file_utils.h include/torrent/data/piece.h include/torrent/data/transfer_list.h -include/torrent/dht_manager.h include/torrent/download.h include/torrent/download/choke_group.h include/torrent/download/choke_queue.h @@ -29,6 +28,7 @@ include/torrent/hash_string.h include/torrent/http.h include/torrent/net/address_info.h include/torrent/net/fd.h +include/torrent/net/resolver.h include/torrent/net/socket_address.h include/torrent/net/socket_address_key.h include/torrent/net/socket_event.h @@ -53,7 +53,11 @@ include/torrent/poll_select.h include/torrent/rate.h include/torrent/throttle.h include/torrent/torrent.h -include/torrent/tracker.h +include/torrent/tracker/dht_controller.h +include/torrent/tracker/manager.h +include/torrent/tracker/tracker.h +include/torrent/tracker/tracker_state.h +include/torrent/tracker/wrappers.h include/torrent/tracker_controller.h include/torrent/tracker_list.h include/torrent/utils/directory_events.h @@ -64,10 +68,10 @@ include/torrent/utils/option_strings.h include/torrent/utils/ranges.h include/torrent/utils/resume.h include/torrent/utils/signal_bitfield.h -include/torrent/utils/thread_base.h +include/torrent/utils/thread.h include/torrent/utils/thread_interrupt.h include/torrent/utils/uri_parser.h lib/libtorrent.so -lib/libtorrent.so.23 -lib/libtorrent.so.23.0.0 +lib/libtorrent.so.24 +lib/libtorrent.so.24.0.0 libdata/pkgconfig/libtorrent.pc diff --git a/net-p2p/rtorrent/Makefile b/net-p2p/rtorrent/Makefile index e32d531e786f..9f200ea388a8 100644 --- a/net-p2p/rtorrent/Makefile +++ b/net-p2p/rtorrent/Makefile @@ -1,5 +1,5 @@ PORTNAME= rtorrent -DISTVERSION= 0.15.1 +DISTVERSION= 0.15.2 CATEGORIES= net-p2p MASTER_SITES= https://github.com/rakshasa/rtorrent/releases/download/v${DISTVERSION}/ @@ -14,7 +14,7 @@ LICENSE_FILE_GPLv2= ${WRKSRC}/COPYING LIB_DEPENDS= libcurl.so:ftp/curl \ libtorrent.so:net-p2p/libtorrent -USES= compiler:c++14-lang ncurses pkgconfig +USES= compiler:c++17-lang ncurses pkgconfig GNU_CONFIGURE= yes CONFIGURE_ARGS= --disable-debug LDFLAGS+= -lexecinfo -pthread diff --git a/net-p2p/rtorrent/distinfo b/net-p2p/rtorrent/distinfo index 5be13ef027c7..f1dc84144faa 100644 --- a/net-p2p/rtorrent/distinfo +++ b/net-p2p/rtorrent/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1735748725 -SHA256 (rtorrent-0.15.1.tar.gz) = 1d5437d7a6828f2f72a6c309f25f136eda1be69b059d250bc52e0d4185420506 -SIZE (rtorrent-0.15.1.tar.gz) = 688056 +TIMESTAMP = 1743204418 +SHA256 (rtorrent-0.15.2.tar.gz) = d10fd7d392d5d1e599ccf54238270df8b14b03fcc7cb8f62778ab868af6b0e5d +SIZE (rtorrent-0.15.2.tar.gz) = 858419 diff --git a/net-p2p/rtorrent/files/patch-Fixed_RpcManager b/net-p2p/rtorrent/files/patch-Fixed_RpcManager new file mode 100644 index 000000000000..65a2f8498ef9 --- /dev/null +++ b/net-p2p/rtorrent/files/patch-Fixed_RpcManager @@ -0,0 +1,63 @@ +commit 672bd0900501bba4d302479dc6fd1e244c2268f5 +Author: rakshasa +Date: Sat Mar 29 07:46:22 2025 +0100 + + Added default switch cases to RpcManager. + +diff --git src/rpc/rpc_manager.cc src/rpc/rpc_manager.cc +index 5409a4f..13a13d6 100644 +--- src/rpc/rpc_manager.cc ++++ src/rpc/rpc_manager.cc +@@ -99,22 +99,26 @@ RpcManager::object_to_target(const torrent::Object& obj, int call_flags, rpc::ta + bool + RpcManager::process(RPCType type, const char* in_buffer, uint32_t length, slot_response_callback callback) { + switch (type) { +- case RPCType::XML: { ++ case RPCType::XML: + if (m_xmlrpc.is_valid() && rpc::call_command_value("network.rpc.use_xmlrpc")) { + return m_xmlrpc.process(in_buffer, length, callback); + } else { + const std::string response = "faultCode-501faultStringXML-RPC not supported"; + return callback(response.c_str(), response.size()); + } +- } +- case RPCType::JSON: { ++ break; ++ ++ case RPCType::JSON: + if (rpc::call_command_value("network.rpc.use_jsonrpc")) { + return m_jsonrpc.process(in_buffer, length, callback); + } else { + const std::string response = "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32601,\"message\":\"JSON-RPC not supported\"},\"id\":null}"; + return callback(response.c_str(), response.size()); + } +- } ++ break; ++ ++ default: ++ throw torrent::input_error("invalid parameters: unknown RPC type"); + } + } + +@@ -139,6 +143,8 @@ RpcManager::is_type_enabled(RPCType type) const { + return m_is_xmlrpc_enabled; + case RPCType::JSON: + return m_is_jsonrpc_enabled; ++ default: ++ throw torrent::input_error("invalid parameters: unknown RPC type"); + } + } + +@@ -147,8 +153,12 @@ RpcManager::set_type_enabled(RPCType type, bool enabled) { + switch (type) { + case RPCType::XML: + m_is_xmlrpc_enabled = enabled; ++ break; + case RPCType::JSON: + m_is_jsonrpc_enabled = enabled; ++ break; ++ default: ++ throw torrent::input_error("invalid parameters: unknown RPC type"); + } + } + diff --git a/net-p2p/rtorrent/files/patch-configure b/net-p2p/rtorrent/files/patch-configure new file mode 100644 index 000000000000..8953b1567937 --- /dev/null +++ b/net-p2p/rtorrent/files/patch-configure @@ -0,0 +1,15 @@ +Fixed configure script compatibility issue. +Applied manually on configure from 92e37cb4d7760bd4a1e6cd07eb61d33f4c402647 + + +--- configure.orig 2025-03-28 23:35:13 UTC ++++ configure +@@ -17588,7 +17588,7 @@ printf "%s\n" "#define API_VERSION 11" >>confdefs.h + CXX="$CXX" + else + result=`echo "${values_to_check}" | $GREP -Fvx -- "${unwanted_values}" | $GREP -v '^$'` +- CXX=${result//$'\n'/ } ++ CXX=$(echo "$result" | tr -d '\n') + fi + +