Commit Graph

5477 Commits

Author SHA1 Message Date
Charles Kerr c171d6df7c
refactor: remove tr_utf8_validate from public API (#3671)
it was only used as an impl helper, so make it private
2022-08-18 13:23:59 -05:00
Charles Kerr 76a7994eef
refactor: remove tr_free() (#3668) 2022-08-18 09:14:12 -05:00
Charles Kerr 963a8112a1
refactor: remove tr_strvDup() (#3666) 2022-08-17 21:18:44 -05:00
Charles Kerr bfec98c323
refactor: avoid tr_new() in transmission-remote (#3665) 2022-08-17 20:25:42 -05:00
Charles Kerr 36675d183a
refactor: avoid tr_new() in tr_main_win32() (#3664) 2022-08-17 18:26:52 -05:00
Charles Kerr 7fe2cf68b9
refactor: avoid tr_new(), tr_free() in tr_variant (#3663)
* refactor: remove unused tr_renew()

* refactor: remove unused tr_realloc()

* refactor: avoid tr_strvDup() in tr-quark
2022-08-17 14:44:18 -05:00
Charles Kerr 9374e332ec
refactor: avoid tr_new in rpcimpl (#3662) 2022-08-17 13:11:44 -05:00
Charles Kerr 29f57bc296
chore: iwyu headers (#3661) 2022-08-17 11:08:36 -05:00
Charles Kerr 6b25a57899
refactor: don't use tr_free in tr_strvUtf8Clean() (#3658) 2022-08-16 21:47:07 -05:00
Charles Kerr e49747ab51
feat: add tr_strvToBuf() (#3657)
* feat: add tr_getDefaultConfigDirToBuf()

* feat: add tr_getDefaultDownloadDirToBuf()

* feat: add tr_strvToBuf()

* feat: add tr_torrentFindFileToBuf()

* feat: add tr_torrentGetMagnetLinkToBuf()

* refactor: remove unused makeString() from tests

* feat: add tr_torrentFilenameToBuf()

* feat: add tr_torrentGetTrackerListToBuf()

* chore: remove obsolete comment references to tr_free

* chore: remove unused tr_strdup()

* chore: remove unused forward declarations
2022-08-16 19:28:57 -05:00
Charles Kerr 293f4f6759
refactor: fix sonarcloud warnings (#3649)
* refactor: help sonarcloud to see that tr_bandwidth dtor does not throw

* refactor: use std::map instead of QMap in qt FileTreeModel
2022-08-16 09:30:05 -05:00
Charles Kerr 99c21efecc
refactor: avoid tr_malloc / tr_free in subprocess-win32 (#3648) 2022-08-16 00:07:06 -05:00
Charles Kerr c625ec7e0f
refactor: make tr_session.rpc_server_private_ (#3646)
* refactor: make tr_session.rpc_server_ private

* chore: sort some fields to reduce number of padding holes

* chore: remove unused forward declarations

* refactor: aggregate tr_bitfield in tr_turtle

* chore: remove unused forward declarations

* chore: remove unused forward declarations
2022-08-15 16:25:55 -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 a4c1a23fae
refactor: make tr_session.is_incomplete_file_naming_enabled_ private (#3642)
* refactor: make tr_session.is_incomplete_file_naming_enabled_ private

* refactor: make session callback setters constexpr

* refactor: make tr_session.is_port_random_ private

* refactor: make tr_session.desired_ratio_ private

* refactor: make tr_session.is_pex_enabled_ private

* refactor: make tr_session.is_idle_limited_ private
2022-08-14 19:33:28 -05:00
Charles Kerr 44a291ca39
refactor: remove tr_session nonmember functions (#3641) 2022-08-14 14:41:57 -05:00
Charles Kerr 6beca85ae2
refactor: make tr_session.rpc_func_ private (#3640) 2022-08-14 10:40:03 -05:00
Charles Kerr 08ec882055
refactor: remove tr_isSession() (#3638) 2022-08-14 09:16:08 -05:00
Charles Kerr 5c8695025a
refactor: make tr_session.is_closing_private_ (#3637) 2022-08-13 20:04:36 -05:00
Charles Kerr f6bf652043
refactor: make tr_session.peer_count private (#3635) 2022-08-13 17:41:42 -05:00
Charles Kerr ed6ee619a6
refactor: make tr_session.queue fields private (#3634) 2022-08-13 14:56:10 -05:00
Charles Kerr 403e81e163
refactor: make tr_session.web_mediator_ private (#3633) 2022-08-13 13:36:34 -05:00
Charles Kerr c7466b3ff4
fix: coverity warnings (#3632)
* fix: uninitialized field natpmp

* fix: unchecked downcast result

* fix: potential tr_error leak

* fix: potential tr_error leak

* fix: potential tr_error leak

* fix: potential nullptr dereference in test fixtures

* fix: handshake fields not initialized in constructor

* chore: cast unchecked return value to void

* chore: cast unchecked return value to void

* chore: cast unchecked return value to void

* chore: make single-arg constructors explicit

* fix: code smell make variable a pointer-to-const

* fix: code smell make variable a pointer-to-const

* chore: make single-arg constructors explicit

* chore: silence sonarcloud false warning on commented-out-code

* chore: fix code smell use std::array

* chore: make EvTimer::handleTimer() const

* chore: mark tr_bandwidth remove_child as noexcept
2022-08-13 12:11:07 -05:00
Charles Kerr 1c8032d23a
fix: tr_session field order (#3630) 2022-08-12 12:22:23 -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 e781ee1773
refactor: timer pt 3 (#3624) 2022-08-11 14:30:00 -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 c66303fae2
refactor: watchdir (#3606) 2022-08-10 08:34:51 -05:00
Guido Vranken b1cc968969
Fix out-of-bounds read in torrent parsing (#3600)
Fixes #3591
2022-08-09 17:04:56 -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 83ffa6bf1b
chore: fix spdx abbreviations (#3602) 2022-08-08 13:05:39 -05:00
Charles Kerr 31a733fab7
refactor: make tr_session_id a class (#3598) 2022-08-06 14:27:37 -05:00
Charles Kerr 90f08f4fa1
refactor: fix recent sonarcloud warnings (#3593) 2022-08-05 20:37:21 -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 4bc1589c5d
refactor: remove tr_win32_utf8_to_native_ex() (#3590) 2022-08-05 14:16:25 -05:00
Charles Kerr 8b983b3d1c
refactor: tr_sys_path_resolve() returns a std::string (#3587)
* refactor: tr_sys_path_resolve returns std::string
2022-08-05 11:36:01 -05:00
Charles Kerr 3ed6b187bb
refactor: iwyu utils.h (#3583) 2022-08-04 08:44:18 -05:00
Charles Kerr 4f6909a27a
refactor: tr_sys_dir_get_current() returns a std::string (#3581) 2022-08-03 23:59:41 -05:00
Charles Kerr ef34c7c4dc
refactor: use std::wstring on win32 (#3578) 2022-08-03 18:07:38 -05:00
Charles Kerr 3428076ecd
fix: cppcoreguidelines-special-member-functions warnings in libtransmission (#3575) 2022-08-03 12:03:28 -05:00
qu1ck 9afbf58c4e
Fix peer port change in session rpc (#3573)
Currently transmission keeps listening to the old port when you change
it so incoming peers can't connect.
2022-08-03 10:07:45 -05:00
Charles Kerr dab81c1af6
fix: readability-inconsistent-declaration-parameter-name warnings in libtransmission (#3572) 2022-08-03 01:15:37 -05:00
Viacheslav Chimishuk 8e604b44a5
Fix broken tr_sessionSetPeerPortRandom() function. (#3569) 2022-08-02 22:38:37 -05:00
Charles Kerr df7a44adb2
refactor: in sendPex(), reuse the temporary buffer (#3568) 2022-08-02 18:35:16 -05:00
Charles Kerr f39826cc59
fix: clang-tidy-15 warnings (#3570)
* fix: bugprone-assignment-in-if-condition warning in tr_bitfield::countFlags()

* fix: bugprone-assignment-in-if-condition warning in tr_watchdir_generic_new()

* fix: bugprone-assignment-in-if-condition warning in torrentRenamePath()

* fix: bugprone-assignment-in-if-condition warning in tr_watchdir_inotify_on_event()

* fix: bugprone-assignment-in-if-condition warning in tr_variantWalk()

* fix: misc-const-correctness warning in TrackerDelegate::getText()

* fix: bugprone-assignment-in-if-condition warning in Session::updateStats()

* fix: performance-unnecessary-value-param warning in discoverThreadfunc()

* fix: clang-analyzer-core.UndefinedBinaryOperatorResult warning in tr_completion::setHasAll()

* fix: clang-analyzer-core.UndefinedBinaryOperatorResult warning in tr_torrentFileCompleted()

* fix: silence clang-analyzer-cplusplus.NewDelete warning when using QPointer

This appears to be a false positive; added NOLINT
2022-08-02 18:34:53 -05:00
Charles Kerr bf8f72e61f
refactor: tr_metainfo_builder() (#3565) 2022-08-02 14:46:08 -05:00
Charles Kerr 5eb7f75010
refactor: tr_sys_path_get_info() now returns a tr_sys_path_info (#3566)
* refactor: tr_sys_path_get_info() now returns a tr_sys_path_info

* refactor: tr_sys_file_get_info() now returns a tr_sys_path_info
2022-08-02 12:41:04 -05:00
Charles Kerr 18e2a04f88
refactor: make sha1, sha256 RAII safe (#3556) 2022-07-31 15:58:14 -05:00
Charles Kerr c34b6407bb
refactor: use fmt::format() in tr-getopt (#3551) 2022-07-30 12:54:22 -05:00
Charles Kerr fa6ba14dc3
refactor: remove closure struct in tr-dht (#3550)
This was the last use of tr_memdup(), so remove that too
2022-07-29 14:38:43 -05:00
Charles Kerr 822fabb233
refactor: remove unused GET handler in rpc-server.cc (#3549)
* refactor: when serving files, use string_view

* refactor: remove HTTP GET servicing code

This has not been needed for awhile but did not get removed
2022-07-29 13:02:33 -05:00
Charles Kerr 526d9fcdc4
refactor: aggregate bindinfo in tr_session (#3545) 2022-07-29 08:11:47 -05:00
Ilkka Kallioniemi 718480bc8b
Add some missing characters and remove extra whitespaces (#3541) 2022-07-28 20:02:33 -05:00
Charles Kerr 9c7fcf85cf
refactor: tr_stats (#3542) 2022-07-28 18:56:40 -05:00
Charles Kerr e0ca366b2d
refactor: remove tr_loadFile() (#3540)
* refactor: use the std::vector variant of tr_loadFile() in rpc-server.cc

* refactor: use the std::vector variant of tr_loadFile() in rename-test.cc

* refactor: remove the unused raw ptr variant of tr_loadFile()
2022-07-28 14:22:32 -05:00
Charles Kerr 15056045bd
perf: batch up calls to the RNG (#3537) 2022-07-28 10:01:59 -05:00
Charles Kerr 88e898b005
refactor: avoid unnecessary heap alloc when sending magnet link over RPC (#3535) 2022-07-27 23:31:41 -05:00
Charles Kerr d8d03b8e3b
refactor: avoid unnecessary heap alloc when reading PadC (#3534) 2022-07-27 22:17:05 -05:00
Charles Kerr 905ee4c8aa
refactor: use std::sort() in rechokeDownloads() (#3533) 2022-07-27 18:08:18 -05:00
Charles Kerr b889f0c395
chore: iwyu cstring, cstdlib, optional, unordered_set (#3532) 2022-07-27 16:53:39 -05:00
Charles Kerr 62e40e88cf
refactor: use STL containers in torrent-magnet.cc (#3531) 2022-07-27 14:15:06 -05:00
Charles Kerr b7bc21cdb6
refactor: reimplement tr_strlcpy() using fmt::format_to_n() (#3530) 2022-07-27 12:38:46 -05:00
Charles Kerr ec79a2a888
fix: clang-tidy misc-const-correctness warnings (#3529) 2022-07-27 09:03:13 -05:00
Charles Kerr 78b24b594b
refactor: remove tr_runInEventThread() temp data structs (#3528)
* refactor: remove port_forwarding_data

* refactor: remove "struct rename_data"
2022-07-27 02:07:44 -05:00
Charles Kerr 0e7ef51d5c
refactor: tr_env_get_string() now returns a std::string (#3527) 2022-07-26 23:26:37 -05:00
Charles Kerr 1a0afbe95e
refactor: iwyu (#3525) 2022-07-25 21:45:54 -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 4f7051fe7f
refactor: make tr_session's directory fields private (#3516) 2022-07-23 02:13:18 -05:00
Charles Kerr 47fe7c47d2
refactor: replace per-torrent callbacks with per-session ones. (#3495) 2022-07-23 01:04:34 -05:00
Charles Kerr 445aad56a0
test: add platform tests (#3514)
* test: add tr_getDefaultDownloadDir() tests

this also indirectly tests xdg and homedir

* test: add PlatformTest.defaultConfigDirEnv

* test: add PlatformTest.defaultConfigDirXdgConfig

test: add PlatformTest.defaultConfigDirXdgConfigHome

* test: add PlatformTest.webClientDirEnvClutch

test: add PlatformTest.webClientDirEnvTr

test: add PlatformTest.webClientDirXdgDataHome

* fixup! test: add PlatformTest.webClientDirEnvClutch

fix: win32 breakage
2022-07-22 20:10:02 -05:00
Charles Kerr 9bf2918ad0
refactor: remove tr_strvPath() (#3509) 2022-07-22 13:07:23 -05:00
Charles Kerr 0da1cbb6ec
fix: 3508 location invalidation (#3511)
* Revert "refactor: remove tr_sessionGetConfigDir() (#3506)"

This reverts commit c50da43ae0.

* Revert "fix: do not leak in tr_getWebClientDir() (#3502)"

This reverts commit 5a75e37033.
2022-07-22 00:52:48 -05:00
Charles Kerr c50da43ae0
refactor: remove tr_sessionGetConfigDir() (#3506)
* refactor: remove tr_sessionGetConfigDir() from GTK client

* refactor: remove tr_sessionGetConfigDir() from daemon

* refactor: remove tr_sessionGetConfigDir()

* refactor: remove tr_getTorrentDir()

* fixup! refactor: remove tr_sessionGetConfigDir()
2022-07-21 20:12:45 -05:00
Charles Kerr 5a75e37033
fix: do not leak in tr_getWebClientDir() (#3502) 2022-07-21 17:02:13 -05:00
Charles Kerr bb3871b8b9
fix: silence "couldn't read file" warnings (#3501)
* fix: silence could not read user-dirs.dirs warning

* fix: silence could not read bandwidth-groups warning
2022-07-21 13:22:38 -05:00
Charles Kerr da032e3875
refactor: remove unused tr_stat fields (#3493) 2022-07-20 21:54:41 -05:00
Viacheslav Chimishuk de7986e01d
Add announce-ip and announce-ip-enabled parameters. (#3461) 2022-07-20 14:04:52 -05:00
David Miguel Susano Pinto f8b3514c0e
tr_makeMetaInfo: new anonymize option (closes #3420) (#3452) 2022-07-19 16:48:24 -05:00
Gary Elshaw 99ed472e0b
Change the default number of upload slots from 14 to 8 (#3474) 2022-07-19 10:27:12 -05:00
Charles Kerr 41c0f8885e
fix: limit pad search during encrypted handshake (#3471) 2022-07-18 13:00:26 -05:00
Charles Kerr fb431cb1c1
fix: 3415 assert failure in webseed.requestBlocks (#3470)
Fixes #3415.
2022-07-18 11:40:58 -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
Colin B c3db52e310
Fix #3444, support single file hybrid torrents. (#3446) 2022-07-14 13:53:00 -05:00
Charles Kerr ba26e79afe
refactor: decouple tr_handshake (#3435)
Add a shim between the handshake code and the rest of the codebase to 
improve decoupling so that a followup PR can add handshake unit tests. 

The handshake code no longer directly relies on tr_torrent, tr_session, 
tr_dht, or tr_peerMgr.
2022-07-11 18:29:48 -05:00
Charles Kerr 0a39cb9302
refactor: migrate tr_crypto C functions to members (#3430) 2022-07-10 21:57:05 -05:00
Charles Kerr 5e4c7f9a1e
refactor: use std::deque for tr_peerIo.outbuf_info (#3428) 2022-07-10 13:51:35 -05:00
Charles Kerr d164343fe7
refactor: remove tr_address_to_string() (#3427) 2022-07-09 20:03:40 -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 745adf8332
Update libutp to 3.4+ (TRAC-5888) (#3416)
Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-07-08 10:13:22 -05:00
Charles Kerr e9a7ddf7f9
fix: minor warnings (#3413)
* fix: signed-unsigned comparison warning

* fix: readability-implicit-bool-conversion warning

* fix: signed-unsigned comparison warning
2022-07-05 18:32:30 -05:00
Charles Kerr 9dfb3bf3df
refactor: add tr_peer.canRequest() (#3408) 2022-07-04 13:03:32 -05:00
Charles Kerr 513f4bc91b
fix: assertion failed "s->leftUntilDone <= s->sizeWhenDone" (#3406) 2022-07-04 11:48:54 -05:00
depler 707fce44da
fix_empty_log_windows (#3396)
\
2022-07-04 00:34:39 -05:00
Charles Kerr d62a0bd81e
Instantiate `tr_parseNum()` template using basic types (#3404)
There're places where e.g. `size_t` is used which may or may not match one of
`(u)intXX_t` types.

Authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-07-03 23:28:41 -05:00
Mike Gelfand 142b2a088d
Support wolfSSL 4.6+ (#3398)
* Fix testing against reference crypto implementation

Build would fail on CI if using cyassl/wolfssl or polarssl/mbedtls as a
backend and testing it against reference openssl implementation due to
missing include directories, but only if bundled (non-system) b64 is
used.

* Iniitalize size arguments to `wc_DhGenerateKeyPair`

Despite it not being mentioned in the documentation [1] and v4.6 release
notes [2], the two size parameters became [3] not purely "out", but
"in/out", to avoid potential buffer overflows.

[1] https://www.wolfssl.com/documentation/manuals/wolfssl/group__Diffie-Hellman.html
[2] https://github.com/wolfSSL/wolfssl/releases/tag/v4.6.0-stable
[3] 4364700c01
2022-07-03 14:05:40 +01:00
Charles Kerr e7627dc209
refactor: add tr_peer.requestBlocks() (#3384) 2022-07-02 14:42:16 -05:00
Colin B 5e43731bcf
Ensure hybrid torrents are parsed correctly. (#3388) 2022-07-02 12:16:34 -05:00
Colin B 3237323b8e
Add basic support for v2 hashes in transmission-show (#3380)
* Add basic support for v2 hashes in transmission-show

* Add sha256 for more libraries

* Fix issue with sha256 digest length
* Add sha256 for polarssl
    Note: Bumping miniumum PolarSSL version to 1.3 because of
    sha2->sha256 name change.
* Add sha256 for CommonCrypto/ccrypto
* Add sha256 for cyassl
2022-07-01 09:49:33 -05:00