Skip to content

Commit

Permalink
merged RC_2_0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Feb 17, 2024
2 parents 166f6c5 + 07c62c7 commit 742df3d
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 79 deletions.
16 changes: 8 additions & 8 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
freebsd_instance:
image_family: freebsd-12-1
image_family: freebsd-14-0

task:
install_script: |
Expand Down Expand Up @@ -28,7 +28,7 @@ build_and_store_wheels: &BUILD_AND_STORE_WHEELS
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
install_cibuildwheel_script:
- $PYTHON -m pip install cibuildwheel==2.12.0
- $PYTHON -m pip install cibuildwheel==2.16.3

run_cibuildwheel_script:
- cibuildwheel
Expand All @@ -40,12 +40,12 @@ build_macos_arm64_task:
name: Build macOS arm64 wheels.

macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-xcode
image: ghcr.io/cirruslabs/macos-sonoma-xcode:latest

env:
CIRRUS_CLONE_SUBMODULES: true
CIBW_SKIP: pp* cp38-* # cp38-* has problem with x86_64 / arm64 confusion
CIBW_BUILD: cp39-* cp310-* cp311-*
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-*
CIBW_ARCH: arm64
PATH: /opt/homebrew/bin:$PATH
PYTHON: python3.9
Expand All @@ -64,19 +64,19 @@ test_macos_arm64_task:
name: Test macOS arm64.

macos_instance:
image: ghcr.io/cirruslabs/macos-monterey-xcode
image: ghcr.io/cirruslabs/macos-sonoma-xcode:latest

env:
CIRRUS_CLONE_SUBMODULES: true
PATH: /opt/homebrew/bin:$PATH
PYTHON: python3.9
OPENSSL_OPTS: >
openssl-lib=/opt/homebrew/opt/openssl@1.1/lib
openssl-include=/opt/homebrew/opt/openssl@1.1/include
openssl-lib=/opt/homebrew/opt/openssl@3.0/lib
openssl-include=/opt/homebrew/opt/openssl@3.0/include
install_pre_requirements_script:
- brew install python@3.9
- brew install boost-build boost openssl@1.1
- brew install boost-build boost openssl@3.0
- echo "using darwin ;" >>~/user-config.jam

debug_script:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
- name: install boost
run: |
sudo apt install libboost-tools-dev libboost-dev
echo "using clang_tidy : : clang-tidy \"-checks=-clang-analyzer-core.*,-clang-analyzer-unix.*\" : <cxxflags>-I/usr/local/clang-7.0.0/include/c++/v1 <cxxflags>-stdlib=libc++ <linkflags>-stdlib=libc++ ;" >> ~/user-config.jam;
echo "using clang_tidy : : clang-tidy \"-checks=-clang-analyzer-core.*,-clang-analyzer-unix.*\" : <cxxflags>-I/usr/local/clang-7.0.0/include/c++/v1 <cxxflags>-stdlib=libc++ <cxxflags>-Wno-unknown-warning-option <linkflags>-stdlib=libc++ ;" >> ~/user-config.jam;
- name: analyze
run: |
Expand Down
20 changes: 0 additions & 20 deletions .lgtm.yml

This file was deleted.

12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
#- id: end-of-file-fixer
Expand All @@ -37,7 +37,7 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
exclude: |
Expand All @@ -62,12 +62,12 @@ repos:
tools/update_copyright.py
)$
- repo: https://github.com/PyCQA/autoflake
rev: v2.1.1
rev: v2.2.1
hooks:
- id: autoflake
args: [--in-place, --remove-unused-variables, --remove-all-unused-imports, --remove-duplicate-keys]
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.2.0
hooks:
- id: black
# Avoiding PR bloat
Expand Down Expand Up @@ -107,7 +107,7 @@ repos:
name: black (pyi)
types: [pyi]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.8.0
hooks:
- id: mypy
# Avoiding PR bloat
Expand Down Expand Up @@ -140,7 +140,7 @@ repos:
tools/update_copyright.py
)$
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
exclude: |
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
-Wno-exit-time-destructors
-Wno-weak-vtables
-Wno-return-std-move-in-c++11
-Wno-unsafe-buffer-usage
-Wno-unknown-warning-option
)
elseif(CMAKE_CXX_COMPILER_ID MATCHES GNU)
Expand Down
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* libtorrent now requires C++17 to build
* added support for WebTorrent

