Index | Thread | Search

From:
Jeremie Courreges-Anglas <jca@wxcvbn.org>
Subject:
Re: (unfinished) UPDATE: net/rtorrent, net/libtorrent
To:
"Anthony J. Bentley" <bentley@openbsd.org>
Cc:
ports@openbsd.org, kn@openbsd.org
Date:
Sat, 9 Nov 2024 19:32:12 +0100

Download raw body.

Thread
On Sat, Nov 09, 2024 at 08:45:27AM -0700, Anthony J. Bentley wrote:
> Hi,
> 
> I noticed recently that rtorrent in -current now segfaults on exit.
> rtorrent and libtorrent haven't changed in some time, so it must be
> some dependency that changed. There's a lot of curl in the backtrace,
> so that's probably it.
> 
> Both rtorrent and libtorrent were updated in September. Unfortunately,
> these have some weird issues (I count three).
> 
> Problem one: rtorrent no longer starts up, instead giving this error:
> 
> "Could not allocate socket for listening."
> 
> This is because SocketFd::open_stream() in libtorrent:src/net/socket_fd.cc 
> now fails. Between 0.13.6 (what we have) and 0.14.0 (the new one), it
> changed from:
> 
> bool
> SocketFd::open_stream() {
>   return (m_fd = socket(rak::socket_address::pf_inet, SOCK_STREAM, IPPROTO_TCP)) != -1;
> }
> 
> to:
> 
> bool
> SocketFd::open_stream() {
>   m_fd = socket(rak::socket_address::pf_inet6, SOCK_STREAM, IPPROTO_TCP);
> 
>   if (m_fd == -1) {
>     m_ipv6_socket = false;
>     return (m_fd = socket(rak::socket_address::pf_inet, SOCK_STREAM, IPPROTO_TCP)) != -1;
>   }
> 
>   m_ipv6_socket = true;
> 
>   if (!set_ipv6_v6only(false)) {
>     close();
>     return false;
>   }
> 
>   return true;
> }
> 
> Reverting to the older function gets past the error, but maybe that's
> papering over something important, I don't know.

As discussed in the restaurant, the problem is that we do not support
IPv4-mapped IPv6 addresses, on purpose, for security concerns.
Frankly at this point my personal opinion is that it's harming us more
than protecting us.  Anyway...

I suspect your tweak isn't enough because your revert doesn't
explicitely set m_ipv6_socket to false, and thus let it be
uninitialized, which most probably means "true" and the opposite of
what you want.

> Problem two: the curl segfault still exists. This can be reproduced by
> starting rtorrent, loading a torrent (waiting for hashing to finish if
> necessary), then exiting with Ctrl-Q.

