Commit Graph

551 Commits

Author SHA1 Message Date
Cœur
c56723ef1f chore: compatibility with clang-format 20 to 21 (#7499) 2025-12-15 23:55:32 -06:00
Charles Kerr
109bc70511 feat: use api_compat for torrent .resume files (#7932)
* test: add benc2cpp.py, a benc beautifier for hardcoded cpp test cases

* test: add .resume file unit test

* refactor: use api_compat::convert_incoming_data() and convert_outgoing_data() on .resume files

* chore: mark TR_KEY_peers2_6_kebab as APICOMPAT

* chore: mark TR_KEY_speed_Bps_kebab as APICOMPAT

* chore: mark TR_KEY_use_speed_limit_kebab as APICOMPAT

* chore: mark as APICOMPAT: TR_KEY_use_global_speed_limit_kebab

* chore: mark as APICOMPAT: TR_KEY_ratio_mode_kebab

* chore: mark as APICOMPAT: TR_KEY_idle_limit_kebab

* chore: mark as APICOMPAT: TR_KEY_idle_mode_kebab

* chore: mark as APICOMPAT: TR_KEY_max_peers_kebab

* chore: mark as APICOMPAT: TR_KEY_added_date_kebab

* chore: mark as APICOMPAT: TR_KEY_seeding_time_seconds_kebab

* chore: mark as APICOMPAT: TR_KEY_downloading_time_seconds_kebab

* chore: mark as APICOMPAT: TR_KEY_bandwidth_priority

* chore: mark as APICOMPAT: TR_KEY_done_date_kebab

* chore: mark as APICOMPAT: TR_KEY_activity_date_kebab

* chore: remove remaining _kebab cases from resume.cc

* chore: clang-format
2025-12-15 09:43:40 -06:00
Charles Kerr
9a792046f3 feat: add libtransmission::api_compat::convert() (#7917)
Add a module to convert between tr4 and tr5 RPC / settings / config file payloads.

This will be used as a compatibility layer between Transmission 5's naming scheme
and Transmission <= 4.

Co-authored-by: Yat Ho <lagoho7@gmail.com>
Co-authored-by: Dzmitry Neviadomski <nevack.d@gmail.com>
2025-12-14 10:56:07 -06:00
Charles Kerr
0fcda4e977 feat: add tr_variant::visit() (#7923)
* refactor: make tr_variant work with std::visit()

* refactor: use tr_variant::visit() in tr_variant_serde

* refactor: use tr_variant::visit() in tr_variant::merge()

* refactor: simplify JsonWriter

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

* test: simplify VariantTest.visitsNodesDepthFirst()

* test: simplify VariantTest.visitNestedJsonSummarizesStructure()

* feat: add tr_variant::clone()

* test: simplify variant tests

* docs: add code comments for tr_variant::merge() and tr_variant::clone()

* fix: add stack-smashing handling for JSON parsing

* fix: clang-tidy modernize-raw-string-literal

* Use writer.Key() for object key names

* refactor: remove unnecessary FMT_COMPILE() macros

* refactor: fix tr_variant::VisitAdapter to preserve the visitor category

chore: remove unnecessary std::cref() calls when calling tr_variant::visitor()

---------

Co-authored-by: Yat Ho <lagoho7@gmail.com>
2025-12-13 13:47:54 -06:00
Charles Kerr
e671c0346c feat: add tr_variant::Map methods (#7910)
* feat: add tr_variant::Map::contains()

* feat: add tr_variant::Map::replace_key()

* fixup! feat: add tr_variant::Map::replace_key()

fix readability-braces-around-statements

* fixup! feat: add tr_variant::Map::contains()

readability-container-contains
2025-12-09 21:16:59 -06:00
Charles Kerr
a630787340 test: add rpc tests for legacy & jsonrpc free_space requests, responses (#7905) 2025-12-09 16:19:01 -06:00
Charles Kerr
fece4137c7 refactor: add tr_variant::unmanaged_string(tr_quark) (#7906)
* feat: add tr_variant::unmanaged_string(tr_quark)

* refactor: use tr_variant::unmanaged_string(tr_quark)
2025-12-09 14:58:15 -06:00
Charles Kerr
0979bbcc3f refactor: intern RPC method names (#7892)
* refactor: add quarks for the RPC method names

* update tr_quark_convert() to handle RPC method names

* refactor: use interned keys for RPC method names

* test: add torrentGetLegacy test

* refactor: use interned keys for RPC method names in tr-qt

* refactor: use interned keys for RPC method names in tr-remote

* refactor: use interned keys for RPC method names in tests

* refactor: use interned keys for RPC method names in tr-gtk

* chore: fix readability-identifier-naming regression
2025-12-09 11:48:09 -06:00
Yat Ho
095bad6568 fix: check if piece is wanted upon receiving block (#7866)
* fix: check if piece is wanted upon receiving block

* test: block_last_loc
2025-12-08 15:43:56 -06:00
Yat Ho
9dd9aab902 build: bump clang tools to 20 (#7573)
* build: bump to clang-format-20

* build: bump to clang-tidy-20

* chore: revert edc59ba5d8
2025-12-01 23:18:02 -06:00
Yat Ho
05aef3e787 refactor: unify quarks and strings to snake_case (#7108)
* refactor: change `leftUntilDone` to `left_until_done`

* refactor: change `magnetLink` to `magnet_link`

* refactor: change `manualAnnounceTime` to `manual_announce_time`

* refactor: change `maxConnectedPeers` to `max_connected_peers`

* refactor: change `metadataPercentComplete` to `metadata_percent_complete`

* refactor: change `peersConnected` to `peers_connected`

* refactor: change `peersFrom` to `peers_from`

* refactor: change `peersGettingFromUs` to `peers_getting_from_us`

* refactor: change `peersSendingToUs` to `peers_sending_to_us`

* refactor: change `percentComplete` to `percent_complete`

* refactor: change `percentDone` to `percent_done`

* refactor: change `pieceCount` to `piece_count`

* refactor: use quark when possible

* refactor: change `pieceSize` to `piece_size`

* refactor: change `primary-mime-type` to `primary_mime_type`

* refactor: change `rateDownload` to `rate_download`

* refactor: change `rateUpload` to `rate_upload`

* refactor: change `recheckProgress` to `recheck_progress`

* refactor: change `secondsDownloading` to `seconds_downloading`

* refactor: change `secondsSeeding` to `seconds_seeding`

* refactor: change `sizeWhenDone` to `size_when_done`

* refactor: change `startDate` to `start_date`

* refactor: change `trackerStats` to `tracker_stats`

* refactor: change `totalSize` to `total_size`

* refactor: change `torrentFile` to `torrent_file`

* refactor: change `uploadedEver` to `uploaded_ever`

* refactor: change `uploadRatio` to `upload_ratio`

* refactor: change `webseedsSendingToUs` to `webseeds_sending_to_us`

* refactor: change `bytesCompleted` to `bytes_completed`

* refactor: change `clientName` to `client_name`

* refactor: change `clientIsChoked` to `client_is_choked`

* refactor: change `clientIsInterested` to `client_is_interested`

* refactor: change `flagStr` to `flag_str`

* refactor: change `isDownloadingFrom` to `is_downloading_from`

* refactor: change `isEncrypted` to `is_encrypted`

* refactor: change `isIncoming` to `is_incoming`

* refactor: change `isUploadingTo` to `is_uploading_to`

* refactor: change `isUTP` to `is_utp`

* refactor: change `peerIsChoked` to `peer_is_choked`

* refactor: change `peerIsInterested` to `peer_is_interested`

* refactor: change `rateToClient` to `rate_to_client`

* refactor: change `rateToPeer` to `rate_to_peer`

* refactor: change `fromCache` to `from_cache`

* refactor: change `fromDht` to `from_dht`

* refactor: change `fromIncoming` to `from_incoming`

* refactor: change `fromLpd` to `from_lpd`

* refactor: change `fromLtep` to `from_ltep`

* refactor: change `fromPex` to `from_pex`

* refactor: change `fromTracker` to `from_tracker`

* refactor: change `announceState` to `announce_state`

* refactor: change `downloadCount` to `download_count`

* refactor: change `hasAnnounced` to `has_announced`

* refactor: change `hasScraped` to `has_scraped`

* refactor: change `isBackup` to `is_backup`

* refactor: change `lastAnnouncePeerCount` to `last_announce_peer_count`

* refactor: change `lastAnnounceResult` to `last_announce_result`

* refactor: change `lastAnnounceStartTime` to `last_announce_start_time`

* refactor: change `lastAnnounceSucceeded` to `last_announce_succeeded`

* refactor: change `lastAnnounceTime` to `last_announce_time`

* refactor: change `lastAnnounceTimedOut` to `last_announce_timed_out`

* refactor: change `lastScrapeResult` to `last_scrape_result`

* refactor: change `lastScrapeStartTime` to `last_scrape_start_time`

* refactor: change `lastScrapeSucceeded` to `last_scrape_succeeded`

* refactor: change `lastScrapeTime` to `last_scrape_time`

* refactor: change `lastScrapeTimedOut` to `last_scrape_timed_out`

* refactor: change `leecherCount` to `leecher_count`

* refactor: change `nextAnnounceTime` to `next_announce_time`

* refactor: change `nextScrapeTime` to `next_scrape_time`

* refactor: change `scrapeState` to `scrape_state`

* refactor: change `seederCount` to `seeder_count`

* refactor: change `torrent-added` to `torrent_added`

* refactor: change `torrent-duplicate` to `torrent_duplicate`

* refactor: change `torrent-remove` to `torrent_remove`

* refactor: change `delete-local-data` to `delete_local_data`

* refactor: change `torrent-rename-path` to `torrent_rename_path`

* refactor: change `alt-speed-down` to `alt_speed_down`

* refactor: convert `pref_toggle_entries` to quark array

* refactor: change `alt-speed-enabled` to `alt_speed_enabled`

* refactor: change `compact-view` to `compact_view`

* refactor: change `sort-reversed` to `sort_reversed`

* refactor: change `show-filterbar` to `show_filterbar`

* refactor: change `show-statusbar` to `show_statusbar`

* refactor: change `show-toolbar` to `show_toolbar`

* refactor: change `alt-speed-time-begin` to `alt_speed_time_begin`

* refactor: change `alt-speed-time-day` to `alt_speed_time_day`

* refactor: change `alt-speed-time-end` to `alt_speed_time_end`

* refactor: change `alt-speed-up` to `alt_speed_up`

* refactor: change `alt-speed-time-enabled` to `alt_speed_time_enabled`

* refactor: change `blocklist-enabled` to `blocklist_enabled`

* refactor: change `blocklist-size` to `blocklist_size`

* refactor: change `blocklist-url` to `blocklist_url`

* refactor: change `cache-size-mb` to `cache_size_mb`

* refactor: change `config-dir` to `config_dir`

* refactor: change `default-trackers` to `default_trackers`

* refactor: change `dht-enabled` to `dht_enabled`

* refactor: change `download-dir-free-space` to `download_dir_free_space`

* refactor: change `download-queue-enabled` to `download_queue_enabled`

* refactor: change `download-queue-size` to `download_queue_size`

* refactor: change `idle-seeding-limit-enabled` to `idle_seeding_limit_enabled`

* refactor: change `idle-seeding-limit` to `idle_seeding_limit`

* refactor: change `incomplete-dir-enabled` to `incomplete_dir_enabled`

* refactor: change `incomplete-dir` to `incomplete_dir`

* refactor: change `lpd-enabled` to `lpd_enabled`

* refactor: change `peer-limit-global` to `peer_limit_global`

* refactor: change `peer-limit-per-torrent` to `peer_limit_per_torrent`

* refactor: change `peer-port-random-on-start` to `peer_port_random_on_start`

* refactor: change `peer-port` to `peer_port`

* refactor: change `pex-enabled` to `pex_enabled`

* refactor: change `port-forwarding-enabled` to `port_forwarding_enabled`

* refactor: change `queue-stalled-enabled` to `queue_stalled_enabled`

* refactor: change `queue-stalled-minutes` to `queue_stalled_minutes`

* refactor: change `rename-partial-files` to `rename_partial_files`

* refactor: change `rpc-version-minimum` to `rpc_version_minimum`

* refactor: change `rpc-version-semver` to `rpc_version_semver`

* refactor: change `rpc-version` to `rpc_version`

* refactor: change `script-torrent-added-enabled` to `script_torrent_added_enabled`

* refactor: change `script-torrent-added-filename` to `script_torrent_added_filename`

* refactor: change `script-torrent-done-enabled` to `script_torrent_done_enabled`

* refactor: change `script-torrent-done-filename` to `script_torrent_done_filename`

* refactor: change `script-torrent-done-seeding-enabled` to `script_torrent_done_seeding_enabled`

* refactor: change `script-torrent-done-seeding-filename` to `script_torrent_done_seeding_filename`

* refactor: change `seed-queue-enabled` to `seed_queue_enabled`

* refactor: change `seed-queue-size` to `seed_queue_size`

* refactor: change `seedRatioLimited` to `seed_ratio_limited`

* refactor: change `session-id` to `session_id`

* refactor: change `speed-limit-down-enabled` to `speed_limit_down_enabled`

* refactor: change `speed-limit-down` to `speed_limit_down`

* refactor: change `speed-limit-up-enabled` to `speed_limit_up_enabled`

* refactor: change `speed-limit-up` to `speed_limit_up`

* refactor: change `start-added-torrents` to `start_added_torrents`

* refactor: change `trash-original-torrent-files` to `trash_original_torrent_files`

* refactor: change `utp-enabled` to `utp_enabled`

* refactor: change `tcp-enabled` to `tcp_enabled`

* docs: add missing docs for RPC `tcp_enabled`

* refactor: change `speed-units` to `speed_units`

* refactor: change `speed-bytes` to `speed_bytes`

* refactor: change `size-units` to `size_units`

* refactor: change `size-bytes` to `size_bytes`

* refactor: change `memory-units` to `memory_units`

* refactor: change `memory-bytes` to `memory_bytes`

* refactor: change `session-set` to `session_set`

* refactor: change `session-get` to `session_get`

* refactor: change `session-stats` to `session_stats`

* refactor: change `activeTorrentCount` to `active_torrent_count`

* refactor: change `downloadSpeed` to `download_speed`

* refactor: change `pausedTorrentCount` to `paused_torrent_count`

* refactor: change `torrentCount` to `torrent_count`

* refactor: change `uploadSpeed` to `upload_speed`

* refactor: change `cumulative-stats` to `cumulative_stats`

* refactor: change `current-stats` to `current_stats`

* refactor: change `uploadedBytes` and `uploaded-bytes` to `uploaded_bytes`

* refactor: change `downloadedBytes` and `downloaded-bytes` to `downloaded_bytes`

* refactor: change `filesAdded` and `files-added` to `files_added`

* refactor: change `sessionCount` and `session-count` to `session_count`

* refactor: change `secondsActive` and `seconds-active` to `seconds_active`

* refactor: change `blocklist-update` to `blocklist_update`

* refactor: change `port-test` to `port_test`

* refactor: change `session-close` to `session_close`

* refactor: change `queue-move-top` to `queue_move_top`

* refactor: change `queue-move-up` to `queue_move_up`

* refactor: change `queue-move-down` to `queue_move_down`

* refactor: change `queue-move-bottom` to `queue_move_bottom`

* refactor: change `free-space` to `free_space`

* refactor: change `group-set` to `group_set`

* refactor: change `group-get` to `group_get`

* refactor: change `announce-ip` to `announce_ip`

* refactor: change `announce-ip-enabled` to `announce_ip_enabled`

* refactor: change `upload-slots-per-torrent` to `upload_slots_per_torrent`

* refactor: change `trash-can-enabled` to `trash_can_enabled`

* refactor: change `watch-dir-enabled` to `watch_dir_enabled`

* refactor: change `watch-dir-force-generic` to `watch_dir_force_generic`

* refactor: change `watch-dir` to `watch_dir`

* refactor: change `message-level` to `message_level`

* refactor: change `scrape-paused-torrents-enabled` to `scrape_paused_torrents_enabled`

* refactor: change `torrent-added-verify-mode` to `torrent_added_verify_mode`

* refactor: change `sleep-per-seconds-during-verify` to `sleep_per_seconds_during_verify`

* refactor: change `bind-address-ipv4` to `bind_address_ipv4`

* refactor: change `bind-address-ipv6` to `bind_address_ipv6`

* refactor: change `peer-congestion-algorithm` to `peer_congestion_algorithm`

* refactor: change `peer-socket-tos` to `peer_socket_tos`

* refactor: change `peer-port-random-high` to `peer_port_random_high`

* refactor: change `peer-port-random-low` to `peer_port_random_low`

* refactor: change `anti-brute-force-enabled` to `anti_brute_force_enabled`

* refactor: change `rpc-authentication-required` to `rpc_authentication_required`

* refactor: change `rpc-bind-address` to `rpc_bind_address`

* refactor: change `rpc-enabled` to `rpc_enabled`

* refactor: change `rpc-host-whitelist` to `rpc_host_whitelist`

* refactor: change `rpc-host-whitelist-enabled` to `rpc_host_whitelist_enabled`

* refactor: change `rpc-password` to `rpc_password`

* refactor: change `rpc-port` to `rpc_port`

* refactor: change `rpc-socket-mode` to `rpc_socket_mode`

* refactor: change `rpc-url` to `rpc_url`

* refactor: change `rpc-username` to `rpc_username`

* refactor: change `rpc-whitelist` to `rpc_whitelist`

* refactor: change `rpc-whitelist-enabled` to `rpc_whitelist_enabled`

* refactor: change `ratio-limit-enabled` to `ratio_limit_enabled`

* refactor: change `ratio-limit` to `ratio_limit`

* refactor: change `show-options-window` to `show_options_window`

* refactor: change `open-dialog-dir` to `open_dialog_dir`

* refactor: change `inhibit-desktop-hibernation` to `inhibit_desktop_hibernation`

* refactor: change `show-notification-area-icon` to `show_notification_area_icon`

* refactor: change `start-minimized` to `start_minimized`

* refactor: change `torrent-added-notification-enabled` to `torrent_added_notification_enabled`

* refactor: change `anti-brute-force-threshold` to `anti_brute_force_threshold`

* refactor: change `torrent-complete-notification-enabled` to `torrent_complete_notification_enabled`

* refactor: change `prompt-before-exit` to `prompt_before_exit`

* refactor: change `sort-mode` to `sort_mode`

* refactor: change `statusbar-stats` to `statusbar_stats`

* refactor: change `show-extra-peer-details` to `show_extra_peer_details`

* refactor: change `show-backup-trackers` to `show_backup_trackers`

* refactor: change `blocklist-date` to `blocklist_date`

* refactor: change `blocklist-updates-enabled` to `blocklist_updates_enabled`

* refactor: change `main-window-layout-order` to `main_window_layout_order`

* refactor: change `main-window-height` to `main_window_height`

* refactor: change `main-window-width` to `main_window_width`

* refactor: change `main-window-x` to `main_window_x`

* refactor: change `main-window-y` to `main_window_y`

* refactor: change `filter-mode` to `filter_mode`

* refactor: change `filter-trackers` to `filter_trackers`

* refactor: change `filter-text` to `filter_text`

* refactor: change `remote-session-enabled` to `remote_session_enabled`

* refactor: change `remote-session-host` to `remote_session_host`

* refactor: change `remote-session-https` to `remote_session_https`

* refactor: change `remote-session-password` to `remote_session_password`

* refactor: change `remote-session-port` to `remote_session_port`

* refactor: change `remote-session-requres-authentication` to `remote_session_requires_authentication`

* refactor: change `remote-session-username` to `remote_session_username`

* refactor: change `torrent-complete-sound-command` to `torrent_complete_sound_command`

* refactor: change `torrent-complete-sound-enabled` to `torrent_complete_sound_enabled`

* refactor: change `user-has-given-informed-consent` to `user_has_given_informed_consent`

* refactor: change `read-clipboard` to `read_clipboard`

* refactor: change `details-window-height` to `details_window_height`

* refactor: change `details-window-width` to `details_window_width`

* refactor: change `main-window-is-maximized` to `main_window_is_maximized`

* refactor: change `port-is-open` to `port_is_open`

* refactor: change `show-tracker-scrapes` to `show_tracker_scrapes`

* refactor: change `max-peers` to `max_peers`

* refactor: change `peers2-6` to `peers2_6`

* refactor: change `seeding-time-seconds` to `seeding_time_seconds`

* refactor: change `downloading-time-seconds` to `downloading_time_seconds`

* refactor: change `ratio-mode` to `ratio_mode`

* refactor: change `idle-limit` to `idle_limit`

* refactor: change `idle-mode` to `idle_mode`

* refactor: change `speed-Bps` to `speed_Bps`

* refactor: change `use-global-speed-limit` to `use_global_speed_limit`

* refactor: change `use-speed-limit` to `use_speed_limit`

* chore: remove TODO comment

* docs: add upgrade instructions to `5.0.0`

* chore: bump rpc semver major version

* chore: housekeeping
2025-12-01 16:08:18 -06:00
Yat Ho
1cb24a701b feat: new JSON-RPC 2.0 RPC API (#7269)
* feat: add enum for JSON-RPC error codes

* feat: new `tr_rpc_request_exec()` overload that accepts string

* feat: add JSON-RPC parse error handling

* feat: add logic for branching to JSON-RPC or legacy API

* feat: error codes for existing errors strings

* refactor: async handlers now take the done cb as parameter

* feat: support non-batch JSON-RPC requests

* feat: support batch JSON-RPC requests

* refactor: move JSON-RPC error codes to header

* test: new tests for JSON-RPC

* refactor(webui): use jsonrpc api

* docs: update docs for jsonrpc

* fix: clang-tidy warning

* perf: avoid copying callback in batch mode

* code review: don't commit to dropping old RPC

* chore: fix shadowed variable warnings
2025-11-30 10:04:40 -06:00
Yat Ho
25d2ebf8fc refactor: overhaul tr_address special address checks (#7818)
* refactor: rewrite is_martian_addr() with tr_address methods

- Fix broken check for IPv4 multicast address in is_martian_address()

* refactor: rewrite is_global_unicast_address()

- Rewrite using new tr_address methods
- Add missing IPv4 loopback check
- Follow RFC 4291 IPv6 global unicast definition
- Fix and update existing tests

* chore: reorganise methods and add comments

* fix: check for teredo and 6to4

* test: tests for new methods
2025-11-21 18:09:38 -06:00
Charles Kerr
73e6892a74 refactor: let client pass in translated string of None when calling tr_strratio() (#7805) 2025-11-14 10:04:04 -06:00
Yat Ho
8dc5d925fe feat: convert preferred-transport to preferred_transports (#7473)
* feat: store `preferred_transports` as array in `settings.json`

* refactor: `Settings::save()` returns `tr_variant::Map`

* feat: new RPC API for `preferred_transports`

* feat: new arg `--preferred-transports` for remote
2025-11-12 17:17:29 -06:00
Yat Ho
4318a6f1ac fix: caching a source address doesn't imply public internet connectivity (#7520) 2025-11-12 14:46:26 -06:00
Geoffrey Bonneville
0f7f460c55 feat: allow downloading sequentially from a specific piece (#7502)
* feat: allow downloading sequentially from a specific piece

* Apply review changes

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

* Use sequential_download_from_piece param in torrent-add, and save it to resume file

* fix: change observable type bool -> tr_piece_index_t

* fix: run code_style.sh

* fix: improved test and missing comment

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

* fix: apply similar changes to sequentialDownloadFromPiece test

* docs: change parameter type boolean -> number

---------

Co-authored-by: Yat Ho <lagoho7@gmail.com>
2025-11-11 09:32:57 -06:00
Charles Kerr
a5d09b29ff chore: move tr_rpc_parse_list_str() from libtransmission to remote.cc (#7797)
libtransmission hasn't used this since 822fabb2 (#3549)
2025-11-11 09:31:19 -06:00
Yat Ho
b3424ed260 feat: match IPv4-mapped addresses with IPv4 whitelist (#7523)
* feat: match IPv4-mapped addresses with IPv4 whitelist

* test: for converting IPv4-mapped to native IPv4

* perf: avoid copying in `tr_wildmat()`
2025-11-07 20:26:45 -06:00
Yat Ho
2a3a8ea364 perf: even faster wishlist (#7744)
* chore: add comments to annotate observer dependencies

* refactor: overhaul wishlist

Avoid expensive `count_active_requests` and `has_active_request_to_peer`.
- Remove "endgame"
- Never rebuild candidate list mid-download

* chore: code cleanup

* test: fix

* perf: sort block list in reverse order

* refactor: reduce request timeout from 90 to 15 seconds
2025-11-02 11:55:38 -06:00
Yat Ho
41dd2cfd53 fix: accept either one of udp announce response (#7583)
* fix: accept either one of udp announce response

* fix: udp announcer tests should read packets in-order

* test: housekeeping

* test: new tests for the new logic
2025-10-27 12:08:59 -05:00
Charles Kerr
454b810698 fix: performance-for-range-copy warning in tr-peer-info-test.cc (#7741)
this warning broke the clang-tidy-libtransmission-win32 CI
2025-10-26 21:07:52 -05:00
Yat Ho
0715897fc8 feat: use canonical peer priority to decide which peers to keep (#6981)
* feat: CRC32-C

* feat: canonical peer priority calculation bep-40

* test: add test cases for IPv4 canonical peer priority

* refactor: compare by canonical priority

* fix: use network byte order for peer ports

* test: more cases

* build: xcode

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

* ci: test system crc32c library

---------

Co-authored-by: Dzmitry Neviadomski <nevack.d@gmail.com>
2025-10-25 12:05:20 -05:00
Yat Ho
e7d4a69107 fix: update wishlist when files wanted changed (#7733)
* refactor: extract salt calculation to method

* fix: update wishlist when files wanted changed
2025-10-24 20:48:48 -05:00
Yat Ho
894c0859aa ci: run clang-tidy for tests (#7526)
* ci: run clang-tidy for tests

* fix: clang-tidy warnings

* ci: run clang-tidy only when needed
2025-10-15 19:21:34 -05:00
Yat Ho
bf5507ff24 fix: load .torrent then .magnet (#7585) 2025-10-15 12:16:32 -05:00
Yat Ho
9c14fa58d8 feat: allow optional arguments in tr_getopt() (#7510)
* feat: allow optional arguments in `tr_getopt()`

* test: new tests for optional arg

* code review: `using Arg = tr_option::Arg`

* refactor: static assert option array size

* test: add new tests for missing arguments in the middle

* test: static auto constexpr
2025-10-15 12:08:11 -05:00
Yat Ho
bf461a0f72 refactor: removed redundant type check in tr_ip_cache::set_global_addr() (#7551)
* refactor: removed redundant type check in `tr_ip_cache::set_global_addr()`

* chore: tweak formatting
2025-10-14 13:00:01 -05:00
Yat Ho
08ec7fb7c7 build: lint header files with clang-tidy (#7527)
* build: clang-tidy headers when building libtransmission

* chore: revert `= default` workaround

It was introduced in 6909ec0bad to fix build issues with macOS 10.14. We
no longer support that version.

* fix: clang-tidy warnings for libtransmission

* build: clang-tidy headers when building tests

* fix: clang-tidy warnings for tests

* build: clang-tidy headers when building qt

* code review: don't manually edit mime-types.h

* code review: unify variable naming for static private members
2025-05-07 22:10:16 +01:00
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