* 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>
* 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
* 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>
* 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
* 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`
* 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`
* feat: log timestamps in local ISO8601 format
* code review: avoid repeated arguments
* code review: locale-independent decimal point character
* fix: pad sub-second part
* 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
* 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
* fix: silence bugprone-unchecked-optional-access warnings
clang-tidy emits bugprone-unchecked-optional-access warning for
`tr_sys_file_lock`. however, this is a false positive: the lines
warned about cannot be reached if the optional does not contain a value.
adding an `assert` silences these warnings.
* Apply suggestions from code review
* chore: remove redundant `.clang-format` entry for `TR_DEFINE_QUARK`
Left-over from bf41e1487a.
* chore: remove redundant `.clang-format` entry for `API_HEADER_*`
Left-over from f7edcfcb2a.
* chore: drop deprecated options in favour of `PackConstructorInitializers`
* fix: invalid `SpacesInAngles` value
* chore: add comment to forecast a change we need to make in the future
* chore: add trailing comma to prettify lambda
* Add CI configuration for clang-tidy on Windows
* Fix issues reported by clang-tidy on Windows
* Workaround clang-tidy defects on Windows
* Fix C-style casts (which clang-tidy didn't report)
* fix: FTBFS when `TR_UTP_TRACE` is defined
* refactor: log socket address when processing udp packets
* refactor: log details of unexpected UDP packet
* fix: don't unset utp context userdata during shutdown
It is still needed inside `utp_destroy()` when `UTP_DEBUG_LOGGING` is defined.
* code review: lazy evaluate incoming udp packet display name
* code review: move `from_str` out of loop
* 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
The crash will happen if the following series of events happened:
1. Torrent verification starts for a `tr_torrent` object.
2. The session thread starts executing `tr_torrentFreeInSessionThread()`, about to free this `tr_torrent` object.
3. `tr_torrent::VerifyMediator::on_verify_done()` queues a lambda that captures a pointer to the `tr_torrent` object.
4. The `tr_torrent` object is freed.
5. The session thread executes the lambda from Step 3, and crashes when dereferencing the dangling `tr_torrent` pointer.
* ci: bump `clang-tidy` from 14 to 18
`clang-tidy-14` has been crashing when being run on `peer-mgr.cc` since 96de1706af.
According to https://github.com/llvm/llvm-project/issues/95631, upgrading to `clang-tidy-18` fixes this.
* chore: workaround clang-tidy false positives
* fix: limit nolint comment scope
* code review: try avoiding false positive without nolint
* fix compile error with gcc 8.2: no matching function for call to ‘flock::flock(tr_sys_file_t&, const int&)
* #error temp checking which pipelines have XFS
* code review: removing duplicate include
---------
Co-authored-by: yunhai <haihai107@126.com>
This is related to #4850 since libtransmission/mime-types.js generates
libtransmission/mime-types.h and puts it there.
Also add a note that the file is automatically generated for good measure.
* chore: do not include <set> unless we use it
* chore: do not include <map> unless we use it
* chore: do not include <string> unless we use it
* chore: do not include <list> unless we use it
* chore: do not include <memory> unless we use it
* chore: do not include <optional> unless we use it
* chore: do not include <functional> unless we use it
* 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>
* fix: don't save blocks bitfield to resume when we are seed
* chore: housekeeping
* code review: replace `auto` with `tr_resume::fields_t`
* code review: remove the `have` key in resume
* fix: `blocks` error message
* chore: housekeeping
* refactor: store peer info objects in shared_ptr
* refactor: minimise insert/erase operations to the peer info pool
* refactor: unify `on_got_port()` exit point to simplify cleanup
* fix: use `std::unordered_map` as a stand-in for `small::map`
* refactor: use small maps but with `std::vector` as base
* fix: suppress goto warning
* refactor: use `small::map`
* fix: remove constexpr
* feat: allow upnp to recover from errors
* feat: allow natpmp to recover from errors
* chore: housekeeping
* code review: explicitly list all states to start discovering from
* fix: recover from failed UPnP discovery
* refactor: remove `UpnpState::Failed`
std::chrono::duration is just a wrapper, underlying numerical value member will be default initialized to zero as expected.
See https://en.cppreference.com/w/cpp/chrono/duration
Signed-off-by: Dzmitry Neviadomski <nevack.d@gmail.com>
* 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