* 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
* 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
* 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>
* 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
* 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: 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
* chore: housekeeping
* refactor: convert `on_idle()` to class method
* refactor: convert `task_request_next_chunk()` to class method
* refactor: convert `onPartialDataFetched()` to class method
* refactor: convert `onBufferGotData()` to class method
* refactor: convert `useFetchedBlocks()` to class method
* refactor: hide some `tr_webseed_task` fields and methods
* refactor: convert `tr_webseed_task` methods to snake_case
* refactor: remove `write_block_data`
* refactor: store reference to `tr_torrent` directly
* refactor: convert `ConnectionLimiter` methods to snake_case
* refactor: convert `tr_webseed` methods to snake_case
* refactor: hide `tr_webseed` callback member variables
* refactor: convert `tr_webseed` to C++ interface
* fix: `tr_address` should be invalid by default
* fix: allow loopback address for LPD and incoming connections
* fix: `parseCidrline()` should set address type
* code review: keep `memcmp`
* refactor: update bep links
* chore: use more appropriate data types
* chore: checkpoint
* refactor: split `can_request()` into each of their own different signature
* chore: checkpoint
* refactor: convert tr_peerMsgsImpl functions to methods
* chore: checkpoint
* refactor: store peer info as reference
* refactor: convert all member variables to private
* chore: re-arrange methods
* refactor: optimise tmp vector default size in `send_ut_pex()`
* chore: housekeeping
* chore: housekeeping
* refactor: avoid `dynamic_cast` when sending cancel
* fix: restore `blocks_sent_to_peer` stat
regression e91af26923
* fix: choke first then reject
* refactor: convert `tr_peerMsgsNew()` to static factory function
* refactor: store `tr_torrent` reference instead of pointer
* Revert "refactor: store peer info as reference"
This reverts commit bb419bf2
---------
Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: unset peer BEP-9 support if size hint is invalid
* fix: open torrent file in binary mode
* refactor: move metadata size check to method
* refactor: remove duplicate checks
* refactor: reduce temp variable scope in `parseLtepHandshake()`
* refactor: convert `get_piece_length()` to method
* refactor: convert `tr_torrentSetMetadataSizeHint()` to method
* refactor: convert `tr_torrentGetMetadataPiece()` to method
* refactor: convert `tr_torrentUseMetainfoFromFile()` to method
* refactor: convert `tr_torrentSetMetadataPiece()` to method
* refactor: convert `tr_torrentGetNextMetadataRequest()` to method
* refactor: convert `tr_torrentGetMetadataPercent()` to method
* refactor: add basic framework for MagnetMediator
* refactor: initialise `tr_incomplete_metadata` fields in constructor
* refactor: check metadata transfer completion in `set_metadata_piece()`
* refactor: convert `use_new_metainfo()` and `on_have_all_metainfo()` to methods
* refactor: move parts of `tr_torrent::set_metadata_piece()` into `tr_incomplete_metadata`
* refactor: move parts of `tr_torrent::get_next_metadata_request()` into `tr_incomplete_metadata`
* refactor: move parts of `tr_torrent::get_metadata_percent()` into `tr_incomplete_metadata`
* refactor: hide all `tr_incomplete_metadata` fields
* refactor: move `incomplete_metadata` to private
* feat: add test for `set_metadata_piece()`
* refactor: unify integer types
* refactor: rename `tr_incomplete_metadata` to `tr_metadata_download`
* chore: make clang-tidy happy
libtransmission/torrent-magnet.cc:117:68: warning: comparison of integers of different signs: 'long' and 'const uint64_t' (aka 'const unsigned long') [clang-diagnostic-sign-compare]
* refactor: pass log name to `tr_metadata_download` constructor
* chore: iwyu
* fix: thread-safe `TorrentMagnetTest.setMetadataPiece`
* chore: housekeeping
* Revert "fix: thread-safe `TorrentMagnetTest.setMetadataPiece`"
This reverts commit 2a7fcd93a262888f9f55d542b1a9a2da9ca72cea.
* fix: stop soon instead of stop now in `on_metainfo_completed()`
This is unreachable code now, but if it is ever reached, Transmission
will very likely crash.
* fix: maybe fix OpenBSD test failure
* refactor: minor decoupling in peer-mgr
Pass a tr_torrents& and TimerMaker& into the tr_peerMgr and HandshakeMediator
constructors so they can be used directly instead of via tr_session.
No functional changes.
* refactor: in HandshakeMediator, make the session reference const