* allow on_unknown_torrent method in the absence of active torrents (new plugin feature added)
* fix missing python converter for dht::announce_flags_t

2.0.9 released
Expand Down
4 changes: 4 additions & 0 deletions Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ rule warnings ( properties * )

# libtorrent uses alloca() carefully
result += <cxxflags>-Wno-alloca ;

# these warnings should all be addressed. Either by transitioning to span and
# array, or by suppressing the warning for specific code
result += <cxxflags>-Wno-unsafe-buffer-usage ;
}

if <toolset>gcc in $(properties)
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ TEST_TORRENTS = \
url_seed_multi_space_nolist.torrent \
whitespace_url.torrent \
v2.torrent \
v2_empty_file.torrent \
v2_multipiece_file.torrent \
v2_only.torrent \
v2_invalid_filename.torrent \
Expand Down
3 changes: 2 additions & 1 deletion include/libtorrent/aux_/aligned_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ see LICENSE file.

namespace libtorrent { namespace aux {

#if defined __GNUC__ && __GNUC__ < 5 && !defined(_LIBCPP_VERSION)
#if __cplusplus >= 202302L || defined __GNUC__ && __GNUC__ < 5 && !defined(_LIBCPP_VERSION)

// this is for backwards compatibility with not-quite C++11 compilers
// and for C++23 which deprecated std::aligned_storage
template <std::size_t Len, std::size_t Align = alignof(void*)>
struct aligned_storage
{
Expand Down
6 changes: 4 additions & 2 deletions include/libtorrent/aux_/session_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Copyright (c) 2015-2022, Alden Torres
Copyright (c) 2015, Thomas
Copyright (c) 2016-2017, Pavel Pimenov
Copyright (c) 2020, Paul-Louis Ageneau
Copyright (c) 2023, Joris Carrier
All rights reserved.
You may use, distribute and modify this code under the terms of the BSD license,
Expand Down Expand Up @@ -323,7 +324,8 @@ namespace aux {
plugins_all_idx = 0, // to store all plugins
plugins_optimistic_unchoke_idx = 1, // optimistic_unchoke_feature
plugins_tick_idx = 2, // tick_feature
plugins_dht_request_idx = 3 // dht_request_feature
plugins_dht_request_idx = 3, // dht_request_feature
plugins_unknown_torrent_idx = 4 // unknown_torrent_feature
};

template <typename Fun, typename... Args>
Expand Down Expand Up @@ -1307,7 +1309,7 @@ namespace aux {

#ifndef TORRENT_DISABLE_EXTENSIONS
// this is a list to allow extensions to potentially remove themselves.
std::array<std::vector<std::shared_ptr<plugin>>, 4> m_ses_extensions;
std::array<std::vector<std::shared_ptr<plugin>>, 5> m_ses_extensions;
#endif

#if TORRENT_ABI_VERSION == 1
Expand Down
4 changes: 4 additions & 0 deletions include/libtorrent/extensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ TORRENT_VERSION_NAMESPACE_3
// called
static inline constexpr feature_flags_t alert_feature = 4_bit;

// include this bit if your plugin needs to have on_unknown_torrent()
// called even if there is no active torrent in the session
static inline constexpr feature_flags_t unknown_torrent_feature = 5_bit;

// This function is expected to return a bitmask indicating which features
// this plugin implements. Some callbacks on this object may not be called
// unless the corresponding feature flag is returned here. Note that
Expand Down
2 changes: 1 addition & 1 deletion include/libtorrent/flags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct bit_t
int m_bit_idx;
};

constexpr bit_t operator "" _bit(unsigned long long int b) { return bit_t{static_cast<int>(b)}; }
constexpr bit_t operator ""_bit(unsigned long long int b) { return bit_t{static_cast<int>(b)}; }

namespace flags {

Expand Down
3 changes: 2 additions & 1 deletion include/libtorrent/i2p_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ struct i2p_stream : aux::proxy_base
m_state = read_session_create_response;
char cmd[400];
int size = std::snprintf(cmd, sizeof(cmd),
"SESSION CREATE STYLE=STREAM ID=%s DESTINATION=TRANSIENT SIGNATURE_TYPE=7 "
"SESSION CREATE STYLE=STREAM ID=%s "
"DESTINATION=TRANSIENT SIGNATURE_TYPE=7 i2cp.leaseSetEncType=4,0 "
"inbound.quantity=%d outbound.quantity=%d inbound.length=%d outbound.length=%d\n",
m_id, m_session_options.m_inbound_quantity, m_session_options.m_outbound_quantity,
m_session_options.m_inbound_length, m_session_options.m_outbound_length);
Expand Down
16 changes: 8 additions & 8 deletions src/ip_notifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ struct ip_change_notifier_impl final : ip_change_notifier

void async_wait(std::function<void(error_code const&)> cb) override
{
post(m_ios, [cb]()
{ cb(make_error_code(boost::system::errc::not_supported)); });
post(m_ios, [cb1=std::move(cb)]()
{ cb1(make_error_code(boost::system::errc::not_supported)); });
}

void cancel() override {}
Expand Down Expand Up @@ -130,10 +130,10 @@ struct ip_change_notifier_impl final : ip_change_notifier
void async_wait(std::function<void(error_code const&)> cb) override
{
m_socket.async_receive(boost::asio::buffer(m_buf)
, [cb=std::move(cb), this] (error_code const& ec, std::size_t const bytes_transferred)
, [cb1=std::move(cb), this] (error_code const& ec, std::size_t const bytes_transferred)
{
if (ec) cb(ec);
else this->on_notify(int(bytes_transferred), std::move(cb));
if (ec) cb1(ec);
else this->on_notify(int(bytes_transferred), std::move(cb1));
});
}

Expand Down Expand Up @@ -193,10 +193,10 @@ struct ip_change_notifier_impl final : ip_change_notifier
if (!pertinent)
{
m_socket.async_receive(boost::asio::buffer(m_buf)
, [cb=std::move(cb), this] (error_code const& ec, std::size_t const bytes_transferred)
, [cb1=std::move(cb), this] (error_code const& ec, std::size_t const bytes_transferred)
{
if (ec) cb(ec);
else this->on_notify(int(bytes_transferred), std::move(cb));
if (ec) cb1(ec);
else this->on_notify(int(bytes_transferred), std::move(cb1));
});
}
else
Expand Down
1 change: 1 addition & 0 deletions src/posix_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace aux {
posix_storage::posix_storage(storage_params const& p)
: m_files(p.files)
, m_save_path(p.path)
, m_file_priority(p.priorities)
, m_part_file_name("." + to_hex(p.info_hash) + ".parts")
{
if (p.mapped_files) m_mapped_files = std::make_unique<file_storage>(*p.mapped_files);
Expand Down
4 changes: 4 additions & 0 deletions src/read_resume_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ namespace {
}
ret.ti = std::move(ti);
}
else
{
ec = errors::mismatching_info_hash;
}
}

#if TORRENT_ABI_VERSION < 3
Expand Down
23 changes: 18 additions & 5 deletions src/session_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Copyright (c) 2020, Paul-Louis Ageneau
Copyright (c) 2020, Rosen Penev
Copyright (c) 2022, Vladimir Golovnev (glassez)
Copyright (c) 2022, thrnz
Copyright (c) 2023, Joris Carrier
All rights reserved.
You may use, distribute and modify this code under the terms of the BSD license,
Expand Down Expand Up @@ -952,6 +953,8 @@ bool ssl_server_name_callback(ssl::stream_handle_type stream_handle, std::string
m_ses_extensions[plugins_tick_idx].push_back(ext);
if (features & plugin::dht_request_feature)
m_ses_extensions[plugins_dht_request_idx].push_back(ext);
if (features & plugin::unknown_torrent_feature)
m_ses_extensions[plugins_unknown_torrent_idx].push_back(ext);
if (features & plugin::alert_feature)
m_alerts.add_extension(ext);
session_handle h(shared_from_this());
Expand Down Expand Up @@ -3049,9 +3052,15 @@ namespace {
return;
}

bool want_on_unknown_torrent = false;
#ifndef TORRENT_DISABLE_EXTENSIONS
want_on_unknown_torrent = !m_ses_extensions[plugins_unknown_torrent_idx].empty();
#endif

// check if we have any active torrents
// or if there is an extension that wants on_unknown_torrent
// if we don't reject the connection
if (m_torrents.empty())
if (m_torrents.empty() && !want_on_unknown_torrent)
{
#ifndef TORRENT_DISABLE_LOGGING
session_log("<== INCOMING CONNECTION [ rejected, there are no torrents ]");
Expand Down Expand Up @@ -3103,9 +3112,10 @@ namespace {
// if we don't have any active torrents, there's no
// point in accepting this connection. If, however,
// the setting to start up queued torrents when they
// get an incoming connection is enabled, we cannot
// get an incoming connection is enabled or if there is
// an extension that wants on_unknown_torrent, we cannot
// perform this check.
if (!m_settings.get_bool(settings_pack::incoming_starts_queued_torrents))
if (!m_settings.get_bool(settings_pack::incoming_starts_queued_torrents) && !want_on_unknown_torrent)
{
bool has_active_torrent = std::any_of(m_torrents.begin(), m_torrents.end()
, [](std::shared_ptr<torrent> const& i)
Expand Down Expand Up @@ -5662,8 +5672,11 @@ namespace {
listen_socket->external_address.cast_vote(external_ip, source_router, address());
}

if (proto == portmap_protocol::tcp) listen_socket->tcp_port_mapping[transport].port = port;
else if (proto == portmap_protocol::udp) listen_socket->udp_port_mapping[transport].port = port;
// need to check whether this mapping is for one of session ports (it could also be a user mapping)
if ((proto == portmap_protocol::tcp) && (listen_socket->tcp_port_mapping[transport].mapping == mapping))
listen_socket->tcp_port_mapping[transport].port = port;
else if ((proto == portmap_protocol::udp) && (listen_socket->udp_port_mapping[transport].mapping == mapping))
listen_socket->udp_port_mapping[transport].port = port;

if (!ec && m_alerts.should_post<portmap_alert>())
{
Expand Down
2 changes: 2 additions & 0 deletions src/ssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ void set_server_name_callback(context_handle_type c, server_name_callback_type c
#if defined __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wcast-function-type-strict"
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#endif
SSL_CTX_set_tlsext_servername_callback(c, cb);
SSL_CTX_set_tlsext_servername_arg(c, arg);
Expand Down
8 changes: 4 additions & 4 deletions src/torrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2450,9 +2450,9 @@ bool is_downloading_state(int const st)

span<sha256_hash> v2_span(hashes);
m_ses.disk_thread().async_hash(m_storage, m_checking_piece, v2_span, flags
, [self = shared_from_this(), hashes = std::move(hashes)]
, [self = shared_from_this(), hashes1 = std::move(hashes)]
(piece_index_t p, sha1_hash const& h, storage_error const& error) mutable
{ self->on_piece_hashed(std::move(hashes), p, h, error); });
{ self->on_piece_hashed(std::move(hashes1), p, h, error); });
++m_checking_piece;
if (m_checking_piece >= m_torrent_file->end_piece()) break;
}
Expand Down Expand Up @@ -11397,9 +11397,9 @@ namespace {

span<sha256_hash> v2_span(hashes);
m_ses.disk_thread().async_hash(m_storage, piece, v2_span, flags
, [self = shared_from_this(), hashes = std::move(hashes)]
, [self = shared_from_this(), hashes1 = std::move(hashes)]
(piece_index_t p, sha1_hash const& h, storage_error const& error) mutable
{ self->on_piece_verified(std::move(hashes), p, h, error); });
{ self->on_piece_verified(std::move(hashes1), p, h, error); });
m_picker->started_hash_job(piece);
m_ses.deferred_submit_jobs();
}
Expand Down
Loading

0 comments on commit 742df3d

Please sign in to comment.