Can you reproduce using the diff below?  (I can't, using a toy setup.)
Slightly tested using upstream's default config file and layout.  I've
tested downloading a debian-12.8 netinst iso using rtorrent, the
resulting file matches.  I haven't tested or checked anything else.

HTH


Index: net/libtorrent/Makefile
===================================================================
RCS file: /home/cvs/ports/net/libtorrent/Makefile,v
diff -u -p -r1.65 Makefile
--- net/libtorrent/Makefile	27 Sep 2023 14:18:17 -0000	1.65
+++ net/libtorrent/Makefile	9 Nov 2024 17:38:28 -0000
@@ -6,9 +6,8 @@ BROKEN-sh =		undefined references to __s
 # requires C++ tr1 headers
 NOT_FOR_ARCHS=		${GCC3_ARCHS}
 
-DISTNAME=		libtorrent-0.13.6
+DISTNAME=		libtorrent-0.14.0
 EPOCH=			0
-REVISION=		9
 SHARED_LIBS +=  	torrent 22.1	# .18.0
 CATEGORIES=		net devel
 
@@ -17,16 +16,16 @@ HOMEPAGE=		https://rakshasa.github.io/rt
 # GPLv2
 PERMIT_PACKAGE=	Yes
 
-SITES=			https://rtorrent.net/downloads/
+SITES=			https://github.com/rakshasa/rtorrent-archive/raw/master/
 
-WANTLIB=		crypto m pthread ${COMPILER_LIBCXX} z
+WANTLIB=		crypto cppunit m pthread ${COMPILER_LIBCXX} z
 
 COMPILER =		base-clang ports-gcc base-gcc
 
-BUILD_DEPENDS=		devel/cppunit
+LIB_DEPENDS=		devel/cppunit
 
 CONFIGURE_STYLE=	autoconf
-AUTOCONF_VERSION=	2.69
+AUTOCONF_VERSION=	2.71
 CONFIGURE_ARGS=		--enable-static \
 			--with-kqueue \
 			--without-epoll \
@@ -36,11 +35,4 @@ CONFIGURE_ARGS=		--enable-static \
 
 DEBUG_PACKAGES =	${BUILD_PACKAGES}
 
-CXXFLAGS +=		-std=c++11
-
-# this patches *only* files containing tr1 to no longer refer to tr1
-# we do it pre-patch, because autoconf passes right after us
-pre-patch:
-	find ${WRKDIST} -type f -exec fgrep -lw tr1 {} + | \
-		xargs sed -i.bak -e 's,<tr1/,<,' -e 's/std::tr1/std/g'
 .include <bsd.port.mk>
Index: net/libtorrent/distinfo
===================================================================
RCS file: /home/cvs/ports/net/libtorrent/distinfo,v
diff -u -p -r1.20 distinfo
--- net/libtorrent/distinfo	11 Sep 2015 09:15:40 -0000	1.20
+++ net/libtorrent/distinfo	9 Nov 2024 17:38:28 -0000
@@ -1,2 +1,2 @@
-SHA256 (libtorrent-0.13.6.tar.gz) = KDigjJbt/ZNq/4+/mey7kwwr/KMzfdFILrX8zbgNWgQ=
-SIZE (libtorrent-0.13.6.tar.gz) = 781253
+SHA256 (libtorrent-0.14.0.tar.gz) = F7gW2lgHx7NFWhpIqujazw9O91saQ3LHWJSHEAZv0+w=
+SIZE (libtorrent-0.14.0.tar.gz) = 809617
Index: net/libtorrent/patches/patch-src_data_memory_chunk_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_data_memory_chunk_cc
diff -N net/libtorrent/patches/patch-src_data_memory_chunk_cc
--- net/libtorrent/patches/patch-src_data_memory_chunk_cc	11 Mar 2022 19:46:17 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-Index: src/data/memory_chunk.cc
---- src/data/memory_chunk.cc.orig
-+++ src/data/memory_chunk.cc
-@@ -54,6 +54,10 @@ extern "C" int madvise(void *, size_t, int);
- 
- namespace torrent {
- 
-+const int MemoryChunk::sync_sync;
-+const int MemoryChunk::sync_async;
-+const int MemoryChunk::sync_invalidate;
-+
- uint32_t MemoryChunk::m_pagesize = getpagesize();
- 
- inline void
Index: net/libtorrent/patches/patch-src_net_socket_set_h
===================================================================
RCS file: net/libtorrent/patches/patch-src_net_socket_set_h
diff -N net/libtorrent/patches/patch-src_net_socket_set_h
--- net/libtorrent/patches/patch-src_net_socket_set_h	11 Mar 2022 19:46:17 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,23 +0,0 @@
-clang can't accept a "generic" void* allocator because value_type doesn't
-match.  FreeBSD has the same patch.
-
-
-Index: src/net/socket_set.h
---- src/net/socket_set.h.orig
-+++ src/net/socket_set.h
-@@ -53,12 +53,12 @@ namespace torrent {
- 
- // Propably should rename to EventSet...
- 
--class SocketSet : private std::vector<Event*, rak::cacheline_allocator<> > {
-+class SocketSet : private std::vector<Event*, rak::cacheline_allocator<Event*> > {
- public:
-   typedef uint32_t    size_type;
- 
--  typedef std::vector<Event*, rak::cacheline_allocator<> > base_type;
--  typedef std::vector<size_type, rak::cacheline_allocator<> > Table;
-+  typedef std::vector<Event*, rak::cacheline_allocator<Event*> > base_type;
-+  typedef std::vector<size_type, rak::cacheline_allocator<size_type> > Table;
- 
-   static const size_type npos = static_cast<size_type>(-1);
- 
Index: net/libtorrent/patches/patch-src_protocol_extensions_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_protocol_extensions_cc
diff -N net/libtorrent/patches/patch-src_protocol_extensions_cc
--- net/libtorrent/patches/patch-src_protocol_extensions_cc	11 Mar 2022 19:46:17 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,23 +0,0 @@
-# https://github.com/rakshasa/libtorrent/pull/99/files
-
-Index: src/protocol/extensions.cc
---- src/protocol/extensions.cc.orig	2015-08-08 17:01:32.000000000 +0200
-+++ src/protocol/extensions.cc	2017-12-02 01:46:38.522736000 +0100
-@@ -394,7 +394,7 @@
-   if (m_download->info()->is_meta_download() || piece >= pieceEnd) {
-     // reject: { "msg_type" => 2, "piece" => ... }
-     m_pendingType = UT_METADATA;
--    m_pending = build_bencode(40, "d8:msg_typei2e5:piecei%zuee", piece);
-+    m_pending = build_bencode(sizeof(size_t) + 36, "d8:msg_typei2e5:piecei%zuee", piece);
-     return;
-   }
- 
-@@ -407,7 +407,7 @@
-   // data: { "msg_type" => 1, "piece" => ..., "total_size" => ... } followed by piece data (outside of dictionary)
-   size_t length = piece == pieceEnd - 1 ? m_download->info()->metadata_size() % metadata_piece_size : metadata_piece_size;
-   m_pendingType = UT_METADATA;
--  m_pending = build_bencode(length + 128, "d8:msg_typei1e5:piecei%zue10:total_sizei%zuee", piece, metadataSize);
-+  m_pending = build_bencode((2 * sizeof(size_t)) + length + 120, "d8:msg_typei1e5:piecei%zue10:total_sizei%zuee", piece, metadataSize);
- 
-   memcpy(m_pending.end(), buffer + (piece << metadata_piece_shift), length);
-   m_pending.set(m_pending.data(), m_pending.end() + length, m_pending.owned());
Index: net/libtorrent/patches/patch-src_protocol_handshake_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_protocol_handshake_cc
diff -N net/libtorrent/patches/patch-src_protocol_handshake_cc
--- net/libtorrent/patches/patch-src_protocol_handshake_cc	11 Mar 2022 19:46:17 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-# https://github.com/rakshasa/libtorrent/pull/99/files
-
-Index: src/protocol/handshake.cc
---- src/protocol/handshake.cc.orig	2015-08-08 17:01:49.000000000 +0200
-+++ src/protocol/handshake.cc	2017-12-02 01:46:38.523093000 +0100
-@@ -738,7 +738,7 @@
-         break;
- 
-       if (m_readBuffer.remaining() > m_encryption.length_ia())
--        throw internal_error("Read past initial payload after incoming encrypted handshake.");
-+        throw handshake_error(ConnectionManager::handshake_failed, e_handshake_invalid_value);
- 
-       if (m_encryption.crypto() != HandshakeEncryption::crypto_rc4)
-         m_encryption.info()->set_obfuscated();
Index: net/libtorrent/patches/patch-src_protocol_request_list_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_protocol_request_list_cc
diff -N net/libtorrent/patches/patch-src_protocol_request_list_cc
--- net/libtorrent/patches/patch-src_protocol_request_list_cc	11 Mar 2022 19:46:17 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
-Index: src/protocol/request_list.cc
---- src/protocol/request_list.cc.orig
-+++ src/protocol/request_list.cc
-@@ -52,6 +52,7 @@
- 
- namespace torrent {
- 
-+const int request_list_constants::bucket_count;
- const instrumentation_enum request_list_constants::instrumentation_added[bucket_count] = {
-   INSTRUMENTATION_TRANSFER_REQUESTS_QUEUED_ADDED,
-   INSTRUMENTATION_TRANSFER_REQUESTS_UNORDERED_ADDED,
Index: net/libtorrent/patches/patch-src_torrent_common_h
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_common_h
diff -N net/libtorrent/patches/patch-src_torrent_common_h
--- net/libtorrent/patches/patch-src_torrent_common_h	11 Mar 2022 19:46:17 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,21 +0,0 @@
-comment says it all
-
-Index: src/torrent/common.h
---- src/torrent/common.h.orig
-+++ src/torrent/common.h
-@@ -109,4 +109,15 @@ class TransferList;
- 
- }
- 
-+// XXX tr1/array differs from array
-+template<typename T, typename U>
-+inline void fill_with_value(T& a, const U& v)
-+{
-+#if __cplusplus >= 201103L
-+	a.fill(v);
-+#else
-+	a.assign(v);
-+#endif
-+}
-+
- #endif
Index: net/libtorrent/patches/patch-src_torrent_data_block_failed_h
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_data_block_failed_h
diff -N net/libtorrent/patches/patch-src_torrent_data_block_failed_h
--- net/libtorrent/patches/patch-src_torrent_data_block_failed_h	11 Mar 2022 19:46:17 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,16 +0,0 @@
-const reference has no useful semantics, shut up clang warning
-
-Index: src/torrent/data/block_failed.h
---- src/torrent/data/block_failed.h.orig
-+++ src/torrent/data/block_failed.h
-@@ -85,8 +85,8 @@ class BlockFailed : public std::vector<std::pair<char*
-   BlockFailed(const BlockFailed&);
-   void operator = (const BlockFailed&);
- 
--  static void         delete_entry(const reference e)                         { delete [] e.first; }
--  static bool         compare_entries(const reference e1, const reference e2) { return e1.second < e2.second; }
-+  static void         delete_entry(reference e)                         { delete [] e.first; }
-+  static bool         compare_entries(reference e1, reference e2) { return e1.second < e2.second; }
- 
-   size_type           m_current;
- };
Index: net/libtorrent/patches/patch-src_torrent_data_file_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_data_file_cc
diff -N net/libtorrent/patches/patch-src_torrent_data_file_cc
--- net/libtorrent/patches/patch-src_torrent_data_file_cc	11 Mar 2022 19:46:17 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,19 +0,0 @@
-Index: src/torrent/data/file.cc
---- src/torrent/data/file.cc.orig
-+++ src/torrent/data/file.cc
-@@ -50,6 +50,15 @@
- 
- namespace torrent {
- 
-+const int File::flag_active;
-+const int File::flag_create_queued;
-+const int File::flag_resize_queued;
-+const int File::flag_fallocate;
-+const int File::flag_previously_created;
-+
-+const int File::flag_prioritize_first;
-+const int File::flag_prioritize_last;
-+
- File::File() :
-   m_fd(-1),
-   m_protection(0),
Index: net/libtorrent/patches/patch-src_torrent_data_transfer_list_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_data_transfer_list_cc
diff -N net/libtorrent/patches/patch-src_torrent_data_transfer_list_cc
--- net/libtorrent/patches/patch-src_torrent_data_transfer_list_cc	11 Mar 2022 19:46:17 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-Index: src/torrent/data/transfer_list.cc
---- src/torrent/data/transfer_list.cc.orig
-+++ src/torrent/data/transfer_list.cc
-@@ -159,7 +159,7 @@ TransferList::hash_succeeded(uint32_t index, Chunk* ch
- struct transfer_list_compare_data {
-   transfer_list_compare_data(Chunk* chunk, const Piece& p) : m_chunk(chunk), m_piece(p) { }
- 
--  bool operator () (const BlockFailed::reference failed) {
-+  bool operator () (BlockFailed::reference failed) {
-     return m_chunk->compare_buffer(failed.first, m_piece.offset(), m_piece.length());
-   }
- 
Index: net/libtorrent/patches/patch-src_torrent_download_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_download_cc
diff -N net/libtorrent/patches/patch-src_torrent_download_cc
--- net/libtorrent/patches/patch-src_torrent_download_cc	11 Mar 2022 19:46:17 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,24 +0,0 @@
-Index: src/torrent/download.cc
---- src/torrent/download.cc.orig
-+++ src/torrent/download.cc
-@@ -72,6 +72,20 @@
- 
- namespace torrent {
- 
-+const int DownloadInfo::flag_open LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_active LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_compact LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_accepting_new_peers LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_accepting_seeders LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_private LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_meta_download LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_pex_enabled LIBTORRENT_EXPORT;
-+const int DownloadInfo::flag_pex_active LIBTORRENT_EXPORT;
-+
-+const int DownloadInfo::public_flags;
-+
-+const uint32_t DownloadInfo::unlimited;
-+
- const DownloadInfo* Download::info() const { return m_ptr->info(); }
- const download_data* Download::data() const { return m_ptr->data(); }
- 
Index: net/libtorrent/patches/patch-src_torrent_object_stream_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_object_stream_cc
diff -N net/libtorrent/patches/patch-src_torrent_object_stream_cc
--- net/libtorrent/patches/patch-src_torrent_object_stream_cc	11 Mar 2022 19:46:17 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,15 +0,0 @@
-# https://github.com/rakshasa/libtorrent/pull/99/files
-
-Index: src/torrent/object_stream.cc
---- src/torrent/object_stream.cc.orig	2015-08-08 17:01:32.000000000 +0200
-+++ src/torrent/object_stream.cc	2017-12-02 01:46:38.523350000 +0100
-@@ -104,7 +104,8 @@
-   while (first != last && *first >= '0' && *first <= '9')
-     length = length * 10 + (*first++ - '0');
- 
--  if (length + 1 > (unsigned int)std::distance(first, last) || *first++ != ':')
-+  if (length + 1 > (unsigned int)std::distance(first, last) || *first++ != ':'
-+		  || length + 1 == 0)
-     throw torrent::bencode_error("Invalid bencode data.");
-   
-   return raw_string(first, length);
Index: net/libtorrent/patches/patch-src_torrent_peer_connection_list_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_peer_connection_list_cc
diff -N net/libtorrent/patches/patch-src_torrent_peer_connection_list_cc
--- net/libtorrent/patches/patch-src_torrent_peer_connection_list_cc	11 Mar 2022 19:46:17 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,15 +0,0 @@
-Index: src/torrent/peer/connection_list.cc
---- src/torrent/peer/connection_list.cc.orig
-+++ src/torrent/peer/connection_list.cc
-@@ -60,6 +60,11 @@
- 
- namespace torrent {
- 
-+const int ConnectionList::disconnect_available;
-+const int ConnectionList::disconnect_quick;
-+const int ConnectionList::disconnect_unwanted;
-+const int ConnectionList::disconnect_delayed;
-+
- ConnectionList::ConnectionList(DownloadMain* download) :
-   m_download(download), m_minSize(50), m_maxSize(100) {
- }
Index: net/libtorrent/patches/patch-src_torrent_poll_kqueue_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_poll_kqueue_cc
diff -N net/libtorrent/patches/patch-src_torrent_poll_kqueue_cc
--- net/libtorrent/patches/patch-src_torrent_poll_kqueue_cc	11 Mar 2022 19:46:17 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,33 +0,0 @@
-Fix a crash when total number of connections exceeds 1024.
-
-The number of events is used to index an array of maxOpenSockets
-(file descriptors) elements. If there are fewer fds than maxEvents,
-this will cause a segfault.
-Limit the number of events to the number of fds with an upper limit of
-maxEvents.
-
---- src/torrent/poll_kqueue.cc.orig	Tue May  6 03:22:57 2014
-+++ src/torrent/poll_kqueue.cc	Tue Mar 24 03:43:10 2015
-@@ -37,6 +37,7 @@
- #include "config.h"
- 
- #include <cerrno>
-+#include <cassert>
- 
- #include <algorithm>
- #include <unistd.h>
-@@ -121,12 +122,12 @@ PollKQueue::create(int maxOpenSockets) {
-   if (fd == -1)
-     return NULL;
- 
--  return new PollKQueue(fd, 1024, maxOpenSockets);
-+  return new PollKQueue(fd, 16384, maxOpenSockets);
- }
- 
- PollKQueue::PollKQueue(int fd, int maxEvents, int maxOpenSockets) :
-   m_fd(fd),
--  m_maxEvents(maxEvents),
-+  m_maxEvents((maxOpenSockets < maxEvents) ? maxOpenSockets : maxEvents),
-   m_waitingEvents(0),
-   m_changedEvents(0),
-   m_stdinEvent(NULL) {
Index: net/libtorrent/patches/patch-src_torrent_utils_extents_h
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_utils_extents_h
diff -N net/libtorrent/patches/patch-src_torrent_utils_extents_h
--- net/libtorrent/patches/patch-src_torrent_utils_extents_h	11 Mar 2022 19:46:17 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,17 +0,0 @@
-assign/fill difference, see header
-
-Index: src/torrent/utils/extents.h
---- src/torrent/utils/extents.h.orig
-+++ src/torrent/utils/extents.h
-@@ -51,9 +51,9 @@ struct extents_base {
-   typedef std::array<mapped_type, TableSize> table_type;
-   
-   extents_base(key_type pos, unsigned int mb, mapped_value_type val) :
--    mask_bits(mb), position(pos) { table.assign(mapped_type(NULL, mapped_value_type())); }
-+    mask_bits(mb), position(pos) { fill_with_value(table, mapped_type(NULL, mapped_value_type())); }
-   extents_base(extents_base* parent, typename table_type::const_iterator itr) :
--    mask_bits(parent->mask_bits - TableBits), position(parent->partition_pos(itr)) { table.assign(mapped_type(NULL, itr->second)); }
-+    mask_bits(parent->mask_bits - TableBits), position(parent->partition_pos(itr)) { fill_with_value(table, mapped_type(NULL, itr->second)); }
-   ~extents_base();
- 
-   bool         is_divisible(key_type key) const { return key % mask_bits == 0; }
Index: net/libtorrent/patches/patch-src_torrent_utils_log_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_utils_log_cc
diff -N net/libtorrent/patches/patch-src_torrent_utils_log_cc
--- net/libtorrent/patches/patch-src_torrent_utils_log_cc	11 Mar 2022 19:46:17 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,39 +0,0 @@
-can't figure out the functional magic, so just do the algorithm by hand.
-
-Index: src/torrent/utils/log.cc
---- src/torrent/utils/log.cc.orig
-+++ src/torrent/utils/log.cc
-@@ -187,17 +187,14 @@ log_group::internal_print(const HashString* hash, cons
-     return;
- 
-   pthread_mutex_lock(&log_mutex);
--  std::for_each(m_first, m_last, std::bind(&log_slot::operator(),
--                                                std::placeholders::_1,
--                                                buffer,
--                                                std::distance(buffer, first),
--                                                std::distance(log_groups.begin(), this)));
-+
-+  for (log_slot *it = m_first; it != m_last; ++it)
-+  	(*it)(buffer, std::distance(buffer, first),
-+		std::distance(log_groups.begin(), this));
-+
-   if (dump_data != NULL)
--    std::for_each(m_first, m_last, std::bind(&log_slot::operator(),
--                                                  std::placeholders::_1,
--                                                  (const char*)dump_data,
--                                                  dump_size,
--                                                  -1));
-+      for (log_slot *it = m_first; it != m_last; ++it)
-+      	(*it)((const char*)dump_data, dump_size, -1);
-   pthread_mutex_unlock(&log_mutex);
- }
- 
-@@ -250,7 +247,7 @@ void
- log_cleanup() {
-   pthread_mutex_lock(&log_mutex);
- 
--  log_groups.assign(log_group());
-+  fill_with_value(log_groups, log_group());
-   log_outputs.clear();
-   log_children.clear();
- 
Index: net/libtorrent/patches/patch-src_torrent_utils_net_h
===================================================================
RCS file: net/libtorrent/patches/patch-src_torrent_utils_net_h
diff -N net/libtorrent/patches/patch-src_torrent_utils_net_h
--- net/libtorrent/patches/patch-src_torrent_utils_net_h	11 Mar 2022 19:46:17 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
-Add missing include.
-
-Index: src/torrent/utils/net.h
---- src/torrent/utils/net.h.orig
-+++ src/torrent/utils/net.h
-@@ -37,6 +37,7 @@
- #ifndef LIBTORRENT_UTILS_NET_H
- #define LIBTORRENT_UTILS_NET_H
- 
-+#include <sys/socket.h>
- #include <netdb.h>
- #include <functional>
- 
Index: net/libtorrent/patches/patch-src_utils_diffie_hellman_cc
===================================================================
RCS file: net/libtorrent/patches/patch-src_utils_diffie_hellman_cc
diff -N net/libtorrent/patches/patch-src_utils_diffie_hellman_cc
--- net/libtorrent/patches/patch-src_utils_diffie_hellman_cc	11 Mar 2022 19:46:17 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,39 +0,0 @@
-Fix build with opaque DH in LibreSSL 3.5.
-
-Index: src/utils/diffie_hellman.cc
---- src/utils/diffie_hellman.cc.orig
-+++ src/utils/diffie_hellman.cc
-@@ -53,9 +53,11 @@ DiffieHellman::DiffieHellman(const unsigned char *prim
-   m_secret(NULL), m_size(0) {
- 
- #ifdef USE_OPENSSL
-+  BIGNUM *p, *g;
-   m_dh = DH_new();
--  m_dh->p = BN_bin2bn(prime, primeLength, NULL);
--  m_dh->g = BN_bin2bn(generator, generatorLength, NULL);
-+  p = BN_bin2bn(prime, primeLength, NULL);
-+  g = BN_bin2bn(generator, generatorLength, NULL);
-+  DH_set0_pqg(m_dh, p, NULL, g);
- 
-   DH_generate_key(m_dh);
- #else
-@@ -73,7 +75,7 @@ DiffieHellman::~DiffieHellman() {
- bool
- DiffieHellman::is_valid() const {
- #ifdef USE_OPENSSL
--  return m_dh != NULL && m_dh->pub_key != NULL;
-+  return m_dh != NULL && DH_get0_pub_key(m_dh) != NULL;
- #else
-   return false;
- #endif
-@@ -102,8 +104,8 @@ DiffieHellman::store_pub_key(unsigned char* dest, unsi
- #ifdef USE_OPENSSL
-   std::memset(dest, 0, length);
- 
--  if ((int)length >= BN_num_bytes(m_dh->pub_key))
--    BN_bn2bin(m_dh->pub_key, dest + length - BN_num_bytes(m_dh->pub_key));
-+  if ((int)length >= BN_num_bytes(DH_get0_pub_key(m_dh)))
-+    BN_bn2bin(DH_get0_pub_key(m_dh), dest + length - BN_num_bytes(DH_get0_pub_key(m_dh)));
- #endif
- }
- 
Index: net/libtorrent/patches/patch-src_utils_instrumentation_h
===================================================================
RCS file: net/libtorrent/patches/patch-src_utils_instrumentation_h
diff -N net/libtorrent/patches/patch-src_utils_instrumentation_h
--- net/libtorrent/patches/patch-src_utils_instrumentation_h	11 Mar 2022 19:46:17 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-tr1/std  difference, see header
-
-Index: src/utils/instrumentation.h
---- src/utils/instrumentation.h.orig
-+++ src/utils/instrumentation.h
-@@ -118,7 +118,7 @@ void instrumentation_reset();
- 
- inline void
- instrumentation_initialize() {
--  instrumentation_values.assign(int64_t());
-+  fill_with_value(instrumentation_values, int64_t());
- }
- 
- inline void
Index: net/libtorrent/patches/patch-src_utils_queue_buckets_h
===================================================================
RCS file: net/libtorrent/patches/patch-src_utils_queue_buckets_h
diff -N net/libtorrent/patches/patch-src_utils_queue_buckets_h
--- net/libtorrent/patches/patch-src_utils_queue_buckets_h	11 Mar 2022 19:46:17 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-proper typing, from FreeBSD
-
-Index: src/utils/queue_buckets.h
---- src/utils/queue_buckets.h.orig
-+++ src/utils/queue_buckets.h
-@@ -251,7 +251,7 @@ queue_buckets<Type, Constants>::destroy(int idx, itera
-   instrumentation_update(constants::instrumentation_total[idx], -difference);
- 
-   // Consider moving these to a temporary dequeue before releasing:
--  std::for_each(begin, end, std::function<void (value_type)>(&constants::template destroy<value_type>));
-+  std::for_each(begin, end, std::function<void (value_type&)>(&constants::template destroy<value_type>));
-   queue_at(idx).erase(begin, end);
- }
- 
Index: net/libtorrent/patches/patch-test_Makefile_in
===================================================================
RCS file: net/libtorrent/patches/patch-test_Makefile_in
diff -N net/libtorrent/patches/patch-test_Makefile_in
--- net/libtorrent/patches/patch-test_Makefile_in	11 Mar 2022 19:46:17 -0000	1.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
---- test/Makefile.in.orig	Thu Sep 10 20:12:55 2015
-+++ test/Makefile.in	Thu Sep 10 20:13:00 2015
-@@ -644,7 +644,7 @@ LibTorrentTest_SOURCES = \
- 	main.cc
- 
- LibTorrentTest_CXXFLAGS = $(CPPUNIT_CFLAGS)
--LibTorrentTest_LDFLAGS = $(CPPUNIT_LIBS)  -ldl
-+LibTorrentTest_LDFLAGS = $(CPPUNIT_LIBS)
- AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/src
- all: all-am
- 
Index: net/libtorrent/pkg/PLIST
===================================================================
RCS file: /home/cvs/ports/net/libtorrent/pkg/PLIST,v
diff -u -p -r1.15 PLIST
--- net/libtorrent/pkg/PLIST	11 Mar 2022 19:46:17 -0000	1.15
+++ net/libtorrent/pkg/PLIST	9 Nov 2024 17:38:28 -0000
@@ -30,6 +30,14 @@ include/torrent/event.h
 include/torrent/exceptions.h
 include/torrent/hash_string.h
 include/torrent/http.h
+include/torrent/net/
+include/torrent/net/address_info.h
+include/torrent/net/fd.h
+include/torrent/net/socket_address.h
+include/torrent/net/socket_address_key.h
+include/torrent/net/socket_event.h
+include/torrent/net/types.h
+include/torrent/net/utils.h
 include/torrent/object.h
 include/torrent/object_raw_bencode.h
 include/torrent/object_static_map.h
@@ -54,16 +62,17 @@ include/torrent/tracker.h
 include/torrent/tracker_controller.h
 include/torrent/tracker_list.h
 include/torrent/utils/
+include/torrent/utils/directory_events.h
 include/torrent/utils/extents.h
 include/torrent/utils/log.h
 include/torrent/utils/log_buffer.h
-include/torrent/utils/net.h
 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_interrupt.h
+include/torrent/utils/uri_parser.h
 @static-lib lib/libtorrent.a
 lib/libtorrent.la
 @lib lib/libtorrent.so.${LIBtorrent_VERSION}
Index: net/rtorrent/Makefile
===================================================================
RCS file: /home/cvs/ports/net/rtorrent/Makefile,v
diff -u -p -r1.71 Makefile
--- net/rtorrent/Makefile	27 Sep 2023 14:18:31 -0000	1.71
+++ net/rtorrent/Makefile	9 Nov 2024 17:38:28 -0000
@@ -1,7 +1,6 @@
 COMMENT=		ncurses BitTorrent client based on libTorrent
 
-DISTNAME=		rtorrent-0.9.6
-REVISION=		8
+DISTNAME=		rtorrent-0.10.0
 EPOCH=			0
 CATEGORIES=		net
 
@@ -13,33 +12,28 @@ PERMIT_PACKAGE=	Yes
 WANTLIB += ${COMPILER_LIBCXX} c crypto curl curses m nghttp2 pthread
 WANTLIB += ssl torrent>=21 z
 
-COMPILER =		base-clang ports-gcc base-gcc
+COMPILER =		base-clang ports-gcc
 
-SITES=			https://rtorrent.net/downloads/
+SITES=			https://github.com/rakshasa/rtorrent-archive/raw/master/
 
 BUILD_DEPENDS=		devel/cppunit
 LIB_DEPENDS=		net/libtorrent>=0.13.4 \
 			net/curl
 
 CONFIGURE_STYLE=	autoconf
-AUTOCONF_VERSION=	2.69
-CONFIGURE_ENV +=	LDFLAGS=-pthread
+AUTOCONF_VERSION=	2.71
+CONFIGURE_ENV +=	LDFLAGS="-pthread -lexecinfo"
 CONFIGURE_ARGS=		--disable-debug
 
 DEBUG_PACKAGES =	${BUILD_PACKAGES}
 
-CXXFLAGS +=		-std=c++11
+# uses std::bind2nd which was removed in c++17
+CXXFLAGS +=		-std=c++14
 
 post-install:
 	${INSTALL_DATA_DIR} ${PREFIX}/share/doc/rtorrent
 	${INSTALL_DATA_DIR} ${PREFIX}/share/examples/rtorrent
 	${INSTALL_DATA} ${WRKSRC}/doc/rtorrent.rc \
 		${PREFIX}/share/examples/rtorrent/rtorrent.rc
-
-# this patches *only* files containing tr1 to no longer refer to tr1
-# we do it pre-patch, because autoconf passes right after us
-pre-patch:
-	find ${WRKDIST} -type f -exec fgrep -lw tr1 {} + | \
-		xargs sed -i.bak -e 's,<tr1/,<,' -e 's/std::tr1/std/g' -e 's/tr1::placeholders::/std::placeholders::/g' -e 's/tr1::bind/std::bind/g'
 
 .include <bsd.port.mk>
Index: net/rtorrent/distinfo
===================================================================
RCS file: /home/cvs/ports/net/rtorrent/distinfo,v
diff -u -p -r1.20 distinfo
--- net/rtorrent/distinfo	11 Sep 2015 09:16:03 -0000	1.20
+++ net/rtorrent/distinfo	9 Nov 2024 17:38:28 -0000
@@ -1,2 +1,2 @@
-SHA256 (rtorrent-0.9.6.tar.gz) = HmnCTx8m+PB9WNZzSA3Dkr/EMXgYwRFSZbCKeBP/Ww4=
-SIZE (rtorrent-0.9.6.tar.gz) = 610845
+SHA256 (rtorrent-0.10.0.tar.gz) = zGW7p6vq0kFR8QrxFuyiNCsMMg/f88uNYEwK8JIV06o=
+SIZE (rtorrent-0.10.0.tar.gz) = 402931
Index: net/rtorrent/patches/patch-src_core_manager_cc
===================================================================
RCS file: net/rtorrent/patches/patch-src_core_manager_cc
diff -N net/rtorrent/patches/patch-src_core_manager_cc
--- net/rtorrent/patches/patch-src_core_manager_cc	11 Mar 2022 19:47:22 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,15 +0,0 @@
-Index: src/core/manager.cc
---- src/core/manager.cc.orig
-+++ src/core/manager.cc
-@@ -74,6 +74,11 @@
- 
- namespace core {
- 
-+const int Manager::create_start;
-+const int Manager::create_tied;
-+const int Manager::create_quiet;
-+const int Manager::create_raw_data;
-+
- void
- Manager::push_log(const char* msg) {
-   m_log_important->lock_and_push_log(msg, strlen(msg), 0);
Index: net/rtorrent/patches/patch-src_core_poll_manager_cc
===================================================================
RCS file: net/rtorrent/patches/patch-src_core_poll_manager_cc
diff -N net/rtorrent/patches/patch-src_core_poll_manager_cc
--- net/rtorrent/patches/patch-src_core_poll_manager_cc	11 Mar 2022 19:47:22 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
-Index: src/core/poll_manager.cc
---- src/core/poll_manager.cc.orig
-+++ src/core/poll_manager.cc
-@@ -38,6 +38,7 @@
- 
- #include <stdexcept>
- #include <unistd.h>
-+#include <sys/select.h>
- #include <torrent/exceptions.h>
- #include <torrent/poll_epoll.h>
- #include <torrent/poll_kqueue.h>
Index: net/rtorrent/patches/patch-src_display_window_file_list_cc
===================================================================
RCS file: net/rtorrent/patches/patch-src_display_window_file_list_cc
diff -N net/rtorrent/patches/patch-src_display_window_file_list_cc
--- net/rtorrent/patches/patch-src_display_window_file_list_cc	11 Mar 2022 19:47:22 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
-Index: src/display/window_file_list.cc
---- src/display/window_file_list.cc.orig
-+++ src/display/window_file_list.cc
-@@ -41,6 +41,7 @@
- #include <torrent/data/file.h>
- #include <torrent/data/file_list.h>
- #include <torrent/data/file_list_iterator.h>
-+#include <locale>
- 
- #include "core/download.h"
- #include "ui/element_file_list.h"
Index: net/rtorrent/patches/patch-src_rpc_exec_file_cc
===================================================================
RCS file: net/rtorrent/patches/patch-src_rpc_exec_file_cc
diff -N net/rtorrent/patches/patch-src_rpc_exec_file_cc
--- net/rtorrent/patches/patch-src_rpc_exec_file_cc	11 Mar 2022 19:47:22 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,18 +0,0 @@
-Index: src/rpc/exec_file.cc
---- src/rpc/exec_file.cc.orig
-+++ src/rpc/exec_file.cc
-@@ -52,6 +52,14 @@ namespace rpc {
- 
- // Close m_logFd.
- 
-+const unsigned int ExecFile::max_args;
-+const unsigned int ExecFile::buffer_size;
-+
-+const int ExecFile::flag_expand_tilde;
-+const int ExecFile::flag_throw;
-+const int ExecFile::flag_capture;
-+const int ExecFile::flag_background;
-+
- int
- ExecFile::execute(const char* file, char* const* argv, int flags) {
-   // Write the execued command and its parameters to the log fd.
Index: net/rtorrent/patches/patch-src_rpc_object_storage_cc
===================================================================
RCS file: net/rtorrent/patches/patch-src_rpc_object_storage_cc
diff -N net/rtorrent/patches/patch-src_rpc_object_storage_cc
--- net/rtorrent/patches/patch-src_rpc_object_storage_cc	11 Mar 2022 19:47:22 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,27 +0,0 @@
-Index: src/rpc/object_storage.cc
---- src/rpc/object_storage.cc.orig
-+++ src/rpc/object_storage.cc
-@@ -44,6 +44,23 @@
- 
- namespace rpc {
- 
-+const unsigned int object_storage::flag_generic_type;
-+const unsigned int object_storage::flag_bool_type;
-+const unsigned int object_storage::flag_value_type;
-+const unsigned int object_storage::flag_string_type;
-+const unsigned int object_storage::flag_list_type;
-+const unsigned int object_storage::flag_function_type;
-+const unsigned int object_storage::flag_multi_type;
-+
-+const unsigned int object_storage::mask_type;
-+
-+const unsigned int object_storage::flag_constant;
-+const unsigned int object_storage::flag_static;
-+const unsigned int object_storage::flag_private;
-+const unsigned int object_storage::flag_rlookup;
-+
-+const size_t object_storage::key_size;
-+
- object_storage::local_iterator
- object_storage::find_local(const torrent::raw_string& key) {
-   std::size_t n = hash_fixed_key_type::hash(key.data(), key.size()) % bucket_count();
Index: net/rtorrent/patches/patch-src_signal_handler_cc
===================================================================
RCS file: net/rtorrent/patches/patch-src_signal_handler_cc
diff -N net/rtorrent/patches/patch-src_signal_handler_cc
--- net/rtorrent/patches/patch-src_signal_handler_cc	11 Mar 2022 19:47:22 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
-Index: src/signal_handler.cc
---- src/signal_handler.cc.orig
-+++ src/signal_handler.cc
-@@ -38,6 +38,7 @@
- 
- #include <signal.h>
- #include <stdexcept>
-+#include <string>
- #include "rak/error_number.h"
- #include "signal_handler.h"
- 
Index: net/rtorrent/patches/patch-test_Makefile_in
===================================================================
RCS file: net/rtorrent/patches/patch-test_Makefile_in
diff -N net/rtorrent/patches/patch-test_Makefile_in
--- net/rtorrent/patches/patch-test_Makefile_in	11 Mar 2022 19:47:22 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
-Unbreak build.
-
---- test/Makefile.in.orig	Thu Sep 10 20:20:28 2015
-+++ test/Makefile.in	Thu Sep 10 20:20:33 2015
-@@ -561,7 +561,7 @@ rtorrentTest_SOURCES = \
- 	main.cc
- 
- rtorrentTest_CXXFLAGS = $(CPPUNIT_CFLAGS)
--rtorrentTest_LDFLAGS = $(CPPUNIT_LIBS)  -ldl
-+rtorrentTest_LDFLAGS = $(CPPUNIT_LIBS)
- AM_CPPFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/src
- all: all-am
- 

-- 
jca