Commit Graph

635 Commits

Author SHA1 Message Date
Charles Kerr
849cd0ecea refactor: remove write cache (#8669)
* refactor: mark cache_size_mib as deprecated in RPC

* refactor: make RPC session_set cache_size_mib a no-op

* refactor: tr_ioRead(), tr_ioWrite() now take a std::span

* refactor: add BufferReader::to_buf(std::span<uint8_t>)

* refactor: migrate some methods to to_buf(std::span<uint8_t>)

* refactor: remove the write memory cache

* chore: simplify recalculate_hash()

* refactor: simplify span use in tr_peerMsgsImpl::read_piece_data()
2026-03-11 07:16:39 -05:00
Yat Ho
a483792783 feat: configurable ip query endpoint (#8650)
* feat: configurable ip query endpoint

* fix(test): don't query global IP
2026-03-10 11:36:10 -05:00
Yat Ho
a3545eb9c2 feat: bound-checked tr_variant::value_if() for smaller integer types (#8660)
* feat: bound-checked `tr_variant::value_if()` for smaller integer types

* feat(rpc): ignore values outside the `tr_torrent_id_t` range
2026-03-09 19:35:08 -05:00
Yat Ho
282f085e30 refactor: move tr_pex/tr_variant converters to serializer.cc (#8655) 2026-03-08 12:22:30 -05:00
Yat Ho
eac99ff1a0 fix: readability-container-contains (#8656)
* fix(core): `readability-container-contains`

* fix(test): `readability-container-contains`

* build(gtk): enable `readability-container-contains`

* fix(qt): `readability-container-contains`
2026-03-05 10:00:29 -06:00
reardonia
cee65c7606 security: sanitise CTRL characters in filenames on all systems (#8495)
* disallow CTRL characters in filenames on Unixen

* fixup: compact into is_reserved_char()
2026-03-04 18:08:38 -06:00
Yat Ho
59abf6e1db fix: re-create candidate when got bad block if needed (#8644)
* refactor: use the same salter everywhere

* fix: re-create candidate when got bad block if needed

* refactor: housekeeping

* fix: emit bad piece signal after all bookkeeping
2026-03-04 15:59:21 -06:00
Charles Kerr
5e305a2d26 refactor: simplify session callbacks (#8646)
* refactor: add a Torrent.id property

* feat: add Controller.torrentForId

* refactor: make tr_session_idle_limit_hit_func a std::function

* refactor: make tr_session_metadata_func a std::function

* refactor: make tr_session_ratio_limit_hit_func a std::function

* refactor: make tr_torrent_completeness_func a std::function

* refactor: make tr_altSpeedFunc a std::function

* refactor: make tr_sessionSetQueueStartCallback callback a std::function

* refactor: make tr_rpc_callback_status callback a std::function

* refactor: remove user_data arg from tr_torrent_rename_done_func

* refactor: harden `tr_torrentFindFromId()` by making it safe to pass in a nullptr session
2026-03-03 16:02:54 -06:00
Yat Ho
b561960d51 fix: enable modernize-use-ranges (#8626)
* fix(core): enable `modernize-use-ranges`

* fix(test): enable `modernize-use-ranges`

* fix(qt): enable `modernize-use-ranges`

* fix(gtk): enable `modernize-use-ranges`
2026-02-26 08:22:29 -06:00
Yat Ho
fe879f5817 fix: revert percent-encoding announce urls and webseeds (#8620) 2026-02-25 08:48:34 -06:00
Yat Ho
4e26df6671 fix: modernize-use-ranges in peer-*.cc (#8599) 2026-02-24 07:48:36 -06:00
Yat Ho
f89242c855 fix: enable modernize-loop-convert (#8579) 2026-02-21 09:06:59 -06:00
Yat Ho
ece1d7b6c2 fix: fail when encountering invalid benc character. (#8573)
* fix: fail when encountering invalid benc character

* fix(test): wrong `pieces` length in test string

* test: more benc test cases
2026-02-19 13:53:01 -06:00
Charles Kerr
c5ec41e05e test: use QT_QPA_PLATFORM=offscreen for qt tests on posix (#8575)
Fix the qt tests on Jenkins
2026-02-19 09:24:58 -06:00
Yat Ho
6ad5a4ae31 test: info hash for unordered info dict (#8558) 2026-02-18 12:02:24 -06:00
Charles Kerr
aa8039cfb5 refactor: safeguard against nullptr tr_torrent* args in tr_torrentFoo() methods (#8550)
* refactor: safeguard against nullptr `tr_torrent*` args in `tr_torrentFoo()` methods (#8504)

* feat: safeguard tr_torrentFoo() calls against nullptr torrents

* refactor: tr_log_if_fail(tr_isTorrent(tor))

* test: add tests for invalid args to torrent C API

* fix: cppcoreguidelines-pro-type-member-init

* fix: readability-simplify-boolean-expr
2026-02-17 17:58:34 -06:00
reardonia
31047493f5 UTF8-clean torrent 'path' (#8328)
* fix: mask non-UTF-8 characters in torrent file paths

BEP-3 requires strings to be UTF-8. Run path components through
tr_strv_to_utf8_string() to replace invalid bytes with U+FFFD
before sanitizing. Adds test with good and bad UTF-8 paths.

* replace ctrl characters in 'name' and 'path'

* Revert "replace ctrl characters in 'name' and 'path'"

This reverts commit 6816f59295.

* fix: mask non-UTF-8 characters in torrent file paths

BEP-3 requires strings to be UTF-8. Run path components through
tr_strv_to_utf8_string() to replace invalid bytes with U+FFFD
before sanitizing. Adds test with good and bad UTF-8 paths.

* replace ctrl characters in 'name' and 'path'

* Revert "replace ctrl characters in 'name' and 'path'"

This reverts commit 6816f59295.

* prepare for future Bittorrent v2 usage
2026-02-16 08:49:20 -06:00
Yat Ho
031c996386 fix(test): wait for previous torrent to be removed before continuing (#8477) 2026-02-13 18:13:24 -06:00
reardonia
04922eca8d reject .torrent files with missing info:[pieces] key (#8333)
* reject .torrent files with missing info:[pieces] key

* reduce test torrent size

* add more tests for bad 'pieces' key

* use files_.total_size()

* fixup code_style

* anonymize piece hashes

* move dupe files check to finishInfoDict()

* better piece count comparison

* add test for dupe files

* revert else if -> else

* update for #8409, move tests to torrents-metainfo suite

* add test for duplicate pieces key and tidy

* deeper testing of error conditions

Co-authored-by: Yat Ho <lagoho7@gmail.com>

---------

Co-authored-by: Yat Ho <lagoho7@gmail.com>
2026-02-12 11:36:55 -06:00
Charles Kerr
cbaefab599 refactor: add libtransmission/types.h (#8449)
refactor: add libtransission/constants.h
2026-02-11 16:52:29 -06:00
Charles Kerr
21874392a9 refactor: string-utils, file-utils, env (#8417)
* refactor: add libtransmission/string-utils

* refactor: add libtransmission/file-utils

* refactor: add libtransmission/env

* build: update Xcode
2026-02-11 11:21:45 -06:00
Yat Ho
4bc74e3dd4 feat: allow non-ASCII announce and webseed URLs (#8420)
* test: `tr_urlPercentEncode()`

* refactor: percent-encode URLs provided in announce list or webseeds

* test: announce list and webseed
2026-02-10 16:19:04 -06:00
Yat Ho
ea043d642b perf(test): write zero tor in 512KiB blocks (#8391)
* perf(test): write zero tor in 512KiB blocks

* code review: allocate buffer on heap
2026-02-09 22:22:45 -06:00
Charles Kerr
df16feaa36 feat: add serializer support for std::chrono::sys_seconds, std::u8string, std::filesystem::path (#8364)
* chore: rename display-mode-tests.cc as converter-tests.cc

* feat: support std::chrono::sys_seconds in serializers

* feat: support std::u8string, std::filesystem::path in serializer

* build: address review feedback

* chore: remove unnecessary helper function

* Revert "chore: remove unnecessary helper function"

This reverts commit 69ea907836.

std::to_chars() unavailable on macOS < 13.3

We can remove this hack if/when we drop support for macOS < 13.3
2026-02-09 21:04:18 -06:00
Yat Ho
182c8ce12c fix: fail if pieces length in info dict is not multiple of 20 (#8409)
* fix: fail if `pieces` length in info dict is not multiple of 20

* fix(tests): replace potentially malicious test torrent for pieces length
2026-02-09 19:10:53 -06:00
Charles Kerr
2493c4b904 fix: use video/mp4 as the mime type for mp4 files (#8377)
* refactor: move primary_mime_type() to tr_torrent_files where it is easier to test

* fix: use video/mp4 mime type for .mp4 files

* docs: remove obsolete code comment
2026-02-09 15:53:06 -06:00
Yat Ho
2e65935bbc build: wrap fmt::fmt-header-only with transmission::fmt-header-only (#8370) 2026-02-05 07:50:11 -06:00
Yat Ho
59939ad4e3 build: improve building with system libevent (#8223)
* build: improve building with system libevent

* chore: remove legacy `tr_add_external_auto_library` macro
2026-02-04 13:36:04 -06:00
Charles Kerr
f9d4ced2d0 chore: remove FMT_STRING macros (#8354) 2026-02-04 07:44:33 -06:00
Charles Kerr
90402fd97b refactor: move StatsMode to tr::app (#8330)
* refactor: add StatsMode to libtransmission-app

* test: add display-mode unit tests

* feat: add apicompat for StatsMode

* refactor: use StatsMode in Qt client

* refactor: add template method for gtr_set_pref()

* refactor: use StatsMode in GTK client

* ci: use the all-tests alias instead of hardcoding tests

* ci: copy runtime DLLS into test output directory for Windows test binaries
2026-02-03 09:52:49 -06:00
Charles Kerr
64a53a8219 refactor: use sigslot (#8309)
* fix: warning: declaration shadows a variable in the global namespace [clang-diagnostic-shadow]

* fix: warning: use 'contains' to check for membership [readability-container-contains]

* fix: warning: variable gl_confdir can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]

* warning: function 'TorrentFilter::match_mode' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]

* build: add sigslot dependency

* refactor: use sigslot for tr::Blocklists

* refactor: use sigslot for torrent, peer-mgr, wishlist

* refactor: remove tr::SimpleObservable

* chore: make lint happy

warning: method 'make_wishlist' can be made static [readability-convert-member-functions-to-static]

warning: invalid case style for function 'make_wishlist' [readability-identifier-naming]

warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays]

* refactor: remove unused forward declaration of tr_peer

* chore: remove slop

* refactor: Blocklist::observe_changes() now returns a scoped connection

* build: use transmission/sigslot fork

* refactor: copyediting

* refactor: fix cyclical dependency loop between Wishlist and tr_peerMgr::WishlistMediator
2026-02-02 22:42:28 -06:00
Yat Ho
7a070c2305 fix: update changed dates after setting torrent queue position (#8292)
* Revert "fix: put torrent in "recently active" set after changing queue position (#8290)"

This reverts commit c4283e0c8f.

* fix: update changed dates after setting torrent queue position
2026-01-30 13:05:05 -06:00
Charles Kerr
dd008ae1d0 refactor: C++ify tr_torrentStat() (#8257)
* refactor: callers now own the return value of tr_torrentStat()

fix one potential thread issue by simplifying ownership

* refactor: make tr_stat_errtype an enum class; move into tr_stat

* refactor: order tr_stat fields to reduce padding

* chore: fix branch shear

* fix: int-to-enum-class comparison

* fix: namespace regression

* chore: make clang-tidy happy
2026-01-29 08:07:11 -06:00
Yat Ho
754b295d2a chore(core, tests): fix modernize-loop-convert (#8235)
* chore(core, tests): fix `modernize-loop-convert`

* ci: bump sanitizer-tests-ubuntu to 24.04

Get newer clang to fix FTBFS.
2026-01-28 18:53:40 -06:00
Charles Kerr
554cc56bdf refactor: rename our namespace to tr (#8256)
tr and tr::app are less cluttered than libtransmission:: and transmission::app
2026-01-28 18:11:34 -06:00
Yat Ho
63d6d670fd fix: some errors are not returned in tr_sys_path_get_capacity() (#8248)
* fix: some errors are not returned in `tr_sys_path_get_capacity()`

* test: disable well-formed free_space tests

There are no reliable way to test them.
2026-01-28 13:14:44 -06:00
Yat Ho
b68fc15eb0 fix: FTBFS on MSVC Qt5 (#8246) 2026-01-28 13:13:55 -06:00
Yat Ho
02ca4e3e2b build: support building with system gtest (#8196)
* build: support building with system gtest

* chore: include gtest headers with h-char include
2026-01-27 20:15:11 -06:00
Charles Kerr
4e1b092a17 refactor: use std::remove_cvref_t (#8240) 2026-01-27 20:14:47 -06:00
Charles Kerr
68e9049b17 refactor: tr_torrentRemove() now takes std::function args (#8229) 2026-01-27 14:37:11 -06:00
Yat Ho
cbc4e9dc3a refactor: mock udp announcer DNS resolver for tests (#8232)
* refactor: move udp tracker dns lookup to mediator

* test: mock udp announcer DNS resolver
2026-01-27 12:38:24 -06:00
Charles Kerr
dda5dc7ec3 refactor: remove some dead code (#8222)
* chore: remove unused tr_announcerCreate() declaration

added in d27c4c5 but never used

* chore: remove unused ParserStack::parentType()

added in 5efec26 but never used

* chore: remove tr_port::set_network()

added in 32f854a but never used

* chore: remove tr_torrent_metainfo::pieces_offset()

added in 52f6e80 but never used

* chore: remove unused `tr_session::setPeerCongestionAlgorithm()`

unused after 611d36a

chore: remove unused `tr_session::setAnnounceIP()`

unused after 611d36a
2026-01-26 07:22:20 -06:00
Charles Kerr
a7b2a72cca refactor: remove tr_pathbuf::popdir() (#8221) 2026-01-25 20:02:59 -06:00
Charles Kerr
03fdb6f48e refactor: migrate C strings to std::string_view in libtransmission/file.h (#8220)
* refactor: tr_sys_file_open() now takes a std::string_view arg

* refactor: tr_sys_path_copy() now takes a std::string_view arg

* refactor: tr_blocklistSetContent() now takes a std::string_view arg

* refactor: tr_sys_path_remove() now takes a std::string_view arg

* refactor: tr_sys_path_exists() now takes a std::string_view arg

* refactor: tr_sys_dir_create() now takes a std::string_view arg

* refactor: add private stat_sv(), lstat_sv() helpers in file-posix.cc

* refactor: tr_sys_path_is_same() now takes a std::string_view arg

* refactor: tr_sys_path_rename() now takes a std::string_view arg
2026-01-25 18:39:50 -06:00
Yat Ho
3636f5f35e fix: modernize-use-designated-initializers in core and tests (#8186)
* fix(core): `modernize-use-designated-initializers`

* fix(tests): `modernize-use-designated-initializers`
2026-01-23 21:50:08 -06:00
Yat Ho
56f3578ec9 fix: don't generate zero size files in makemeta-test.cc (#8199)
* fix: don't generate zero size files in makemeta-test.cc

* chore: housekeeping
2026-01-23 21:48:56 -06:00
Charles Kerr
cccef8e2a6 refactor: use fewer raw C strings (#8202)
* refactor: tr_ctorGetDownloadDir() returns a std::optional<std::string>

* refactor: tr_sessionGetConfigDir() now returns a std::string

* refactor: tr_sessionGetDownloadDir() now returns a std::string

* refactor: tr_sessionGetIncompleteDir() now returns a std::string

* refactor: tr_sessionGetRPCWhitelist() now returns a std::string

* refactor: tr_sessionGetRPCPassword() now returns a std::string

* refactor: tr_sessionGetRPCUsername() now returns a std::string

* refactor: tr_sessionGetScript() now returns a std::string

* refactor: tr_blocklistGetURL() now returns a std::string

* refactor: tr_ctorGetSourceFile() now returns a std::optional<std::string>

* refactor: tr_torrentFile() now returns a std::string
2026-01-22 22:36:24 -06:00
Charles Kerr
e7129cfd54 refactor: use fewer raw C strings (#8201)
* refactor: tr_blocklistSetURL() takes a string_view

* refactor: tr_ctorSetMetainfoFromFile() takes a string_view

* refactor: tr_ctorSetMetainfoFromMagnetLink() takes a string_view

* refactor: tr_torrentSetDownloadDir() takes a string_view

* refactor: tr_ctorSetDownloadDir() takes a string_view

* refactor: tr_ctorSetIncompleteDir() takes a string_view

* refactor: tr_torrentSetTrackerList() takes a string_view

* refactor: tr_torrentRenamePath() now takes a std::string_view

* refactor: tr_torrentFindFromMagnetLink() takes a string_view
2026-01-22 16:31:08 -06:00
Charles Kerr
f6e9027da7 refactor: use fewer raw C strings (#8200)
* refactor: tr_sessionSaveSettings() takes a string_view

* refactor: tr_sessionSetDownloadDir() takes a string_view

* refactor: tr_sessionSetIncompleteDir() takes a string_view

* refactor: tr_sessionSetRPCCWhitelist() takes a string_view

* refactor: tr_sessionSetRPCPassword() takes a string_view

* refactor: tr_sessionSetRPCUsername() takes a string_view

* refactor: tr_sessionSetDefaultTrackers() takes a string_view

* refactor: tr_sessionSetScript() takes a string_view
2026-01-22 14:38:20 -06:00
Charles Kerr
87511c7123 test: add Session tests (#8185)
* build: disable some clang-tidy checks

we cannot use ranges while still supporting gcc 8

* refactor: add Prefs::keyval()

refactor: remove Prefs::getKey()

test: add Prefs::keyval() tests

* refactor: add Prefs::set(idx, tr_variant)

refactor: remove Prefs::type(idx)

refactor: remove Prefs::variant(idx)

* refactor: create RpcClient in main()

* test: add qt remote session tests
2026-01-21 22:36:41 -06:00