Conversation
Addresses below warning: "Node.js 20 actions are deprecated. The following actions are running on Node.js 20 and may not work as expected: nick-fields/retry@v3."
Otherwise it was installing binary in my case (Windows) to `Installing: /Lib/site-packages/libtorrent.cp313-win_amd64.pyd` which means `"L:\Lib\site-packages\libtorrent.cp313-win_amd64.pyd"` instead of `L:/my/install/prefix/Lib\site-packages\libtorrent.cp313-win_amd64.pyd`
So the vector won't trigger reallocation when adding data.
There was a problem hiding this comment.
Pull request overview
This PR aligns piece/request sizing with v2/hybrid torrent semantics (avoiding pad-file bytes), fixes resume-data merkle tree parsing/round-trips, and tightens some proxy/SSL error handling and CI plumbing.
Changes:
- Introduce and adopt
torrent_info::piece_size_for_req()across request/block computations to avoid requesting v2 pad-space. - Fix v2 resume-data merkle tree/mask/verified vectors to round-trip with consistent per-file sizing (and extend tests accordingly).
- Harden SOCKS5/SSL/proxy helpers and update CI retry action versions.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
test/test_read_resume.cpp |
Extends resume-data round-trip assertions for merkle-related fields and ensures vectors have consistent sizes. |
src/web_peer_connection.cpp |
Adjusts web seed request splitting and range mapping for v2 (pad-space aware). |
src/torrent.cpp |
Switches multiple internal size calculations to piece_size_for_req() and improves vector pre-allocation. |
src/read_resume_data.cpp |
Ensures verified_leaf_hashes / mask vectors are always populated (even if missing) to keep sizes consistent. |
src/peer_connection.cpp |
Updates request validation/accounting to use pad-space-aware piece sizing and centralizes request construction via to_req(). |
src/bt_peer_connection.cpp |
Uses torrent::to_req() for reject handling to keep request sizing consistent. |
include/libtorrent/torrent_info.hpp |
Adds piece_size_for_req() API for correct request sizing in v2/hybrid torrents. |
include/libtorrent/torrent_handle.hpp |
Clarifies docs around v2/hybrid piece sizing and returned buffer lengths. |
include/libtorrent/socks5_stream.hpp |
Makes SOCKS5 version checks strict and adds runtime validation for malformed endpoints. |
include/libtorrent/aux_/ssl_stream.hpp |
Switches to aux::throw_ex and adds defensive m_sock null checks across many operations. |
include/libtorrent/aux_/proxy_base.hpp |
Reorders error handling to close first (avoid potential lifetime/UAF hazards). |
bindings/python/CMakeLists.txt |
Makes the computed platlib install path relative to avoid CMake treating it as absolute. |
ChangeLog |
Adds a 2.0.13 section summarizing the key fixes. |
.github/workflows/windows.yml |
Bumps nick-fields/retry action usage to v4 for simulations. |
.github/workflows/macos.yml |
Bumps nick-fields/retry action usage to v4 for flaky tests. |
.github/workflows/linux.yml |
Bumps nick-fields/retry action usage to v4 for flaky tests. |
Comments suppressed due to low confidence (1)
include/libtorrent/aux_/ssl_stream.hpp:76
set_host_name(name, ec)still dereferencesm_sockviahandle()without checking for a nullm_sock(e.g. a moved-from ssl_stream). Many other methods in this struct now guardm_sockand return/throwbad_file_descriptor; this function should do the same to avoid a null dereference/crash and keep behavior consistent.
void set_host_name(std::string const& name)
{
error_code ec;
set_host_name(name, ec);
if (ec) aux::throw_ex<system_error>(ec);
}
void set_host_name(std::string const& name, error_code& ec)
{
ssl::set_host_name(handle(), name, ec);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!info.v2()) | ||
| m_file_requests.push_back(file_req); |
There was a problem hiding this comment.
In v2 torrents pad-file slices are no longer pushed into m_file_requests, but num_pad_files still counts them. This breaks the pad-file-only fast-path: when the mapped range consists solely of pad files, m_file_requests stays empty, the num_pad_files == m_file_requests.size() check won’t trigger, and an empty HTTP request string will be sent. Consider treating m_file_requests.empty() as the v2 pad-only condition (or keep pushing pad slices even in v2 so the existing accounting works).
| if (!info.v2()) | |
| m_file_requests.push_back(file_req); | |
| m_file_requests.push_back(file_req); |
No description provided.