Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test merge #7744

Merged
merged 18 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@

2.0.11 not released

* limit piece size in torrent creator
* fix file pre-allocation when changing file priority (HanabishiRecca)
* fix uTP issue where closing the connection could corrupt the payload
* apply DSCP/TOS to sockets before initiating the TCP connection
* assume copy_file_range() exists on linux (unless old glibc)
* fix issue where set_piece_deadline() did not correctly post read_piece_alert
* fix integer overflow in piece picker
* torrent_status::num_pieces counts pieces passed hash check, as documented
* check settings_pack::max_out_request_queue before performance alert

2.0.10 released

Expand Down Expand Up @@ -182,7 +187,7 @@
2.0 released

* dropped dependency on iconv
* deprecate set_file_hash() in torrent creator, as it's superceded by v2 torrents
* deprecate set_file_hash() in torrent creator, as it's superseded by v2 torrents
* deprecate mutable access to info_section in torrent_info
* removed deprecated lazy_entry/lazy_bdecode
* stats_alert deprecated
Expand Down
2 changes: 1 addition & 1 deletion Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ rule linking ( properties * )
else if [ version.version-less $(jam-version) : 1990 0 ]
{
# the visibility feature was introduced in boost-1.69. This was close to
# when the verisoning scheme changed from year to (low) version numbers.
# when the versioning scheme changed from year to (low) version numbers.
# in boost-1.70
result += <visibility>hidden ;
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ feature.compose <libtorrent-python-pic>on : <cxxflags>-fPIC ;
feature python-install-path : : free path ;

# when not specifying a custom install path, this controls whether to install
# the python module in the system directory or user-specifc directory
# the python module in the system directory or user-specific directory
feature python-install-scope : user system : ;

feature auto-ptr : off on : composite propagated ;
Expand Down
20 changes: 10 additions & 10 deletions bindings/python/libtorrent/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -854,21 +854,21 @@ class listen_on_flags_t(int):
names: Mapping[str, listen_on_flags_t]
values: Mapping[int, listen_on_flags_t]

class listen_succeded_alert_socket_type_t(int):
i2p: listen_succeded_alert_socket_type_t
names: Mapping[str, listen_succeded_alert_socket_type_t]
socks5: listen_succeded_alert_socket_type_t
tcp: listen_succeded_alert_socket_type_t
tcp_ssl: listen_succeded_alert_socket_type_t
udp: listen_succeded_alert_socket_type_t
utp_ssl: listen_succeded_alert_socket_type_t
values: Mapping[int, listen_succeded_alert_socket_type_t]
class listen_succeeded_alert_socket_type_t(int):
i2p: listen_succeeded_alert_socket_type_t
names: Mapping[str, listen_succeeded_alert_socket_type_t]
socks5: listen_succeeded_alert_socket_type_t
tcp: listen_succeeded_alert_socket_type_t
tcp_ssl: listen_succeeded_alert_socket_type_t
udp: listen_succeeded_alert_socket_type_t
utp_ssl: listen_succeeded_alert_socket_type_t
values: Mapping[int, listen_succeeded_alert_socket_type_t]

class listen_succeeded_alert(alert):
address: str
endpoint: Tuple[str, int]
port: int
sock_type: listen_succeded_alert_socket_type_t
sock_type: listen_succeeded_alert_socket_type_t
socket_type: socket_type_t

class log_alert(alert):
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ void bind_alert()
;

#if TORRENT_ABI_VERSION == 1
enum_<listen_succeeded_alert::socket_type_t>("listen_succeded_alert_socket_type_t")
enum_<listen_succeeded_alert::socket_type_t>("listen_succeeded_alert_socket_type_t")
.value("tcp", listen_succeeded_alert::socket_type_t::tcp)
.value("tcp_ssl", listen_succeeded_alert::socket_type_t::tcp_ssl)
.value("udp", listen_succeeded_alert::socket_type_t::udp)
Expand Down
30 changes: 15 additions & 15 deletions bindings/python/tests/alert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,35 +144,35 @@ def test_operation_name(self) -> None:
continue
self.assertIsInstance(lt.operation_name(value), str)

def test_listen_succeded_alert_socket_type_t(self) -> None:
def test_listen_succeeded_alert_socket_type_t(self) -> None:
if lt.api_version < 2:
self.assertIsInstance(lt.listen_succeded_alert_socket_type_t.tcp, int)
self.assertIsInstance(lt.listen_succeded_alert_socket_type_t.tcp_ssl, int)
self.assertIsInstance(lt.listen_succeded_alert_socket_type_t.udp, int)
self.assertIsInstance(lt.listen_succeded_alert_socket_type_t.i2p, int)
self.assertIsInstance(lt.listen_succeded_alert_socket_type_t.socks5, int)
self.assertIsInstance(lt.listen_succeded_alert_socket_type_t.utp_ssl, int)
self.assertIsInstance(lt.listen_succeeded_alert_socket_type_t.tcp, int)
self.assertIsInstance(lt.listen_succeeded_alert_socket_type_t.tcp_ssl, int)
self.assertIsInstance(lt.listen_succeeded_alert_socket_type_t.udp, int)
self.assertIsInstance(lt.listen_succeeded_alert_socket_type_t.i2p, int)
self.assertIsInstance(lt.listen_succeeded_alert_socket_type_t.socks5, int)
self.assertIsInstance(lt.listen_succeeded_alert_socket_type_t.utp_ssl, int)

@unittest.skip("https://github.com/arvidn/libtorrent/issues/5967")
def test_listen_succeded_alert_socket_type_t_deprecated(self) -> None:
def test_listen_succeeded_alert_socket_type_t_deprecated(self) -> None:
if lt.api_version < 2:
with self.assertWarns(DeprecationWarning):
self.assertIsInstance(lt.listen_succeded_alert_socket_type_t.tcp, int)
self.assertIsInstance(lt.listen_succeeded_alert_socket_type_t.tcp, int)
with self.assertWarns(DeprecationWarning):
self.assertIsInstance(
lt.listen_succeded_alert_socket_type_t.tcp_ssl, int
lt.listen_succeeded_alert_socket_type_t.tcp_ssl, int
)
with self.assertWarns(DeprecationWarning):
self.assertIsInstance(lt.listen_succeded_alert_socket_type_t.udp, int)
self.assertIsInstance(lt.listen_succeeded_alert_socket_type_t.udp, int)
with self.assertWarns(DeprecationWarning):
self.assertIsInstance(lt.listen_succeded_alert_socket_type_t.i2p, int)
self.assertIsInstance(lt.listen_succeeded_alert_socket_type_t.i2p, int)
with self.assertWarns(DeprecationWarning):
self.assertIsInstance(
lt.listen_succeded_alert_socket_type_t.socks5, int
lt.listen_succeeded_alert_socket_type_t.socks5, int
)
with self.assertWarns(DeprecationWarning):
self.assertIsInstance(
lt.listen_succeded_alert_socket_type_t.utp_ssl, int
lt.listen_succeeded_alert_socket_type_t.utp_ssl, int
)

def test_listen_failed_alert_socket_type_t(self) -> None:
Expand Down Expand Up @@ -1283,7 +1283,7 @@ def test_listen_succeeded_alert(self) -> None:
if lt.api_version < 2:
self.assertEqual(alert.endpoint, ("127.0.0.1", self.session.listen_port()))
self.assertIsInstance(
alert.sock_type, lt.listen_succeded_alert_socket_type_t
alert.sock_type, lt.listen_succeeded_alert_socket_type_t
)
self.assertEqual(alert.address, "127.0.0.1")
self.assertEqual(alert.port, self.session.listen_port())
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/LibtorrentMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endmacro()
# target_optional_compile_definitions(<target> [FEATURE]
# NAME <name> DESCRIPTION <description> DEFAULT <default_value>
# [ENABLED [enabled_compile_definitions...]]
# [DISABLED [disabled_compile_defnitions...]]
# [DISABLED [disabled_compile_definitions...]]
# )
# NAME, DESCRIPTION and DEFAULT are passed to option() call
# if FEATURE is given, they are passed to add_feature_info()
Expand Down
2 changes: 1 addition & 1 deletion examples/connection_tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void generate_block(span<std::uint32_t> buffer, piece_index_t const piece
for (auto& w : buffer) w = fill;
}

// in order to circumvent the restricton of only
// in order to circumvent the restriction of only
// one connection per IP that most clients implement
// all sockets created by this tester are bound to
// unique local IPs in the range (127.0.0.1 - 127.255.255.255)
Expand Down
2 changes: 1 addition & 1 deletion include/libtorrent/aux_/hash_picker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ namespace libtorrent::aux

// this is for a future per-block request feature
#if 0
// blocks are only added to this list if there is a time critial block which
// blocks are only added to this list if there is a time critical block which
// has been downloaded but we don't have its hash or if the initial request
// for the hash was rejected
// this block hash will be requested from every peer possible until the hash
Expand Down
2 changes: 1 addition & 1 deletion include/libtorrent/aux_/merkle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace libtorrent {
// if we're inserting the hash N, the uncle hashes provide proof of it being
// valid by containing 0, 1 and two (as marked in the tree above)
// Any non-zero hash encountered in target_tree is assumed to be valid, and
// will termiate the validation early, either successful (if there's a
// will terminate the validation early, either successful (if there's a
// match) or unsuccessful (if there's a mismatch).
TORRENT_EXTRA_EXPORT
bool merkle_validate_and_insert_proofs(span<sha256_hash> target_tree
Expand Down
2 changes: 1 addition & 1 deletion include/libtorrent/aux_/peer_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ namespace libtorrent::aux {
int max_out_request_queue() const;

std::time_t last_seen_complete() const { return m_last_seen_complete; }
void set_last_seen_complete(int ago) { m_last_seen_complete = ::time(nullptr) - ago; }
void set_last_seen_complete(int ago) { m_last_seen_complete = aux::posix_time() - ago; }

std::int64_t uploaded_in_last_round() const
{ return m_statistics.total_payload_upload() - m_uploaded_at_last_round; }
Expand Down
3 changes: 2 additions & 1 deletion include/libtorrent/aux_/posix_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ namespace aux {
, storage_error& error);

bool has_any_file(storage_error& error);
void set_file_priority(aux::vector<download_priority_t, file_index_t>& prio
void set_file_priority(settings_interface const&
, aux::vector<download_priority_t, file_index_t>& prio
, storage_error& ec);
bool verify_resume_data(add_torrent_params const& rd
, aux::vector<std::string, file_index_t> const& links
Expand Down
3 changes: 3 additions & 0 deletions include/libtorrent/aux_/time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace libtorrent { namespace aux {

TORRENT_EXTRA_EXPORT std::time_t to_time_t(time_point32 tp);
TORRENT_EXTRA_EXPORT time_point32 from_time_t(std::time_t t);

// returns the current posix time (UTC)
TORRENT_EXTRA_EXPORT time_t posix_time();
} }

#endif
4 changes: 2 additions & 2 deletions include/libtorrent/aux_/torrent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,8 @@ namespace libtorrent::aux {

void write_resume_data(resume_data_flags_t const flags, add_torrent_params& ret) const;

void seen_complete() { m_last_seen_complete = ::time(nullptr); }
int time_since_complete() const { return int(::time(nullptr) - m_last_seen_complete); }
void seen_complete() { m_last_seen_complete = aux::posix_time(); }
int time_since_complete() const { return int(aux::posix_time() - m_last_seen_complete); }
time_t last_seen_complete() const { return m_last_seen_complete; }

template <typename Fun, typename... Args>
Expand Down
2 changes: 2 additions & 0 deletions include/libtorrent/create_torrent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ TORRENT_VERSION_NAMESPACE_4
// The ``piece_size`` is the size of each piece in bytes. It must be a
// power of 2 and a minimum of 16 kiB. If a piece size of 0 is
// specified, a piece_size will be set automatically.
// Piece sizes greater than 128 MiB are considered unreasonable and will
// be rejected (with an lt::system_error exception).
//
// The ``flags`` arguments specifies options for the torrent creation. It can
// be any combination of the flags defined by create_flags_t.
Expand Down
33 changes: 23 additions & 10 deletions simulation/setup_swarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ using namespace sim;

#define DEBUG_SWARM 0

#if DEBUG_SWARM
#include <cstdio>
#include "libtorrent/aux_/file_pointer.hpp"
#endif

constexpr swarm_test_t swarm_test::download;
constexpr swarm_test_t swarm_test::upload;
constexpr swarm_test_t swarm_test::no_auto_stop;
Expand Down Expand Up @@ -311,6 +316,12 @@ void setup_swarm(int num_nodes
// line
#if DEBUG_SWARM == 0
if (i != 0) return;
#else
char path[200];
lt::error_code ignore;
lt::create_directory("logs", ignore);
std::snprintf(path, sizeof(path), "logs/node-%d.log", i);
lt::aux::file_pointer log_output(::fopen(path, "a"));
#endif

for (lt::alert* a : alerts)
Expand All @@ -320,25 +331,27 @@ void setup_swarm(int num_nodes
std::uint32_t const millis = std::uint32_t(
lt::duration_cast<lt::milliseconds>(d).count());

#if DEBUG_SWARM != 0
std::fprintf(log_output.file(),
"%4u.%03u: %-25s %s\n"
, millis / 1000, millis % 1000
, a->what()
, a->message().c_str());

// the behavior of the test itself should not be affected by
// whether we're printing logs for all nodes
if (i != 0) continue;
#endif
// when debugging, we print *all* alerts to the log
if (should_print(a))
{
std::printf(
#if DEBUG_SWARM != 0
"[%d] "
#endif
"%4u.%03u: %-25s %s\n"
#if DEBUG_SWARM != 0
, i
#endif
, millis / 1000, millis % 1000
, a->what()
, a->message().c_str());
}

#if DEBUG_SWARM != 0
if (i != 0) continue;
#endif

// if a torrent was added save the torrent handle
if (lt::add_torrent_alert* at = lt::alert_cast<lt::add_torrent_alert>(a))
{
Expand Down
2 changes: 1 addition & 1 deletion simulation/test_web_seed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ TORRENT_TEST(urlseed_timeout)
// check for correct handle of unexpected http status response.
// with disabled "close_redundant_connections" alive web server connection
// may be closed in such manner.
TORRENT_TEST(no_close_redudant_webseed)
TORRENT_TEST(no_close_redundant_webseed)
{
using namespace lt;

Expand Down
11 changes: 9 additions & 2 deletions src/create_torrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ see LICENSE file.
#include "libtorrent/session.hpp" // for default_disk_io_constructor
#include "libtorrent/aux_/directory.hpp"
#include "libtorrent/aux_/bencoder.hpp"
#include "libtorrent/aux_/time.hpp" // for posix_time

#include <sys/types.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -559,7 +560,7 @@ TORRENT_VERSION_NAMESPACE_4
, create_flags_t const flags)
: m_files(std::move(files))
, m_total_size(compute_total_size(m_files))
, m_creation_date(::time(nullptr))
, m_creation_date(aux::posix_time())
, m_multifile(m_files.size() > 1)
, m_private(false)
, m_include_mtime(bool(flags & create_torrent::modification_time))
Expand Down Expand Up @@ -628,6 +629,12 @@ TORRENT_VERSION_NAMESPACE_4
aux::throw_ex<system_error>(errors::invalid_piece_size);
}

// this is an unreasonably large piece size. Some clients don't support
// pieces this large.
if (piece_size > 128 * 1024 * 1024) {
aux::throw_ex<system_error>(errors::invalid_piece_size);
}

m_piece_length = piece_size;
TORRENT_ASSERT(m_piece_length > 0);
if (!(flags & v1_only)
Expand All @@ -644,7 +651,7 @@ TORRENT_VERSION_NAMESPACE_4
, m_piece_length(ti.piece_length())
, m_num_pieces(ti.num_pieces())
, m_name(ti.name())
, m_creation_date(::time(nullptr))
, m_creation_date(aux::posix_time())
, m_multifile(ti.num_files() > 1)
, m_private(ti.priv())
, m_include_mtime(false)
Expand Down
2 changes: 1 addition & 1 deletion src/hash_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool validate_hash_request(hash_request const& hr, file_storage const& fs)
{
// limit the size of the base layer to something reasonable
// Blocks are requested for an entire piece so this limit
// effectivly caps the piece size we can handle. A limit of 8192
// effectively caps the piece size we can handle. A limit of 8192
// corresponds to a piece size of 128MB.

if (hr.file < file_index_t{0}
Expand Down
Loading
Loading