Commit Graph

522 Commits

Author SHA1 Message Date
Yat Ho
adea0e2a07 build: tell clang-tidy to suggest uppercase literal suffixes (#7529) 2025-05-06 22:07:43 +01:00
Yat Ho
c215de34d5 chore: move away from fmt/core.h (#7557) 2025-05-06 01:01:12 -05:00
Yat Ho
9e15394c65 refactor: announcer code housekeeping (#7496)
* refactor: use time_t for intervals

* refactor: use appropriate int types

* chore: housekeeping

* perf: replace count with find so it can short circuit

* code review: fix regression noticed by nevack
2025-05-01 17:50:14 +01:00
Yat Ho
03c2dbd63c feat: make proxy_url nullable (#7486)
* fix: clang-tidy warning

* refactor: make `proxy_url` nullable
2025-05-01 16:57:46 +01:00
Yat Ho
7b83c7d625 refactor: rename unreleased quarks to snake_case (#7483)
* refactor: rename `sequentialDownload` to `sequential_download`

* refactor: rename `beginPiece` to `begin_piece`

* refactor: rename `endPiece` to `end_piece`

* refactor: rename `ipProtocol` to `ip_protocol`

* refactor: rename `preferred-transport` to `preferred_transport`
2025-03-10 17:30:19 -05:00
Charles Kerr
76d854dcc8 fix: clang-tidy-20 warnings (#7479)
* chore: disable unavoidable warning

* fix: clang-tidy readability-math-missing-parentheses warnings

* fix: clang-tidy google-readability-todo warnings

* fix: clang-tidy misc-use-internal-linkage warnings

* fix: clang-tidy readability-redundant-string-cstr warnings

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

* chore: disable cppcoreguidelines-avoid-const-or-ref-data-members warnings in qt/

* fix: clang-tidy readability-identifier-naming warnings
2025-03-10 15:01:31 -05:00
Yat Ho
24f58f70ee feat: sequential download in settings.json torrent-add and sesssion-* RPC methods (#7047)
* feat: init sequential download setting from ctor

* feat: `sequantialDownload` arg in `torrent-add` RPC method

* feat: sequential download settings in settings.json

* feat: sequential download arguments in `session-*` RPC methods

* test: fix
2025-03-10 12:07:35 -05:00
Yat Ho
088232f69c fix: abort handshake if the torrent is stopped (#6947)
* fix: abort handshake if torrent isn't running

* fix: check if torrent is running in all cases

* fix: don't penalise peer if handshake failed because of us

* fix: tests

* perf: ensure copy-elision in `HandshakeMediator::torrent()`

* code review: more accurate log wording
2025-03-10 01:05:16 -05:00
Yat Ho
47eb4ee2bc refactor: dedicated class for torrent queue (#7332)
* Revert "feat: save queue order between sessions (#6753)"

This reverts commit 4db50dae10.

* refactor: new torrent queue class

* refactor: replace queue code with new class

* test: new tests for new class

* feat: store and load queue order across sessions

* build: xcode

* refactor: use set_difference instead of unordered_set

* code review: use `tr_torrent_id_t` as key

* fix: don't overflow when moving up/down

---------

Co-authored-by: Dzmitry Neviadomski <nevack.d@gmail.com>
2025-03-09 19:08:50 -05:00
Charles Kerr
cbd65ae8b1 refactor: fix modernize-use-nodiscard warnings by adding [[nodiscard]] (#7351) 2025-03-04 17:28:33 -06:00
Yat Ho
76ab7ba592 refactor: set peer io socket in constructor (#7355)
* refactor: `tr_netOpenPeerSocket()` returns `tr_socket_t`

* refactor: store preferred transport as array

* refactor: set peer io socket in constructor

* refactor: remove `log_peer_io_bandwidth()`

This partially reverts commit efec6505

* refactor: rename `tr_netOpenPeerSocket` to snake_case

* code review: remove redundant comment

* code review: add comment about array order
2025-03-03 23:47:37 -06:00
Yat Ho
f768562421 test(dht): use static IP address (#7408) 2025-01-27 01:12:04 +00:00
reardonia
50eacf6933 Consume early pad a/b, improve handshake tests (#6987)
* properly consume PadA in MSE handshake, check for invalid Ya+PadA

* refactor: make handshake constants public (needed for test coverage)

* test: split test MSE handshakes by blocking steps

* test: use `ASSERT_TRUE` instead of `assert`

* test: fix windows crash by using `recv` and `send`

Co-authored-by: Yat Ho <46261767+tearfur@users.noreply.github.com>

* refactor: use `TR_IF_WIN32` for `LOCAL_SOCKETPAIR_AF`

Co-authored-by: Yat Ho <46261767+tearfur@users.noreply.github.com>

---------

Co-authored-by: Yat Ho <lagoho7@gmail.com>
Co-authored-by: reardonia <reardonia@github.com>
Co-authored-by: Yat Ho <46261767+tearfur@users.noreply.github.com>
2025-01-09 10:26:48 -06:00
Yat Ho
131caa1239 refactor: convert tr_net_init_mgr to singleton (#6914) 2024-12-30 09:32:11 -06:00
Charles Kerr
7820f54ba1 refactor: remove TR_DISABLE_COPY_MOVE macro (#7344) 2024-12-29 00:15:39 -06:00
Yat Ho
5a05b37838 feat: support the JSON null type in tr_variant (#7255) 2024-12-15 16:50:19 -06:00
Yat Ho
b3912fa1a5 feat: download first and last piece first in sequential mode (#6893)
* feat: download first and last piece first in sequential mode

* test: fix tests
2024-12-13 19:32:03 -06:00
Yat Ho
90859fe115 test: use new tr_variant API (#7268)
* test: new `tr_variant` API in `json-test.cc`

* test: new `tr_variant` API in `variant-test.cc`

* chore: housekeeping

* test: new `tr_variant` API in `dht-test.cc`

* fix: use `reinterpret_cast` in `tr_variant::make_raw()`

* fix: add missing `typename` in `tr_variant::make_raw()`

* test: new `tr_variant` API in `settings-test.cc`

* test: new `tr_variant` API in `move-test.cc`

* test: new `tr_variant` API in `rpc-test.cc`

* test: new `tr_variant` API in `makemeta-test.cc`

* test: new `tr_variant` API in `session-test.cc`
2024-12-09 19:22:54 -06:00
Yat Ho
60e5d98dc1 fix: handle nullptr in json serde (#7258)
* fix: handle nullptr in json serde

* test: fuzz json serde
2024-12-09 11:59:10 -06:00
Yat Ho
affb03a8d2 refactor: remove tr_torrent::do_magnet_idle_work() (#7271)
* Revert "fix: possible heap-use-after-free with magnet links (#6815)"

This reverts commit 09b67c84b1.

* fix: check if torrent still exists before verifying

* refactor: queue `on_have_all_metainfo()` in session thread instead
2024-12-09 10:58:39 -06:00
Yat Ho
7e4b4f10a1 refactor: faster wishlist (#7027)
* chore: housekeeping

* perf: short circuit peer has block check

* refactor: track active requests in each respective peer

* refactor: swap `ActiveRequests` with new request tracking method

* refactor: use bitfield to store active requests per peer

* perf: check active request numbers first

* refactor: initialise candidate values in constructor

* refactor: better naming

* refactor: use `find_by_block()` more

* refactor: store wishlist mediator in swarm object

* test: make it compile

* test: update endgame test

* test: new test for choke event

* test: remove redundant lines

* test: new test for request event

* test: new test for reject event

* refactor: cache block have state in wishlist

* test: fix `gotBlockResortsPiece`

* fixup! refactor: track active requests in each respective peer

* fixup! test: fix `gotBlockResortsPiece`

* fix: count webseeds when calculating active requests

* build: update xcode project

* fix: add missing `candidates_dirty_` checks

* chore: remove old `depends-on` comments

* fixup! refactor: use bitfield to store active requests per peer

* refactor: extract block peer event to separate function

* perf: reorder conditions by overhead

* perf: check for completed block instead of completed piece

* chore: remove duplicated "unrequested piece" check

* refactor: merge similar block size sanity check

* refactor: use map to store number of requests in wishlist

* refactor: add asserts

* refactor: flush write buffer as soon as there is new data

* refactor: more accurate function naming

* fix: account for corrupt pieces in wishlist

* fix: account for unaligned blocks in wishlist

* Revert "fix: account for unaligned blocks in wishlist"

This reverts commit c3fce93cbae49c11d62e26caccedf55c1987aa95.

* fixup! refactor: use map to store number of requests in wishlist

* fix: account for unaligned blocks in wishlist v2

* chore: add `[[nodiscard]]`

* fixup! fix: account for unaligned blocks in wishlist v2

* fix: crash when handshake finishes in the middle of function
2024-11-11 19:30:00 -06:00
Charles Kerr
f988da6aa1 refactor: remove unused TR_SYS_FILE_APPEND (#7206) 2024-10-29 17:07:13 -05:00
Yat Ho
62240393ed feat: configurable client reqq (#7030)
* chore: housekeeping

* refactor: raise client reqq value

* feat: allow configuring client reqq value

* feat: expose reqq config in RPC

* test: add new key

* code review: distinguish client vs peer

* docs: fix new config name

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-08-23 21:46:37 -05:00
Yat Ho
b0a6bf964c perf: lazy initialise Diffie-Hellman in handshake (#6949)
* perf: don't generate private key when default constructing DH

* refactor: simplify dh pool code using `small::max_size_vector`

* perf: lazy initialise handshake DH

* fix: tests

* refactor: use `std::optional` instead of `DH::is_dummy()`

* perf: try recycling DH objects in handshake destructor

* fix: don't set `have_read_anything_from_peer_` until all sanity checks are finished
2024-08-23 16:14:45 -05:00
Yat Ho
3e5a77d176 refactor: remove last byte special case in tr_block_info::byte_loc() (#7064)
* refactor: remove last byte special case in `tr_block_info::byte_loc()`

* fix: handle 0-byte file at the end of torrent in fpm

* test: modify test for 0-byte file at the end of torrent

* fix: handle 0-byte file at the end of torrent in `block_span_for_file`
2024-08-22 19:03:14 -05:00
Lucas Clemente Vella
9fc9daf40d Fails with an error if data removal was not possible (#6055)
* Do not remove torrent if trashing files failed.

Instead, stop the torrent and sets an error.

* Fixing GTK interface with new file removal behavior.

* C++17 compliant.

* Reverting unrelated change.

* Avoiding allocating unecessary objects.

* Easy review fixes.

* Fixing merge error.

* Adding result callback to tr_torrentRemove().

Using the new callback in Gtk GUI to decide when to remove it from the
interface.

* Reducing indentation level and making the function more readable.

* Using existing Session RefPtr.

* Notifying the client before freeing the torrent in the session.

* Addressing comments and synchronizing callback.

* Moving include.

* Fix constness issue reported by clang-tidy
2024-08-13 05:26:09 +01:00
Yat Ho
fa8be1b981 fix: tr_variant_serde::parse_json() bug fixes (#6901)
* perf: avoid unnecessary copying

* fix: set `tr_variant_serde::end_` in `parse_json()`

* test: `tr_variant_serde::end()`

* fix: compensate for innate read cursor offset of `rapidjson::AutoUTFInputStream`

* fix: stop parsing json after parsing a complete json root

This matches the benc parser's behaviour

* fixup! fix: stop parsing json after parsing a complete json root
2024-07-17 02:34:13 +01:00
Yat Ho
a76a07ae99 chore: misc code cleanups (#6927)
* refactor: avoid repeated subscripting in `announcer-udp.cc`

* chore: remove redundant locking in global ip cache

* chore: misc code cleanup in global ip cache

* fixup! chore: misc code cleanup in global ip cache

* refactor: remove `tr_global_ip_cache::create()`

* refactor: rename `tr_global_ip_cache` to `tr_ip_cache`

* build: sync changes to xcode
2024-07-14 01:37:55 +01:00
Yat Ho
2c2011d40f fix: update partial file suffix after verifying torrent (#6871)
* fix: only update piece completion if different

* fix: remove return statement from void function

* refactor: add `tr_torrent::has_file()`

* fix: update file suffixes after verifying torrent

* fix: tests
2024-06-01 19:44:01 -05:00
Yat Ho
4657d210ba feat: dual stack udp tracker support (#6687)
* chore: housekeeping

* refactor: reduce copying when building payloads

* feat: dual-stack udp tracker support

* refactor: convert function names to snake_case

* fix: `readability-identifier-naming` warning

* fix: account for dual-stack in tests

* code review: add prefix to global names

* fix: don't resolve to IPv4-mapped address

* refactor: use `tr_address` method to check ip protocol

* fix: workaround MSVC x86 build failure

* fix: handle host components that has square brackets

* Partial Revert: "fix: account for dual-stack in tests"

Not needed anymore

* fix: store ipv6 peers in pex6

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-05-26 15:43:55 -05:00
Yat Ho
d6f5e60a35 feat: ipv6 lpd (#6700)
* feat: ipv6 lpd

* feat: find interface index from ip address

* refactor: use `tr_socket_address::from_string()`

* fix: enable multicast loop

* chore: housekeeping

* refactor: dedupe `if_nametoindex()` call

* refactor: rename `mcast_socket_` to `mcast_sockets_`

* code review: fix variable name typo

* code review: unify comment styles

* fixup! code review: unify comment styles

* code review: explain 15KB in Win32 interface index code
2024-05-26 00:04:50 -05:00
Yat Ho
9748f42c5a fix: restore portable file path check (#6853)
* chore: change to snake_case naming

* fix: restore portable file path check

* fix: macosx build
2024-05-25 10:08:53 -05:00
Yat Ho
09b67c84b1 fix: possible heap-use-after-free with magnet links (#6815)
* fix: queue torrent verification as soon as metadata complete

* fix: avoid heap-use-after-free in `tr_peerMsgsImpl::process_peer_message()`

Details: https://github.com/transmission/transmission/pull/6383#discussion_r1429202253

* code review: move `tr_torrent::do_magnet_idle_work()` to private

* code review: `std::deque::empty()` is not `constexpr`

* fix: test
2024-05-24 15:50:01 -05:00
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