Commit Graph

119 Commits

Author SHA1 Message Date
Charles Kerr a5ca289f41
fix: #3847 crash on session close (#3849)
* chore: use typesafe sin_addr assignment instead of memcpy()

* refactor: make tr_dhtPrintableStatus private

* refactor: make tr_dhtStatus() private

* refactor: make tr_dht status enum private

* refactor: add safety mutex wrapper around libdht API calls

* refactor: make tr_dht::Status an enum class

* refactor: rename private functions

* refactor: const correctness

* refactor: use typesafe assignment instead of memcpy

* refactor: tr_session does not directly call tr_dht

* refactor: tr_dhtPort() returns std::optional

* refactor: use tr_address::fromCompact4 in tr-dht.cc
2022-09-29 09:12:33 -05:00
Charles Kerr 56e0a1bda8
chore: add cppcoreguidelines-pro-type-member-init to libtransmission/.clang-tidy (#3840) 2022-09-23 00:51:15 -05:00
Charles Kerr 228efa16e3
refactor: tr_globalIPv6() returns a std::optional<in6_addr> (#3836) 2022-09-21 23:59:31 -05:00
Charles Kerr dd12fd010a
chore: iwyu headers (#3833) 2022-09-21 18:34:18 -05:00
Charles Kerr 9fb590d3f5
fix: recent coverity warnings (#3788)
* fix: suppress intentional USE_AFTER_FREE in tests

* fix: unnecessary field check

* fix: in ~tr_verify_worker(), release mutex lock before waiting
2022-09-07 19:24:56 -05:00
Charles Kerr 1782dc6d7a
refactor: use readability-identifier-naming in clang-tidy (#3784) 2022-09-07 11:04:28 -05:00
Charles Kerr 8eab7d3ae7
chore: remove dead "fast set" code (#3764)
* chore: remove old fast set code

* chore: remove TR_SHA1_DIGEST_LEN declaration

* chore: remove TR_SHA256_DIGEST_LEN declaration
2022-09-05 08:55:17 -05:00
Charles Kerr b01eebdaf4
refactor: tr_peer_event (#3746) 2022-09-01 16:37:11 -05:00
Charles Kerr b7ea4d9f04
refactor: tr_peerIo ref, unref (#3735)
* refactor: replace manual peerIo refcounting with std::shared_ptr
2022-08-30 12:38:30 -05:00
Charles Kerr 7c014e3256
Refactor/tr peer io member funcs (#3734)
* refactor: make tr_peerIoSetEnabled() a member method

* refactor: make tr_peerIoFlushOutgoingProtocolMsgs() a member method

* refactor: make tr_peerIoFlush() a member method

* refactor: make tr_peerWriteBytes() a member method

* refactor: make tr_peerWriteBuf() a member method

* refactor: make tr_peerIoGetWriteBufferSpace() a member method

* chore: remove unused declaration

* refactor: make tr_peerIoUtpInit() a member method

* refactor: make tr_peerIoNew() a member method

* refactor: make tr_peerIoNewOutgoing() a member method

* refactor: make tr_peerIoNewIncoming() a member method
2022-08-29 15:58:18 -05:00
Charles Kerr 0ed595ca0e
refactor: tr_peerIo read buffer (#3732)
* refactor: make tr_peerIoReadBytes() a member method

* refactor: make tr_peerIoReadUint8() a member method

* refactor: make tr_peerIoReadUint16() a member method

* refactor: make tr_peerIoReadUint32() a member method

* refactor: make tr_peerIoSetIOFuncs() a member method

* refactor: make tr_peerIoReconnect() a member method

* refactor: make tr_peerIoClear() a member method

* refactor: make tr_peerIoDrain() a member method

* refactor: move evbuffer_add_hton_16() impl to cc
2022-08-29 13:33:08 -05:00
Charles Kerr cee339e10d
refactor: remove tr_removeElementFromArray() (#3731) 2022-08-28 21:51:26 -05:00
Charles Kerr a24679d89f
refactor: modernize-avoid-c-arrays pt. 2 (#3713) 2022-08-26 13:35:28 -05:00
Charles Kerr bfec98c323
refactor: avoid tr_new() in transmission-remote (#3665) 2022-08-17 20:25:42 -05:00
Charles Kerr 29f57bc296
chore: iwyu headers (#3661) 2022-08-17 11:08:36 -05:00
Charles Kerr 0fbfed60b1
refactor: make tr_session.speed_limit_Bps_ private (#3645)
* refactor: make tr_session.speed_limit_Bps_ private

* refactor: make tr_session.is_utp_enabled_ private

* refactor: make tr_session.is_prefetch_enabled_ private

* refactor: make tr_session.is_ratio_limited_ private

* refactor: make tr_session.upload_slots_per_torrent_ private

* refactor: make tr_session.peer_id_ttl_hours_ private

* refactor: make tr_session.blocklists_ private

* refactor: make tr_session.umask_ private

* refactor: make tr_session.evdns_base_ private

* fixup! refactor: make tr_session.blocklists_ private

* refactor: make tr_session.default_trackers_ private

* refactor: make tr_session.idle_limit_minutes_ private

* refactor: make tr_session.WebMediator private

* refactor: make tr_session.session_id_ private

* refactor: make tr_session.peer_socket_tos_ private
2022-08-15 12:48:05 -05:00
Charles Kerr 44a291ca39
refactor: remove tr_session nonmember functions (#3641) 2022-08-14 14:41:57 -05:00
Charles Kerr 5c8695025a
refactor: make tr_session.is_closing_private_ (#3637) 2022-08-13 20:04:36 -05:00
Charles Kerr 7c5862a5f5
refactor: remove tr_new, tr_free pt. 1 (#3626)
* refactor: tr_torrentGetMetadataPiece() returns an optional vector

* refactor: use tr_pathbuf in create_temp_path()

* refactor: use tr_pathbuf in win32 create_temp_path()

* refactor: use std::vector in isPeerInteresting()

* refactor: remove tr_new0 from tr_peerMgrPeerStats()

* refactor: remove tr_new0 from rechokeUploads()

* refactor: silence clang nullptr dereference warning

* refactor: make tr_natpmp a C++ class

* refactor: use std::string in tr_log_message
2022-08-11 19:59:58 -05:00
Charles Kerr 63eab54fd5
refactor: timer pt 2 (#3617)
* feat: add convenience variants of TimerMaker::create()

* refactor: use libtransmission::Timer in peer-mgr

* refactor: use libtransmission::Timer in peer-msgs

* refactor: use libtransmission::Timer in tr-utp

* refactor: use libtransmission::Timer in tr-dht

* refactor: use libtransmission::Timer in port-forwarding

* refactor: use libtransmission::Timer in webseed

* refactor: use libtransmission::Timer in tr-lpd

* refactor: use libtransmission::Timer in rpc-server

* chore: remove unused function tr_timerAdd()

* chore: remove unused function tr_gettimeofday()

* fixup! chore: remove unused function tr_timerAdd()

* fixup! refactor: use libtransmission::Timer in port-forwarding
2022-08-11 12:28:37 -05:00
Charles Kerr b49cccbd3e
refactor: add timer class (#3603)
Wraps around evtimer so that some of the codebase can use libevent without coupling to it.
2022-08-08 17:53:20 -05:00
Charles Kerr 868fc1ab78
Refactor/tr variant from buf (#3592)
* refactor: use std::string in tr_watchdir_inotify_on_event()

* refactor: add template tr_variantFromBuf() variant

if it has .data() and .size() it is good
2022-08-05 16:12:45 -05:00
Charles Kerr 3428076ecd
fix: cppcoreguidelines-special-member-functions warnings in libtransmission (#3575) 2022-08-03 12:03:28 -05:00
Charles Kerr dab81c1af6
fix: readability-inconsistent-declaration-parameter-name warnings in libtransmission (#3572) 2022-08-03 01:15:37 -05:00
Charles Kerr df7a44adb2
refactor: in sendPex(), reuse the temporary buffer (#3568) 2022-08-02 18:35:16 -05:00
Charles Kerr d09aba0e6a
refactor: remove tr_address_from_string() (#3524)
use tr_address::fromString() instead

* refactor: use tr_address.isIPv4()
2022-07-25 17:25:55 -05:00
Charles Kerr fe91f04351
test: add plaintext & encrypted handshake tests (#3455) 2022-07-16 15:25:44 -05:00
Charles Kerr 2bcab6be7e
refactor: remove tr_dh code (#3443)
Refactor the MSE handshake Diffie-Hellman key code.
2022-07-14 19:54:10 -05:00
Charles Kerr 71bc7143b8
Revert "refactor: tr_address cleanup (#3422)" (#3426)
This reverts commit 9a44eeaa27.
2022-07-09 18:44:20 -05:00
Charles Kerr 9a44eeaa27
refactor: tr_address cleanup (#3422)
* refactor: remove tr_address_compare()

* refactor: remove tr_address_to_string()

* refactor: remove NUM_TR_AF_INET_TYPES

* refactor: replace tr_sessionGetPublicAddress with tr_session::getPublicAddress()

* refactor: tr_peerIo() takes tr_address by value

* refactor: replace tr_sessionIsAddressBlocked with tr_session::isAddressBlocked()

* refactor: tr_peerMgrAddIncoming now takes tr_address by value

* refactor: replace tr_address_is_valid_for_peers() with tr_address.isValidForPeers()

* refactor: tr_netOpenPeerSocket takes tr_address by value

* refactor: remove tr_generateAllowedSet()

* refactor: setup_sockaddr takes a tr_address by value

* refactor: tr_netBindTCP() takes a tr_address by value

* refactor: tr_dhtAddNode() takes a tr_address by value

* refactor: remove tr_address_from_string()

* refactor: rename tr_address.isValidForPeers() to .isValidPeerAddress()

* refactor: replace tr_address_from_sockaddr_storage() with tr_address::fromSockaddrStorage()

* refactor: minor cleanup to tr_address::readable()
2022-07-08 13:23:41 -05:00
Charles Kerr 9dfb3bf3df
refactor: add tr_peer.canRequest() (#3408) 2022-07-04 13:03:32 -05:00
Charles Kerr e7627dc209
refactor: add tr_peer.requestBlocks() (#3384) 2022-07-02 14:42:16 -05:00
Charles Kerr 85a7d0e09d
refactor: rename Bandwidth as tr_bandwidth (#3379) 2022-06-29 15:08:58 -05:00
Charles Kerr 88a3149ce4
refactor: add tr_peer.activeReqCount() (#3373)
rename peer_stats.pendingReqs to .activeReqs for consistency
2022-06-28 20:48:39 -05:00
Charles Kerr 5841441dd1
fixup! refactor: tr_peerMsgs.percentDone() (#3363) (#3365) 2022-06-27 18:16:08 -05:00
Charles Kerr 81a42c6bb6
refactor: tr_peerMsgs.percentDone() (#3363)
* refactor: add tr_peerMsgs.percentDone()

This moves the `progress` and `have` fields from the `tr_peer` parent
class down into BitTorrent peer subclass, since webseeds by definition
are seeds and have everything.

* refactor: use preferred naming for class members

snake_case for variables, camelCase for methods
2022-06-27 14:12:31 -05:00
Charles Kerr 85c11b7f03
fix: requests across piece boundaries when piece is not a multiple of block_size
Fixes #3324.
2022-06-19 23:08:58 -05:00
Dmytro Lytovchenko d34bd0b4d6
refactor: modernize cache.cc (#3108)
* Modernize cache.cc: Convert tr_cache to a class

* Modernize cache.cc: Replaced ptrArray with vector

* refactor: Cache now takes a tr_torrents reference

* refactor: add Key type to Cache

* refactor: avoid std::back_inserter

* refactor: add Cache::flushOldest()
2022-06-11 19:46:30 -05:00
Charles Kerr 75a7c5f080
refactor: add tr_peerMsgs.networkSocket() (#3175) 2022-06-01 21:33:33 -05:00
Charles Kerr d1028510c1
refactor: use std::vector instead of tr_ptrArray in peer-mgr (#3149)
* refactor: make peer_atom.pool a std::vector

* refactor: remove unused tr_ptrArray methods

* refactor: remove unused #include ptrarray.h

* refactor: remove unused tr_ptrArrayRemove()

* refactor: remove unused peer-mgr.cc code
2022-05-27 16:27:47 -05:00
Charles Kerr cec2195c78
refactor: tr_peerMgrGetPeers() returns a vector (#3142)
* refactor: tr_peerMgrGetPeers() returns a vector

* chore: iwyu <iterator> for std::back_inserter

* chore: iwyu <vector> for std::vector
2022-05-26 20:29:10 -05:00
Charles Kerr 51760bd5c1
refactor: make tr_peerIoGetAddress() a member function (#3141)
* refactor: make tr_peerIoGetAddress() a member function

* refactor: make tr_peerIo.addr a private field

* refactor: make tr_peerIoIsIncoming a member function

* refactor: make tr_peerIoHasBandwidthLeft a member function

* refactor: make tr_peerIoGetPieceSpeed_Bps a member function

* refactor: make tr_peerIoSupportsFEXT() a member function

* refactor: mark tr_peerIo::supportsDHT nodiscard

* refactor: update naming style for tr_peerIo fields

* refactor: make tr_peerIo.is_seed a private field
2022-05-26 12:17:03 -05:00
Charles Kerr e4221916b1
fix: invalid tr_peerMsgsImpl::prefetchCount value (#3024)
* fix: invalid tr_peerMsgsImpl::prefetchCount value

This count could get corrupted due to imprecise bookkeeping when
processing peers' cancel messages. This PR replaces the field with
a `prefetched` flag in the struct that represents a peer request.

This approach has simpler code, simpler logic, and is harder to break.
2022-04-29 12:44:22 -05:00
Charles Kerr 32f854a7cf
refactor: add a tr_port safety class (#2952) 2022-04-21 10:58:13 -05:00
Antoine Cœur bdac708762
docs: fix various typos and misspellings (#2955) 2022-04-21 09:28:38 -05:00
Charles Kerr f4bb09428b
fixup: more libfmt usage regressions (#2924) 2022-04-15 19:56:16 -05:00
Charles Kerr b256da02e3
refactor: remove unused macros (#2897)
* refactor: remove unused fu nction tr_lowerBound()

* refactor: tr_timerAdd() takes a reference, not a pointer

* refactor: tr_timerAddMsec() takes a reference, not a pointer

* refactor: tr_moveFile() takes a reference, not a pointer

* refactor: tr_wildmat() takes std::string_views

* refactor: remove unused macro TR_GNUC_NONNULL

* refactor: remove unused macro TR_GNUC_PRINTF

* refactor: remove unused macro TR_GNUC_NULL_TERMINATED

* refactor: remove unused macro TR_GNUC_HOT

* refactor: remove unused macro __has_feature

* refactor: remove unused macro __has_attribute

* refactor: remove unused macro TR_DEPRECATED

* refactor: remove unused macro TR_DISABLE_COPY_MOVE
2022-04-07 19:20:29 -05:00
Charles Kerr 80dd460773
refactor: annotate nodiscard, constexpr, noexcept methods (#2879) 2022-04-04 22:51:56 -05:00
Charles Kerr a71f0c762d
refactor: remove varargs from libtransmission (#2876)
* refactor: do not use va_arg in peer-msgs.cc

* refactor: do not use va_arg in platform.cc

* build: enable cert-dcl50-cpp clang-tidy warning

* refactor: use some tr_pathbuf where sensible
2022-04-04 20:37:12 -05:00
Charles Kerr 1cc9da26ba
fix: sonarcloud (#2865)
* refactor: implement FileTreeItem::children_ with a std::vector

* fix: std::move should not be called on forwarding reference

* fix: uninitialized scalar variable

* fix: unchecked return value from library

* fix: dereference before null check

* fix: unchecked return value from library

* fix: unchecked return value from library

* fixup! refactor: implement FileTreeItem::children_ with a std::vector

* fix: signed-unsigned comparison in libtransmission tests

* fix: avoid unnecessary copy by using const reference

* fix: function should be declared const

* refactor: use fmt::format to build log timestamps

* fix: use init-statement to reduce variable scope

* fixup! refactor: use fmt::format to build log timestamps

* fix: remove tau_tracker destructor for rule-of-zero

* fix: remove tr_peerIo destructor for rule-of-zero

* Revert "fix: dereference before null check"

This reverts commit cd78967815.

* fix: signed-unsigned comparison in libtransmission tests

* fix: use init-statement to reduce variable scope

* fix: extract nested code block into separate method

* fix: extract nested code block into separate method

* fix: extract nested code block into separate method

* fix: use init-statement to reduce variable scope

* fix: extract nested code block into separate method

* fix: signed-unsigned comparison in libtransmission tests

* fixup! fix: extract nested code block into separate method

* fix: mark possibly-unused as [[maybe_unused]]

* fix: invalid stack memory reference in tr_found_file_t

* fix: signed-unsigned comparison in libtransmission tests
2022-04-02 09:06:02 -05:00