Commit Graph

275 Commits

Author SHA1 Message Date
Yat Ho 92519281b0
refactor: convert `tr_webseed` to C++ interface (#6708)
* 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
2024-04-02 09:31:20 -05:00
Cœur 465b878e8a
Win32 compatibility for get_peer_stats (#6743) 2024-03-28 09:40:08 +00:00
Yat Ho 20aef2f79d
fix: misc net.cc and blocklist.cc fixes (#6717)
* 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`
2024-03-24 17:09:51 -05:00
Cœur 9ddf609d50
KeepEmptyLinesAtTheStartOfBlocks: false (#6726) 2024-03-24 11:25:00 -05:00
Yat Ho 152f3e91a5
refactor: convert `tr_peerMsgsImpl` helper functions to class methods (#6580)
* 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>
2024-03-15 19:52:09 -05:00
Cœur 8709ec60e6
run peerMgrPeerStats in session thread (#5992)
* run peerMgrPeerStats in session thread

* code-review: add a TODO: for refactoring
2024-03-15 19:04:43 -05:00
Yat Ho 16f25e1158
fixup! perf: restore `3.00` wishlist with cached candidates (#6549) (#6604) 2024-02-16 08:28:37 -06:00
Charles Kerr eeea3c540f
fix: clang-tidy-19 warnings (#6597)
* fix: readability-redundant-casting warnings in libtransmission

* fix: readability-avoid-return-with-void-value warnings in libtransmission

* fix: readability-redundant-member-init warnings in libtransmission

* fix: readability-redundant-inline-specifier warnings in libtransmission

* fix: performance-avoid-endl warnings in libtransmission

* fix: bugprone-multi-level-implicit-pointer-conversion warnings in libtransmission

* fix: bugprone-switch-missing-default-case warnings in libtransmission

* fix: readability-redundant-string-cstr warnings in libtransmission

* fixup! fix: bugprone-multi-level-implicit-pointer-conversion warnings in libtransmission
2024-02-13 10:42:19 -06:00
Yat Ho 168d56cefc
perf: restore `3.00` wishlist with cached candidates (#6549)
* feat: rewrite Wishlist to cache candidates

* feat: implement mediator and observers

* feat: rewrite existing tests to work for current implementation

* fix: incorrect block spans for existing tests

* feat: add new tests for new features

* fix: clang shadow warning

* fix: heap-use-after-free in tests

* fixup! feat: rewrite Wishlist to cache candidates

* chore: update comment

* code review: reserve vector memory

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2024-02-05 00:14:34 -06:00
Yat Ho 10d047005a
refactor: convert `tr_incomplete_metadata` to c++ class (#6383)
* 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
2024-01-02 21:04:17 -06:00
Charles Kerr 1ec6b2b232
refactor: make more tr_torrent fields private (#6305)
* refactor: make tr_torrent::max_connected_peers_ private

* refactor: make tr_torrent::completeness_ private

* refactor: make tr_torrent::mark_edited() private

* refactor: make tr_torrent::mark_changed() private

* refactor: make tr_torrent::start_when_stable_ private

* refactor: make tr_torrent::is_dirty() private

* refactor: make tr_torrent::byte_span() private

* refactor: remove unused non-const version of tr_torrent::metainfo()

* refactor: make tr_torrent::set_dirty() private

* refactor: remove unused tr_torrentStartMagnet()
2023-11-27 23:04:04 -06:00
Yat Ho 5d64c860ea
fix: low priority not working (#6079) 2023-11-27 19:59:26 -06:00
Charles Kerr a12ef941e7
refactor: make tr_torrent fields, methods private where possible (#6293) 2023-11-25 20:00:20 -06:00
Charles Kerr d8c2074cb7
refactor: make tr_torrent date fields private (#6281) 2023-11-23 19:52:53 -06:00
Charles Kerr 64d9d57363
chore: fix minor clang-tidy warnings (#6275) 2023-11-21 09:02:03 -06:00
Charles Kerr f8c544397a
refactor: add private helper class CumulativeCount (#6260)
* refactor: CumulativeCounts helper class

* refactor: add private CumulativeCounts helper class for tr_torrent
2023-11-15 18:53:43 -06:00
Yat Ho 234e3278f1
fix: `assertion failed: is_connectable_.value_or(true) || !is_connected()` (#6254) 2023-11-14 09:13:20 -06:00
Charles Kerr 8ebb5b0bc3
refactor: Values pt. 4 - use Speed in peer_mgr, peer_msgs (#6241) 2023-11-12 14:38:27 -06:00
Charles Kerr 36f33c0d30
fix: recent clang-tidy warnings (#6233)
* fix: readability-implicit-bool-conversion warnings in file-piece-map

* fix: clang-analyzer-core.NullDereference warning in on_handshake_done()
2023-11-09 19:13:43 -06:00
Cœur bcbd9b77af
feat: add stats for known peers, not just connected ones (#4900) 2023-11-08 11:17:00 -06:00
Yat Ho a2b547fb50
chore: iwyu (#6201) 2023-11-03 12:03:26 -05:00
Julien 8ac323d5d6
chore: removed copyright timespans in headers (#4850) 2023-11-01 16:11:11 -05:00
Charles Kerr e54b17d92e
refactor: blocklists (#6189) 2023-10-31 19:20:01 -04:00
Charles Kerr e27b05bcec
refactor: make class methods private (#6181) 2023-10-30 02:32:29 -04:00
Charles Kerr 69b293a793
refactor: minor decoupling in peer-mgr (#6155)
* 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
2023-10-24 15:24:52 -04:00
Charles Kerr c0e5e3a368
refactor: reduce coupling between tr_session and tr_peerMgr (#6151) 2023-10-23 11:34:30 -04:00
Yat Ho 88fe76781c
perf: connectable pool housekeeping (#6111) 2023-10-19 13:05:19 -05:00
Charles Kerr 0c3f65e1c6
fix: FTBFS on FreeBSD with clang 14 (#6110) 2023-10-16 19:39:14 -05:00
Yat Ho 6cec60f1fb
refactor: store outgoing handshake in `tr_peer_info` objects (#6103) 2023-10-14 12:58:15 -05:00
Yat Ho 5808f72f50
fix: assertion failed: port_empty in `tr_swarm::remove_peer()` (#6062) 2023-10-02 11:57:48 -05:00
Yat Ho cfa26d0da8
chore: more specific peer error log (#6029) 2023-10-01 10:43:17 -05:00
Yat Ho 85a120faea
feat: add `preferred-transport` to settings.json (#5939) 2023-09-15 20:23:34 -05:00
luzpaz 3be0d728dd
Fix typos (#5980) 2023-09-10 22:31:49 -05:00
Yat Ho d566695b33
fix: always move duplicate peer_info to graveyard pool (#5941) 2023-09-10 21:12:11 -05:00
Yat Ho eea7d4d886
refactor: re-organise `net.h` member functions (#5878) 2023-08-17 22:13:01 -05:00
tearfur 449549c84f
fix: do not mark peer as not connectable when we are currently connected (#5889) 2023-08-14 16:46:09 -05:00
tearfur 0c7992baa2
fix: cover all pex disabled cases in `get_peer_candidate()` (#5806) 2023-08-14 09:56:43 -05:00
tearfur 72f604dbf8
fixup! perf: improve sorting performance in `tr_peerMgrGetPeers()` (#5807) 2023-08-13 22:02:11 -05:00
tearfur a2849219f7
feat: split connectable and non-connectable pool (#5801) 2023-08-01 09:56:26 -05:00
tearfur f758cb3597
refactor: avoid code duplication (#5793) 2023-07-17 08:56:57 -05:00
tearfur 01f25b030c
perf: improve sorting performance in `tr_peerMgrGetPeers()` (#5792) 2023-07-15 08:18:37 -05:00
Charles Kerr 32af004248
perf: reuse the vector in receonnectPulse(). (#5788) 2023-07-14 17:46:10 -05:00
Charles Kerr c867f00153
refactor: replace `peer_atom` with `tr_peer_info` (#5773) 2023-07-14 07:06:25 -05:00
tearfur 2ec19e694d
chore: minor code cleanup (#5760) 2023-07-13 09:10:43 -05:00
Charles Kerr a9a6e54858
refactor: make tr_socket_address a class (#5772) 2023-07-12 17:29:47 -05:00
Charles Kerr bc562eb9a5
perf: avoid atom lookup in tr_peerMgrSetUtpSupported() (#5766) 2023-07-12 10:10:20 -05:00
tearfur 78367c098f
perf: use `std::unordered_map` for `tr_swarm.pool` and Handshakes (#5740) 2023-07-11 11:57:29 -05:00
Charles Kerr 8169d524ea
feat: do not auto-disconnect when a known seed initiates a connection and we are seeding (#5756) 2023-07-08 14:27:31 -05:00
tearfur 8e822a3cbb
perf: avoid copying/moving elements in peer candidate list (#5755) 2023-07-08 13:09:34 -05:00
tearfur 5ec4ca550e
chore: iwyu (#5746) 2023-07-08 10:24:03 -05:00