1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-21 23:32:35 +00:00
Commit graph

6201 commits

Author SHA1 Message Date
Yat Ho
5a05b37838
feat: support the JSON null type in tr_variant (#7255) 2024-12-15 16:50:19 -06:00
reardonia
5c714a5599
refactor: add handshake fire_timer() instead of overloading fire_done() (#6966) 2024-12-14 15:14:44 -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
b4bbc8744e
refactor: use evhttp public accessors in rpc server (#7112)
* refactor: use libevent public accessors in `handle_request()`

* chore: housekeeping in `handle_request()`

* refactor: use libevent public accessors in `make_response()`

* refactor: use libevent public accessors in `serve_file()`

* refactor: use libevent public accessors in `handle_web_client()`

* refactor: use libevent public accessors in `handle_rpc_from_json()`

* refactor: use libevent public accessors in `handle_rpc()`

* refactor: use libevent public accessors in `isHostnameAllowed()`

* refactor: use libevent public accessors in `test_session_id()`
2024-12-13 14:15:30 -06:00
Yat Ho
31a63f0045
feat: log when RPC server reject requests (#7114) 2024-12-12 16:12:02 -06:00
Yat Ho
dd58e42105
fix: send ltep handshake if received ltep handshake (#7204)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-12-12 15:19:03 -06:00
Yat Ho
b2ce9eea83
fix: obtain session lock before getting tor ptr (#7286) 2024-12-12 15:17:07 -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
002c891216
refactor: use string_view literals instead of C string literals (#7266) 2024-11-26 19:52:05 -06:00
Charles Kerr
d1a1a0adae
fix: clang-tidy header warnings, pt. 1 (#7228)
* fix: warning: deleted member function should be public [modernize-use-equals-delete]

* fix: warning: variable has inline specifier but is implicitly inlined [readability-redundant-inline-specifier]

* fix: warning: enum uses a larger base type than necessary for its value set [performance-enum-size]

* fix: warning: initializer for member is redundant [readability-redundant-member-init]

* warning: parameter is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
2024-11-17 20:04:55 -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
Yat Ho
5a881191d0
fix: allow unreachable peers to be retried (#6975)
`tr_peer_info::reconnect_interval_has_passed()` contains logic to increase the reconnect interval for unreachable peers, but it has no effect at all currently because they wouldn't be tried in the first place.
2024-11-08 12:44:27 -06:00
Yat Ho
49f4c604da
fix: don't increment failure count when stopping torrent (#7238)
* fix: don't increment failure count when stopping torrent

* refactor: don't reset failure count on torrent stop
2024-11-08 12:42:59 -06:00
Yat Ho
6bf62959b4
refactor: set CURLOPT_MAXREDIRS once (#7233) 2024-11-06 14:36:34 -06:00
Yat Ho
f1102f0b4d
fix: don't double count webseed download data rate (#7235)
Regression from f1a53840f9
2024-11-06 13:55:58 -06:00
Yat Ho
7978120c41
fix: save resume when shutting down (#7216)
Regression from 24bb159bfe
Xref: https://trac.transmissionbt.com/ticket/2317
2024-11-02 16:08:00 -05:00
Charles Kerr
f988da6aa1
refactor: remove unused TR_SYS_FILE_APPEND (#7206) 2024-10-29 17:07:13 -05:00
Charles Kerr
c1047b8009
refactor: remove unused TR_SYS_FILE_LOCK_UN (#7207) 2024-10-29 00:14:53 -05:00
Yat Ho
d5d950e1cf
fix: always sort peer candidates by score (#7199) 2024-10-27 19:54:09 -05:00
Yat Ho
13987e7996
refactor: warn peer incompliant behaviour in ltep (#7203)
* refactor: add log warning for ut metadata in private torrent

* refactor: add log warning for ut pex in private torrent

* refactor: add log warning for ltep handshake without advertised support

* refactor: unify ltep handshake log format

* refactor: removed redundant ltep logs

* refactor: add back log for ut pex
2024-10-27 19:38:56 -05:00
Yat Ho
5cc0934ddb
fix: clear tracker error if tracker is removed (#7141) 2024-10-24 21:45:43 -05:00
Yat Ho
3ec271fe5a
fix: count webseeds when calculating piece replication (#7028) 2024-10-23 20:49:01 -05:00
Charles Kerr
19543ba65f
fix: clang-tidy-20 warnings (#7187)
* fix: readability-math-missing-parentheses clang-tidy warnings

* chore: remove unused function tr_ctorGetSession()

* chore: remove unused function tr_ctorGetIncompleteDir()

* chore: make generatePublicKey() a lambda

* fix: readability-container-contains warnings

* fix: misc-use-internal-linkage warnings

* chore: inline generate_public_key() since it was only used once
2024-10-21 20:57:01 -05:00
Yat Ho
89a88c6603
fix: date done and recently-active not updated on state change (#6992)
* fix: update `date_done_` as long as the torrent is done

* fix: `mark_change()` should be called as long as torrent state changes

* chore: remove redundant completeness update in `tr_torrent::start_in_session_thread()`

* fix: log whenever torrent state changes

* chore: add comment to explain `recent_change`

* chore: housekeeping

* fix: recover torrents with missing date done
2024-10-21 19:07:49 -05:00
Yat Ho
ab66f73c74
fix: properly reconnect on handshake error (#6950)
* fix: clear read buffer when closing connection

* fix: clear write buffer when closing connection

* fix: disable encryption when reconnecting

* refactor: dedupe code

* fix: maybe reconnect using MSE handshake if it was an utp failure

* chore: misc housekeeping

* chore: removed `tr_peerIo::utp_supported_`

* refactor: more logs in `tr_handshake::on_error()`
2024-10-21 17:45:58 -05:00
Yat Ho
b5cc6916ef
fix: don't retry plain handshake in AwaitingVc state (#6969) 2024-10-21 16:31:11 -05:00
Yat Ho
f37b8d9bf5
fixup! fix: update partial file suffix after verifying torrent (#6871) (#7072) 2024-10-14 07:43:18 -05:00
Yat Ho
c7c8c47850
perf: don't open torrent file descriptors with TR_SYS_FILE_SEQUENTIAL (#7089) 2024-10-13 21:56:44 -05:00
Yat Ho
61ecad4c43
fix: update torrent progress when verifying partially completed pieces (#7143)
* fix: update torrent progress when verifying partially completed pieces

* chore: restrict scope of local variable
2024-10-13 19:15:21 -05:00
Cœur
f5997eb5ed
remove TR_ASSERT(now >= latest) (#7018) 2024-10-13 14:34:45 -05:00
Yat Ho
21d7720749
refactor: improve criteria for choosing peers to save to resume (#6922)
* fix: only consider peers with listening ports interesting

It's a waste of space to store peers we cannot connect to (because we don't know what their listening port is).

* fix: don't consider peer as interesting just because we are currently connected to it

For example, it's possible for a peer to be "in-use" and "banned" at the same time, albeit just for a very short while.

* code review: assert that peer port is not empty
2024-10-13 13:48:49 -05:00
Yat Ho
4db50dae10
feat: save queue order between sessions (#6753)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-10-13 11:36:38 -05:00
Yat Ho
45f5a19950
fix: calculate size of one hash line in lpd correctly (#7136) 2024-10-13 08:36:32 -05:00
Yat Ho
9ff95d162e
fix: various pex flag bugs and cleanup (#6917)
* fix: allow connection between seeds when pex is enabled

* chore: add comment to explain `tr_peerMsgs::on_torrent_got_metainfo()`

* refactor: remove `tr_swarm::mark_peer_as_seed()`

* fix: update seed flag in response to BT msgs

Regression from 81a42c6bb6

* chore: remove redundant code to update peer seed flag

* refactor: inc failure count if there were no piece data exchanged

* fix: save information from ltep handshake

* refactor: rename `tr_peerIo::is_seed_` to disambiguate

* fix: add instead of set pex flags when adding non-pex and non-resume peers

* fix: don't mark peer as connectable on getting ltep port msg

By BEP-11's definition, this flag is only set for peers whom we successfully initiated an outgoing connection with.

* refactor: set holepunch flag when we get it from ltep handshake

* fix: only accept positive `reqq` in ltep handshake

* refactor: handle encryption preference in `tr_peer_info`

* refactor: prefer own value for utp support

* refactor: make `tr_peer_info::from_first_` const

* refactor: handle holepunch support in `tr_peer_info`

* fix: parse metadata size only if we have a valid extention id for metadata xfer

* refactor: remove `tr_peer_info::add_pex_flags()` as it's no longer needed

* fix: correctly handle holepunch support when there is no `m` key in ltep handshake

* fix: distinguish between upload only and seed

Say we just connected to a partial seed, the peer sends an ltep handshake that has the `upload_only` key, then a BT `Bitfield` message:

Without this change, the pex seed flag would be set when parsing the ltep handshake, then immediately unset when parsing the `Bitfield` message.

We don't want that.

* fix: don't update `tr_peer_info::is_seed_` when merging peer info objects

* perf: priority in peer candidate score need 2 bits only

* fix: prefer to connect to downloading peers

Regression from c867f00153

* chore: add TODO for C++20 opportunity

* refactor: don't filter out peers without `ADDED_F_CONNECTABLE`

revert change from a2849219f7

* refactor: move peer state updates out of peermgr code

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-09-08 22:05:03 -05:00
Yat Ho
461e178c8f
fix: don't process http announce error if already succeeded (#7086) 2024-09-02 16:24:35 -05:00
Yat Ho
1b57c294be
fix: process BT messages that immediately follows handshake (#6913)
* refactor: don't loop in `tr_handshake::can_read()`

* fix: return `READ_NOW` after handshake success

* code review: more accurate comment wording

* Revert "refactor: don't loop in `tr_handshake::can_read()`"

This reverts commit 4f33520cba6a38171ed203a071158aa37ddcd325.

* refactor: convert `ReadState` to enum class

* refactor: use new `ReadState` value to break out of loop
2024-08-24 17:04:28 -05:00
Yat Ho
34dbaaad7e
fix: add missing write() call in MSE handshake (#6891)
* refactor: tidy up variables in `tr_handshake::read_crypto_provide()`

* fix: make sure to send out `crypto_select`

* chore: fix comment

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-08-24 14:18:57 -05:00
Yat Ho
b1a765459a
fix: limit number of bad pieces to accept from a webseed (#6875)
* perf: initialise blame bitfield by piece count

* refactor: set blame for all peers

* refactor: make `tr_swarm::add_strike()` work for all peers

* refactor: move `tr_peer::do_purge` to `tr_peerMsgs`

* fix: limit number of bad pieces to accept from a webseed
2024-08-24 14:18:12 -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
Cœur
07172d9f4f
refactor: avoid front() prior to loop (#7068)
* refactor: avoid `front()` prior to loop

* Update libtransmission/peer-mgr.cc

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

---------

Co-authored-by: Yat Ho <lagoho7@gmail.com>
2024-08-23 10:34:44 -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
Yat Ho
1e16912ae4
refactor: new tr_variant API in transmission-remote and other cleanup (#6798)
* refactor: remove `Arguments`

* refactor: replace pointer args with lvalue reference

* refactor: use `uint16_t` for port number

* chore: housekeeping

* refactor: replace `char*` with `std::string_view`

* refactor: simplify argument parsing code

* refactor: use new `tr_variant` API in remote

* chore: rename function to snake_case

* chore: move `break` statements in switches outside of compound statements

* chore: use `std::string` literals

* refactor: extract tor start/stop to `MODE_TORRENT_START_STOP`

* refactor: extract tor actions to `MODE_TORRENT_ACTION`

* chore: iwyu

* fix: msvc build failure

* chore: misc cleanup

* fix: dereference optional

* chore: misc cleanup

* ui: fix minor formatting errors

* fix: remove redundant if branches for response string

* code review: remove `o` prefix for optionals

* code review: add condition clause

* code review: check `left_until_done` instead

* fix: unchecked nullptr

* code review: don't reassign method name

* code review: revert accidentally renaming `addIdArg` to `get_id_arg`

* code review: use `TR_ASSERT` instead of `assert`

* refactor: fix static auto constexpr naming

* code review: assert array size

* code review: assert that `arguments` key exists
2024-08-17 20:04:49 +01:00
Yat Ho
04c115f79c
fix: accurate timestamp in daemon logs (#7009)
* fix: accurate timestamp in daemon logs

* fix: gtk build errors

* fixup! fix: gtk build errors

* code review: use system_clock typedefs

* code review: use the full buffer for string view

* fixup! fix: accurate timestamp in daemon logs

* code review: limit exposure of `using`
2024-08-13 23:57:52 +01:00
Yat Ho
1ae39f8725
feat: log timestamps in local ISO8601 format (#7057)
* feat: log timestamps in local ISO8601 format

* code review: avoid repeated arguments

* code review: locale-independent decimal point character

* fix: pad sub-second part
2024-08-13 11:16:12 +01:00
Yat Ho
7e2212bfe0
refactor: simplify addrinfo unique_ptr definition (#7060) 2024-08-13 11:12:02 +01:00
Mike Gelfand
dbea32809a
Refactor async torrent removal logic (#7059)
* Remove `tr_file_move_strict()`, add param to `tr_file_move()` instead

Also restores proper `local_error` logic to handle null error param.

* Remove unused `moved_files` logic

* Rename the callback type and params to match rename decls

* Add torrent ID param to torrent removal callback

* Remove mutex from torrent removal callback

Torrent IDs aren't reused during the lifetime of the session.

* Move main removal callback logic into a separate method
2024-08-13 06:19:36 +01: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