Commit Graph

489 Commits

Author SHA1 Message Date
Cœur 0ee64695ca
test: disable restartWithDifferentInterval for all platforms (#6745) 2024-03-31 14:07:12 -05:00
Charles Kerr d935d364ed
refactor: remove torrent_view virtual class (#6738)
* refactor: remove torrent_view virtual class

* chore: workaround for google-readability-todo warnings

* chore: fix completion tests
2024-03-30 14:45:00 -05:00
Yat Ho 2ff3ae07d1
fix: more misc `net.cc` fixes (#6735)
* feat: accept ipv6 string in square brackets for `tr_address::from_string()`

* test: add test case for ipv6 string in square brackets

* fix: include square brackets in host component

According to RFC3986:
  host       = IP-literal / IPv4address / reg-name
  IP-literal = "[" ( IPv6address / IPvFuture  ) "]"

* fix: set ipv6-only socket before binding UDP socket

Will return EINVAL on Linux otherwise

* refactor: simplify code using `evutil` when binding TCP socket

* fix: do not set SO_REUSEADDR for listening sockets on Windows systems

Reason: https://stackoverflow.com/a/14388707/11390656

* fix: do not enclose ipv4 address string in square brackets
2024-03-25 21:10:06 -05:00
Yat Ho 1568659f95
fix: mismatched `class` forward declaration for `struct tr_peer` (#6725) 2024-03-25 12:00:26 -05:00
Charles Kerr b318bf8d9d
refactor: use fstream in subprocess tests (#6733) 2024-03-25 09:13:09 -05:00
Cœur 4ce8a02916
Disable a long-lived and recurrent flaky test (#6722) 2024-03-25 00:32:29 -05:00
Yat Ho 2548dd478f
feat: periodically refresh dht node id (#6695) 2024-03-17 18:24:36 -05:00
Cœur 0749300090
bumping googletest from 1.11.0 to 1.14.0 (#6702)
* bumping googletest from 1.11.0 to 1.14.0

* logging ::testing::TempDir()

* sandboxing ::testing::TempDir()
2024-03-17 15:13:56 -05:00
Yat Ho 152f3e91a5
refactor: convert `tr_peerMsgsImpl` helper functions to class methods (#6580)
* refactor: update bep links

* chore: use more appropriate data types

* chore: checkpoint

* refactor: split `can_request()` into each of their own different signature

* chore: checkpoint

* refactor: convert tr_peerMsgsImpl functions to methods

* chore: checkpoint

* refactor: store peer info as reference

* refactor: convert all member variables to private

* chore: re-arrange methods

* refactor: optimise tmp vector default size in `send_ut_pex()`

* chore: housekeeping

* chore: housekeeping

* refactor: avoid `dynamic_cast` when sending cancel

* fix: restore `blocks_sent_to_peer` stat

regression e91af26923

* fix: choke first then reject

* refactor: convert `tr_peerMsgsNew()` to static factory function

* refactor: store `tr_torrent` reference instead of pointer

* Revert "refactor: store peer info as reference"

This reverts commit bb419bf2

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-03-15 19:52:09 -05:00
Cœur edc59ba5d8
fix compatibility with clang-format 18 (#6690)
* fix clang-format

* compatibility with clang-format 17-18
2024-03-15 00:17:10 -05:00
Charles Kerr 50dca24f50
refactor: aggregate crypto handles when computing digests (#6662)
* refactor: aggregate per-crypto-pkg fields instead of using inheritance
2024-03-04 16:59:51 -06:00
Charles Kerr efd6790973
refactor: remove tr_sys_file_flush() (#6647) 2024-03-03 23:29:38 -06:00
Charles Kerr 1855cdb731
refactor: replace tr_sys_file_write_line() with fmt::print("...\n") (#6619)
* refactor: use fmt::print in log.cc

https://github.com/fmtlib/fmt/issues/428#issuecomment-395442159
> You can use fmt::print("...\n") on Windows as well.

Use this mechanism instead of tr_sys_file_write_line()

* refactor: use FILE* in daemon

* refactor: remove unused tr_sys_file_flush_possible()

* refactor: remove unused tr_sys_file_write_line()

* refactor: remove unused tr_sys_file_get_std()

* refactor: remove unused tr_std_sys_file_t
2024-02-25 16:12:08 -06:00
Charles Kerr 189fe73575
refactor: remove TR_PATH_DELIMITER (#6618) 2024-02-18 01:47:12 -06:00
Charles Kerr 7c11809672
fix: more clang-tidy warnings (#6608)
* fix: readability-redundant-casting warnings in gtk

* fix: bugprone-move-forwarding-reference warnings in gtk

* fix: readability-redundant-casting warnings in qt

* fix: bugprone-switch-missing-default-case warnings in qt

* fix: readability-use-std-min-max warning in qt client

* fix: readability-static-accessed-through-instance warning in qt client

* fix: cppcoreguidelines-avoid-const-or-ref-data-members warning in qt client

* fix: readability-avoid-nested-conditional-operator warning in qt client

* fixup! fix: readability-use-std-min-max warning in qt client

* fix: readability-redundant-member-init warnings in gtk client

* fix: performance-avoid-endl warnings in gtk client

* chore: disable readability-qualified-auto

too many false warnings

* chore: disable cppcoreguidelines-avoid-const-or-ref-data-members

* chore: fix readability-duplicate-include warning in gtk client

* chore: fix modernize-use-nodiscard warning in gtk client

* chore: fix readability-convert-member-functions-to-static warning in gtk client

* fixup! fix: bugprone-move-forwarding-reference warnings in gtk

* chore: fix performance-enum-size warning in gtk client

* fix: cppcoreguidelines-prefer-member-initializer warning in gtk client

* fix: readability-identifier-naming warning in qt client

* Revert "chore: fix performance-enum-size warning in gtk client"

This reverts commit 5ce6b562f8.

* fix: readability-redundant-member-init warning in move tests

* fix: readability-redundant-casting warnings in tests

* fixup! fix: readability-identifier-naming warning in qt client

* fixup! fix: readability-avoid-nested-conditional-operator warning in qt client

* fix: readability-static-accessed-through-instance warning in qt client

* fix: readability-redundant-casting warning in watchdir tests
2024-02-17 13:31:49 -06:00
Charles Kerr c14d445cf5
refactor: libtransmission Settings (#6592)
* refactor: make tr_session_settings a libtransmission::Settings

* refactor: make VariantConverter private in settings.cc
2024-02-15 11:31:09 -06:00
Mrnikifabio f06cb37c06
feat: added `sleep-per-seconds-during-verify` to settings.json (#6572)
* feat: added `sleep-per-seconds-during-verify` to settings.json

* Ensuring `sleep_per_seconds_during_verify > 0` in `verify_torrent` for better performance

* `#include` list reordered alphabetically

* fix: `[readability-inconsistent-declaration-parameter-name]` warning
2024-02-12 09:30:40 -06:00
Yat Ho 168d56cefc
perf: restore `3.00` wishlist with cached candidates (#6549)
* feat: rewrite Wishlist to cache candidates

* feat: implement mediator and observers

* feat: rewrite existing tests to work for current implementation

* fix: incorrect block spans for existing tests

* feat: add new tests for new features

* fix: clang shadow warning

* fix: heap-use-after-free in tests

* fixup! feat: rewrite Wishlist to cache candidates

* chore: update comment

* code review: reserve vector memory

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-02-05 00:14:34 -06:00
Yat Ho ca11c33d05
fix: various DHT bugs (#6569)
* fix: unconditionally send DHT Port msg if supported

* chore: add "maybe" to dht add_node functions

* feat: change `bind-address-ipv*` defaults to empty string

* chore: housekeeping

* fix: initialise DHT node id with random bytes

* chore: housekeeping
2024-02-04 12:18:01 -06:00
Charles Kerr 468de87076
refactor: fix cppcoreguidelines-avoid-do-while warnings (#6527)
* fix: avoid do-while in tr_sys_file_lock()

* fix: avoid do-while in BitfieldTest

* chore: set cppcoreguidelines-avoid-do-while.IgnoreMacros

* fix: avoid do-while in FileList::Impl::onRowActivated()

* fix: avoid do-while in tr_spawn_async_in_parent()

* fix: avoid do-while in handle_sigchld()

* fixup! fix: avoid do-while in tr_spawn_async_in_parent()

* fixup! fix: avoid do-while in FileList::Impl::onRowActivated()

* fixup! fix: avoid do-while in tr_spawn_async_in_parent()

fix fd leak regression

* fixup! fix: avoid do-while in tr_spawn_async_in_parent()
2024-01-20 16:56:42 -06:00
Charles Kerr 239478925f
fix: performance-enum-size warnings (#6504) 2024-01-08 08:32:58 -06:00
Charles Kerr 9d433ff8b4
fix: misc-include-cleaner clang-tidy warnings (#6502) 2024-01-07 14:21:05 -06:00
Yat Ho df1dc5812c
fix: restore the `tag` key in RPC response (#6492)
* fix: restore the `tag` key in RPC response

* chore: `tr_rpc_request_exec()` housekeeping

* feat: new tests for RPC tag
2024-01-06 10:40:23 -06:00
Charles Kerr 22cde5d4b9
refactor: use new tr_variant API in rpcimpl (#6456)
* refactor: tr_rpc_request_exec_json takes a std::function callback

* refactor: tr_rpc_request_exec_json callback takes a tr_variant&&

* refactor: use new tr_variant API in rpcimpl.cc

* refactor: tr_rpc_request_exec_json() now takes a const& to the request

* fixup! refactor: use new tr_variant API in rpcimpl.cc

* chore: rename function to tr_rpc_request_exec()

* chore: remove unused DetailsDialog::Impl::build_torrent_ids_variant_list()

* refactor: minor copyediting in rpcimpl.cc getTorrents()

* refactor: split handler methods between sync, async

* refactor: remove unused args_out param from AsyncHandlers

* chore: fix new readability-inconsistent-declaration-parameter-name warning
2024-01-02 22:14:43 -06:00
Yat Ho 10d047005a
refactor: convert `tr_incomplete_metadata` to c++ class (#6383)
* refactor: unset peer BEP-9 support if size hint is invalid

* fix: open torrent file in binary mode

* refactor: move metadata size check to method

* refactor: remove duplicate checks

* refactor: reduce temp variable scope in `parseLtepHandshake()`

* refactor: convert `get_piece_length()` to method

* refactor: convert `tr_torrentSetMetadataSizeHint()` to method

* refactor: convert `tr_torrentGetMetadataPiece()` to method

* refactor: convert `tr_torrentUseMetainfoFromFile()` to method

* refactor: convert `tr_torrentSetMetadataPiece()` to method

* refactor: convert `tr_torrentGetNextMetadataRequest()` to method

* refactor: convert `tr_torrentGetMetadataPercent()` to method

* refactor: add basic framework for MagnetMediator

* refactor: initialise `tr_incomplete_metadata` fields in constructor

* refactor: check metadata transfer completion in `set_metadata_piece()`

* refactor: convert `use_new_metainfo()` and `on_have_all_metainfo()` to methods

* refactor: move parts of `tr_torrent::set_metadata_piece()` into `tr_incomplete_metadata`

* refactor: move parts of `tr_torrent::get_next_metadata_request()` into `tr_incomplete_metadata`

* refactor: move parts of `tr_torrent::get_metadata_percent()` into `tr_incomplete_metadata`

* refactor: hide all `tr_incomplete_metadata` fields

* refactor: move `incomplete_metadata` to private

* feat: add test for `set_metadata_piece()`

* refactor: unify integer types

* refactor: rename `tr_incomplete_metadata` to `tr_metadata_download`

* chore: make clang-tidy happy

libtransmission/torrent-magnet.cc:117:68: warning: comparison of integers of different signs: 'long' and 'const uint64_t' (aka 'const unsigned long') [clang-diagnostic-sign-compare]

* refactor: pass log name to `tr_metadata_download` constructor

* chore: iwyu

* fix: thread-safe `TorrentMagnetTest.setMetadataPiece`

* chore: housekeeping

* Revert "fix: thread-safe `TorrentMagnetTest.setMetadataPiece`"

This reverts commit 2a7fcd93a262888f9f55d542b1a9a2da9ca72cea.

* fix: stop soon instead of stop now in `on_metainfo_completed()`

This is unreachable code now, but if it is ever reached, Transmission
will very likely crash.

* fix: maybe fix OpenBSD test failure
2024-01-02 21:04:17 -06:00
Charles Kerr 5e51fda92e
refactor: remove tr_strlcpy() (#6433)
* refactor: do not use tr_strlcpy() in tr_strratio()

* refactor: do not use tr_strlcpy() in bindUnixSocket()

* refactor: do not use tr_strlcpy() in trackerView()

* chore: remove tr_strlcpy() unit tests

* chore: remove tr_strlcpy()

* chore: remove -DHAVE_STRLCPY from Xcode build

* fixup! refactor: do not use tr_strlcpy() in trackerView()

chore: fix copypaste bug
2023-12-24 13:33:33 -06:00
Yat Ho d2d7987553
refactor: allow explicitly queuing functions in session thread (#6406)
* feat: allow explicitly queuing functions in session thread

* refactor: rename `tr_session_thread`-related functions to snake_case
2023-12-24 08:32:14 -06:00
Yat Ho 45298e5a4e
fix: don't create all 0-byte files in `MakemetaTest::makeRandomFiles()` (#6394)
* fix: randomly failing `MakemetaTest.nameIsRootSingleFile`

* fix: eliminate remaining probability for `MakemetaTest.nameIsRootSingleFile` to fail
2023-12-23 14:49:19 -06:00
Charles Kerr 581d9c34cc
fix: gcc-13 warnings pt. 2 (#6404)
* fix: tr_priority_t usage warnings

* build: disable -Wnull-dereference warnings when building GTest

* fix: -Wunused-result warning in tr_spawn_async()

* fix: -Warray-bounds warning in NetTest::compact4()
2023-12-23 10:32:04 -06:00
Mike Gelfand a494da4fea
fix: fill random buffer in chunks with mbedtls crypto backend (#6379)
* adjust crypto unit test to reproduce the issue

* fill random buffer in chunks with mbedtls crypto backend
2023-12-16 19:21:24 -06:00
Charles Kerr 56837517b0
refactor: tr_block_info cleanup (#6342)
* refactor: make tr_block_info::init_sizes() private

* refactor: remove unuse tr_file_piece_map::empty()

* refactor: remove tr_file_priorities::reset()

* refactor: remove tr_files_wanted::reset()

* refactor: rename method to tr_file_piece_map::piece_span_for_file()

more consistent naming with tr_block_info

* refactor: rename method to tr_file_piece_map::file_span_for_piece()

more consistent naming with tr_block_info

* refactor: use standard class field order in tr_block_info

* refactor: move CompareToSpan from header to cc file

* refactor: make tr_file_piece_map::reset() private

* refactor: rename method to tr_file_piece_map::file_count()

* refactor: rename method to tr_file_piece_map::byte_span_for_file()

* refactor: constify tr_block_info function args

* refactor: fix more signed vs unsigned
2023-12-05 22:06:27 -06:00
Charles Kerr 2e46bad22d
refactor: constify the inout module (#6328)
* refactor: move tr_preallocation_mode info tr_open_files

* refactor: remove unnecessary error nullptr check

* refactor: use snake_case for private method names in inout.cc

* refactor: extract-method get_fd() from read_or_write_bytes()

* refactor: make function args const where possible

* refactor: simplify read_or_write_bytes()

* refactor: make buflen a uint64_t in read_or_write_piece()

* refactor: move tr_torrentStop() logic from read_or_write_piece() to tr_ioWrite()

* refactor: make tr_ioFoo() functions take a const torrent

* refactor: make tr_cache::close_torrent_files() take a tor_id instead of a torrent
2023-12-02 14:16:36 -06:00
Charles Kerr 25d67dd00d
refactor: in tr_announce_list, replace port_and_str with aggregated parsed url (#6323) 2023-12-01 15:48:04 -06:00
Yat Ho ed4fad9b18
feat: support creating 0 byte files (#6232) 2023-11-28 10:51:13 -06:00
Charles Kerr e14806c409
refactor: c++ify libtransmission's tr_ctor struct (#6295) 2023-11-26 15:43:37 -06:00
Charles Kerr a12ef941e7
refactor: make tr_torrent fields, methods private where possible (#6293) 2023-11-25 20:00:20 -06:00
Charles Kerr 7e8eca0e96
refactor: make tr_torrent::seconds_[seeding,downloading] private (#6279) 2023-11-22 23:41:12 -06:00
Yat Ho adc209d7e8
refactor: RPC `port-test` improvements (#6274) 2023-11-22 23:02:21 -06:00
Charles Kerr 64d9d57363
chore: fix minor clang-tidy warnings (#6275) 2023-11-21 09:02:03 -06:00
Charles Kerr 76521a1751
refactor: Values pt. 7 - remove tr_formatter_init methods (#6258)
* refactor: initialize libtransmission::Values units in Application::initUnits()

* refactor: use libtransmission::Values instead of Formatter::unitStr()

* refactor: remove Formatter::Size, Formatter:Type

* refactor: use Values::Config to init units in transmission-qt

* refactor: use Values::Config to init units in transmission-mac

* chore: remove unused tr_formatter_foo_init() functions

* chore: make Value::operator+() const

* use Values::Speed, Values::Storage in GTK client

* chore: use snake_case for Formatter methods

* refactor: use Values::Speed in GTK client details dialog

* feat: add Values::Value::is_zero()

* refactor: remove unnecessary UTF8String calls
2023-11-15 22:15:40 -06:00
Charles Kerr 07d96036d9
refactor: Values pt. 6 - remove deprecated API (#6250) 2023-11-14 17:23:51 -06:00
Charles Kerr 4be0dca5ac
refactor: Values pt. 5 - use Values::Speed in Qt client (#6248) 2023-11-13 11:13:17 -06:00
Yat Ho 40fe56f33e
refactor: thread-safe `lru-cache` and `tr_open_files` (#6230) 2023-11-11 21:09:23 -06:00
Charles Kerr a575be778f
refactor: Values pt. 2 - use Speed in tr_bandwidth (#6234) 2023-11-10 17:12:24 -06:00
Charles Kerr 37f01fac4c
refactor: migrate variant api (#6238) 2023-11-10 15:41:32 -06:00
Charles Kerr 36f33c0d30
fix: recent clang-tidy warnings (#6233)
* fix: readability-implicit-bool-conversion warnings in file-piece-map

* fix: clang-analyzer-core.NullDereference warning in on_handshake_done()
2023-11-09 19:13:43 -06:00
Yat Ho a2e97234d2
refactor: optionally include 0 byte files when computing file offset (#6229) 2023-11-09 16:49:18 -06:00
Charles Kerr 2e32789193
refactor: add libtransmission::Values (#6215) 2023-11-09 08:39:06 -06:00
Charles Kerr a952a0731f
refactor: remove the tr_error** idiom (#6198)
* refactor: remove the tr_error** idiom

* fix: tr_error::message() is only constexpr in c++20 and up

* chore: silence a couple of g++-12 Wshadow warnings
2023-11-04 11:39:41 -05:00
Yat Ho a2b547fb50
chore: iwyu (#6201) 2023-11-03 12:03:26 -05:00