618 Commits

Author SHA1 Message Date
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
Charles Kerr
7f5730984a refactor: add tr_strv_to_utf8_nsstring() (#8174)
* refactor: rename enum types in ip-cache private enum class is_updating_t

this avoids name collisions with YES and NO on macOS

* refactor: rename tr_strv_convert_utf8() to tr_strv_to_utf8_string()

use a name that is symmetrical with the upcoming tr_strv_to_utf8_nsstring()

* feat: add tr_strv_to_utf8_nsstring()

* test: add tests for the new tr_strv_to_utf8_nsstring() methods
2026-01-21 08:25:07 -06:00
Charles Kerr
62be679769 refactor: remove tr_session* argument from tr_rpc_response_func (#8160) 2026-01-20 19:44:06 -06:00
Yat Ho
cbc5388440 build: bump to C++20 (#7191)
* build: bump to C++20

Co-authored-by: Cœur <coeur@gmx.fr>

* refactor: use designated initializers

* refactor: remove redundant SFINAE

* fix: clang-tidy warnings

* chore: comments about min compiler versions for C++20 features

* build: clang objc++ modules build errors

Co-authored-by: Dzmitry Neviadomski <nevack.d@gmail.com>

* refactor: add `TR_CONSTEXPR_VEC` and `TR_CONSTEXPR_STR`

* fix: don't use `std::rel_ops`

* chore: housekeeping

* fix: possible fix for macOS linker error

---------

Co-authored-by: Cœur <coeur@gmx.fr>
Co-authored-by: Dzmitry Neviadomski <nevack.d@gmail.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2026-01-20 16:27:34 -06:00
Yat Ho
4e03de7630 fix: use weak pointers for ip cache curl callback (#8157) 2026-01-16 17:11:03 -06:00
Charles Kerr
a8f531b572 fix: remove unused tr_strbuf::join() (#8144) 2026-01-15 14:37:22 -06:00
Charles Kerr
677e0a6335 test: add tests for RpcClient (#8137)
* refactor do not cache style in convert_outgoing_data() -- not testing-friendly

* refactor: pass a QNetworkAccessManager into RpcClient constructor

this way we can inject a fake one in tests

* refactor: add RpcClient tests

* refactor: remove pointless QVERIFY call

* refactor: add api_compat::default_style()

* refactor: add api_compat::set_default_style()

* test: parameterize RpcClient tests for Tr4 and Tr5
2026-01-14 13:52:10 -06:00
Charles Kerr
70bc3eec48 perf: faster tests (#8113)
* refactor: make libcurl thread shutdown faster during tests

* docs: fix out-of-date code comment in web.h

* refactor: tr_sessionClose() now takes fractions of seconds for deadline

refactor: make tr_web::startShutdown() deadline dependent on the tr_sessionClose() deadline arg

* test: set tr_sessionClose() deadline of 0.5 secs

* refactor: FileTest now inherits from SandboxedTest

* fixup! test: set tr_sessionClose() deadline of 0.5 secs
2026-01-13 19:08:25 -06:00
Yat Ho
3df2b2fb14 refactor: implement tr_strv_sep() as a wrapper of find_first_of() (#8117)
* refactor: implement `tr_strv_sep()` as a wrapper of `find_first_of()`

* test: `tr_strv_sep` other overloads
2026-01-13 17:05:22 -06:00
Charles Kerr
8dea0e863f fix: several CI errors (#8124)
* Revert "build(cmake): support building with (almost) all system 3rd-party libraries (#7554)"

This reverts commit a89ca4f2c9.

* fixup! refactor: use a map of getters, setters for `session_get` and `session_set` properties (#8024)

fix: capture-by-reference error in session_accessors()

* fix: 'Qt depends on a UTF-8 locale' CI warning

* fix: 'qt.qpa.xcb: could not connect to display' CI error
2026-01-13 13:16:40 -06:00
Charles Kerr
6f32b8d5dd refactor: move display types to UserMetaType.h (#8116) 2026-01-12 20:07:55 -06:00
Yat Ho
a89ca4f2c9 build(cmake): support building with (almost) all system 3rd-party libraries (#7554)
* build: overhaul tr_add_external_auto_library

* build: use package-provided CMake config file libevent

* build: use package-provided CMake config file miniupnpc

* build: update libutp find module

* build: make LIBNAME an optional parameter

* build: use package-provided CMake config file libdeflate

* build: update libb64 find module

* build: update libnatpmp find module

* build: update libpsl find module

* build: support system fast_float library

* chore: reformat long brew commands

* build: support system fmt library

* build: support system rapidjson library

* build: support system small library

* build: support system library utf8cpp

* build: support system library WideInteger

* build: support system library gtest

* fix: incorrectly labeled test suites

* build: remove unused parameters from tr_add_external_auto_library

* build: update crc32c cmake script

* fix: dht system library

* fix: add libutp interface target

* code review: move TrGtest.cmake

* code review: move tr_get_fmt_version into Findfmt.cmake

* code review: use option() for gtest

* code review: move find_package(PkgConfig) out of loop

* build: delete FindCrc32c.cmake

Impossible to parse package version from distributed source files.

* code review: Finddht.cmake

* build: delete FindFastFloat.cmake

Impossible to parse package version from distributed source files.

* code review: Findfmt.cmake

* code review: Findlibb64.cmake

* code review: Findlibdeflate.cmake

* code review: Findlibevent.cmake

* code review: Findlibnatpmp.cmake

* code review: Findlibpsl.cmake

* code review: Findlibutp.cmake

* code review: Findlibminiupnpc.cmake

* code review: FindRapidJSON.cmake

* build: delete FindSmall.cmake

Impossible to parse package version from distributed source files.

* build: only accept cmake config package for utf8cpp

Impossible to parse package version from distributed source files.

* build: delete FindWideInteger.cmake

Impossible to parse package version from distributed source files.

* build: add `USE_SYSTEM_DEFAULT`

* ci: drop Fedora 40 and adopt Fedora 43

* ci: try to silence system header warnings

* ci: use `cmake --install`

* Revert "build: only accept cmake config package for utf8cpp"

This reverts commit 2158d631fd.

* build: harden utf8cpp find module

* chore: bump wide-integer

Pick up bf9398f9da and bcc726a30f

* refactor: gtest should be included with angled brackets

Now that gtest is built as a system library, it should be included with angled brackets instead of quotes.

* code review: fixup libutp variables before `find_package_handle_standard_args`

* code review: define `WIDE_INTEGER_HAS_LIMB_TYPE_UINT64` only for targets depending on WideInteger

* chore: bump wide-integer

Pickup 4b2258acac so that wide-integer tests won't run in Transmission project.
2026-01-12 09:04:47 -06:00
Charles Kerr
d177f9f903 test: add unit tests for Prefs (#8112)
* fix: hicpp-use-auto,modernize-use-auto

* refactor: make Prefs::getKey() a static method

refactor: make Prefs::isCore() a static method

refactor: make Prefs::type() a static method

* refactor: Application takes a Prefs& arg, not a std::unique_ptr<Prefs> arg

* fix: bugprone-exception-escape

save settings by calling prefs.save() from main()

* refactor: load settings by calling prefs.load() from main()

* refactor: use preferred declaration order in Prefs

* fixup! fix: bugprone-exception-escape

* refactor: add Prefs::current_values()

* refactor: clean up namespace use in Prefs.cc

* feat: add QString, QDateTime serializers

* test: add scaffolding for testing Qt code

test: add tests for Prefs

* refactor: remove unused #includes

* build: add clang-tidy rules to tests/qt/

* refactor: clean up the new test code a little

* chore: add missing copyright statement

* ci: ensure Qt6Test is installed

build: check for QTest when ENABLE_TESTS + ENABLE_QT are ON

* fixup! feat: add QString, QDateTime serializers

* fix: Wswitch warning

* build: do not disable tests in release/windows/build-qt5.psl, build-qt6.psl

* ci: set QT_QPA_PLATFORM for running new Qt tests

* test: build cleanly in Qt 5.15

* fixup! fixup! feat: add QString, QDateTime serializers

fix QDateTime serializer on macOS

* fixup! ci: set QT_QPA_PLATFORM for running new Qt tests

install xcb-util-cursor on alpine
2026-01-11 19:23:00 -06:00
Yat Ho
cf0a596a45 fix: url port parsing (#8109)
* fix: url port parsing

- `tr_urlParse()` should fail if cannot parse port
- Avoid parsing scheme ports to numbers
- Port should not be parsed to a negative number
- Port should not be parsed to `0`
- Directly parse number string to `uint16_t`

* test: invalid port
2026-01-11 11:43:12 -06:00
Charles Kerr
47832db7b2 refactor: move tr_diffserv_t::Names into serializer (#8088)
* refactor: move tr_diffserv_t::Names into serializer

* Update libtransmission/serializer.cc
2026-01-09 14:39:54 -06:00
Charles Kerr
d7d0d87f78 refactor: remove tr_url_query_view (#8049)
replace bespoke struct with std:: container
2026-01-02 22:39:37 -06:00
Yat Ho
3a4e115c52 fix: wishlist edge case when got bad piece in unaligned torrents (#8047)
* test: add failing test case

* fix: got bad piece in unaligned torrents
2026-01-02 13:04:53 -06:00
Yat Ho
f93165c0bc feat: unify encryption mode serialization format for settings.json and rpc (#8032)
* feat: `settings.json` `encryption` is now string

* feat: api-compat for encryption in `settings.json`

* feat: rpc now uses the same strings as `settings.json` for encryption modes

* feat: api-compat for encryption in rpc

* code review: use `to_variant()`
2026-01-02 11:38:54 -06:00