Commit Graph

4975 Commits

Author SHA1 Message Date
Charles Kerr 903338af72
refactor: tr_session.incomplete_dir (#2145) 2021-11-13 14:49:10 -06:00
Charles Kerr a8f640c559
refactor: tr_dirSpace() (#2143)
* refactor/tr_dirSpace
2021-11-13 12:09:14 -06:00
Charles Kerr 86f4e37571
refactor: tr_sys_path_is_relative() takes a string_view (#2142)
* refactor: tr_sys_path_is_relative() takes a string_view
2021-11-13 10:08:50 -06:00
Charles Kerr 254d837ddf
fixup! refactor: make piece checksums private (#2130) (#2136) 2021-11-13 00:53:52 -06:00
Charles Kerr 6571be2b95
feat: add tr_strvPath() (#2134)
* feat: add tr_strvJoin

* feat: add tr_strvPath
2021-11-12 18:10:04 -06:00
Charles Kerr d1f8c28fcd
refactor: make piece checksums private (#2130)
* refactor: remove tr_info.pieces
2021-11-12 10:42:51 -06:00
Dzmitry Neviadomski 319e1fc6bb
Replace C rand() with uniform_int_distribution and mt19937. (#2089)
Reuse random engine and distribution itself and change only
distribution bounds via lightweight param type.
2021-11-11 13:03:33 -06:00
Charles Kerr 7693ef69bf
refactor: magnet metainfo (#2124)
* refactor: magnet-metainfo
2021-11-09 20:42:18 -06:00
Charles Kerr bdf1bb6d17
refactor: tr_strv*() util functions (#2123)
* feat: add tr_strv utils
2021-11-09 18:13:47 -06:00
Charles Kerr d8b57fe4dc
refactor: web_utils (#2121)
* chore: move web utils from web, utils to web-utils
2021-11-08 21:30:03 -06:00
Charles Kerr 4ecf74081c
refactor: remove tr_ctorSetMetainfoFromHash() (#2116)
* refactor: remove tr_ctorSetMetainfoFromHash()
2021-11-07 20:04:07 -06:00
Charles Kerr af4a953cd1
fixup! refactor: remove tr_piece struct (#2059) (#2115)
yet another fixup of the tr_piece struct removal
2021-11-07 18:25:45 -06:00
Charles Kerr 2bd328c082
fixup! refactor: c++ify torrent ctor (#2098) (#2114)
handle nullptrs in the accessor functions
2021-11-07 17:35:32 -06:00
Charles Kerr bbdb488224
perf: recycle variant tree walking helpers (#2100)
* perf: recycle the helper classes that walk through variant trees
2021-11-05 09:54:44 -05:00
Charles Kerr be22677f10
refactor: prefer string_view over raw char* (#2097) 2021-11-05 01:29:19 -05:00
Charles Kerr 087a804b49
fix: another piece priority fix (#2099)
move initialization to later in torrent construction so that we can correctly check whether the torrent is done or not
2021-11-05 00:06:19 -05:00
Charles Kerr 344ac056c8
refactor: c++ify torrent ctor (#2098)
* refactor: c++ify the torrent-ctor implementation
2021-11-04 22:08:38 -05:00
Charles Kerr 75ce9eae7b
perf: minor perf improvements (#2096)
* perf: use avoid unnecessary strlen when making log messages

* perf: avoid temporary string alloc/free in tr_metainfoAppendSanitizedPathComponent()
2021-11-03 20:36:32 -05:00
Charles Kerr 7724111a8b
refactor: increase use of tr sha1 digest t (#2091)
* refactor: make tr_sha1_digest_t an array of std::byte

* refactor: increase use of tr_sha1_digest_t
2021-11-03 19:55:04 -05:00
Charles Kerr 655050ce70
build: enable more .clang-tidy checks (#2088)
* build: add more clang-tidy warnings
2021-11-03 08:59:39 -05:00
Charles Kerr fa2ef23bdc
refactor: fix uninit var warnings in blocklist.cc (#2087) 2021-11-02 22:55:43 -05:00
Charles Kerr 002b45a95c
fixup! refactor: remove tr_piece struct (#2059) (#2086)
perf: discard piece priorities when done downloading
2021-11-02 21:55:33 -05:00
Charles Kerr 9dca5f2086
perf: intern the announcer module's URL strings (#2085)
* perf: intern the announcer module's internal URLs
2021-11-02 18:00:01 -05:00
Charles Kerr 790b0bb2b5
feat: add tr_quark_get_string_view() (#2083) 2021-11-01 20:01:27 -05:00
Charles Kerr e5225ba8a2
refactor: tr_torrentFindFromHashString() takes a std::string_view (#2082)
* refactor: tr_torrentFindFromHashString() takes a string_view
2021-11-01 19:18:09 -05:00
Charles Kerr 5594b16358
refactor: tr_quark_lookup() takes a std::string_view (#2081)
* refactor: tr_quark_lookup takes a std::string_view
2021-11-01 18:29:13 -05:00
Charles Kerr 3a4dd6de95
refactor: add TR_PRIsv and TR_PRIsv_ARG (#2080)
* refactor: add TR_PRIsv, TR_PRIsv_ARG macros

Like PRId64 and similar macros, these new macros are printf() helpers.
They are for passing std::string_views to printf()-like functions.
2021-11-01 17:14:17 -05:00
Charles Kerr ba59060737
feat: new function tr_variantGetStrView() (#2079)
* feat: new method tr_variantGetStrView()

* test: add new variant tests
2021-11-01 16:30:18 -05:00
Charles Kerr feaf12a205
refactor: tr_urlIsValid*() now takes a std::string_view (#2078)
* refactor: tr_urlIsValid*() now take a string_view arg
2021-11-01 15:36:14 -05:00
Charles Kerr da51a17c30
refactor: add util tr_strvstrip() to strip string_views (#2077) 2021-11-01 13:50:53 -05:00
Charles Kerr 484e9ee64e
refactor: add a tr_urlParse() with no heap allocs (#2070) 2021-10-31 13:48:32 -05:00
Charles Kerr cedec74d26
perf: add tr_buildBuf() (#2068)
* refactor: add tr_buildBuf() utility
2021-10-31 11:38:10 -05:00
depler 8cac7d6f94
Update file-win32.cc (#2066)
Fix pointer `return false` after refactoring
2021-10-31 02:15:07 -05:00
Charles Kerr 7c07f4acbb
perf: omit extra std::map in tr_torrentPrimaryMimeType() (#2064) 2021-10-30 11:49:47 -05:00
Charles Kerr 9200d972c3
refactor: use a std::vector for tr_session.removed_torrents (#2062) 2021-10-29 18:49:15 -05:00
Charles Kerr f270d6081c
refactor: cppcoreguidelines-init-variables pt. 15 (#2055)
* refactor: uninit vars in subprocess-posix

* refactor: uninit vars in handshake

* refactor: uninit vars in file-posix

* refactor: uninit vars in platform-quota
2021-10-29 17:43:25 -05:00
Charles Kerr d6032f829b
refactor: remove tr_piece struct (#2059)
* refactor: remove tr_piece struct
2021-10-29 13:24:30 -05:00
Frank Aurich 82d9232084
Fix RPC 'table' mode not being properly activated (#2058)
* Fix RPC 'table' mode not being properly activated.
2021-10-29 01:54:46 -05:00
Charles Kerr 1d0993c3a5 fix: fmr warning in removeAllPeers() 2021-10-27 21:43:12 -05:00
Charles Kerr 9be93a489e
refactor: simplify sorting peers by liveliness (#2050) 2021-10-27 21:05:00 -05:00
Charles Kerr 6bd229fcfd
fix: clang 13 nullptr warnings in libtransmission (#2054)
* fix: nullptr dereference warning in tr_peerMgrPeerStats

* fix: nullptr dereference warning in refillUpkeep()

* fix: nullptr dereference warning in tr_peerIsSeed()

* fix: nullptr dereference warning in rechokeUploads()

* fix: nullptr dereference warning in tr_variantDictAdd

* fix: nullptr dereference warning in tr_ioFindFileLocation()

* fix: nullptr dereference warning in tr_spawn_async_in_child()

* fix: nullptr dereference warning in calculatePiecePriority()
2021-10-27 20:16:24 -05:00
razaq c3f1aafb96
add TR_TORRENT_TRACKERS env variable to script call (#2053)
* add TR_TORRENT_TRACKERS env variable to script call
2021-10-27 13:25:09 -05:00
Charles Kerr ed801eab8f
feat: less prolix announce error logging (#2052) 2021-10-27 08:34:16 -05:00
Dan Walters 8234d064a8
fix: apply optional peer socket TOS to UDP sockets (#1043)
This effectively makes the TOS setting apply to uTP and DHT traffic.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-10-26 20:59:31 -05:00
Charles Kerr 2b65b985cf
refactor: cppcoreguidelines-init-variables pt. 14 (#2049)
* refactor: fix uninit var warnings in ptrarray

* refactor: fix uninit var warnings in bitfield

* refactor: fix uninit var warnings in handshake

* refactor: fix uninit var warnings in tr-dht

* refactor: fix uninit var warnings in natpmp

* refactor: fix uninit var warnings in tr-dht

* refactor: fix uninit var warnings in crypto-utils-openssl

* refactor: fix uninit var warnings in handshake

* refactor: fix uninit var warnings in crypto-utils

* refactor: fix uninit var warnings in crypto

* Revert "refactor: fix uninit var warnings in handshake"

This reverts commit 5aaa9cc30a.

* refactor: fix uninit var warnings in crypto-utils-ccrypto

* refactor: fix uninit var warnings in crypto-utils-polarssl

* refactor: fix uninit var warnings in crypto-utils-cyassl

* fixup! refactor: fix uninit var warnings in crypto-utils-cyassl

* fixup! refactor: cppcoreguidelines-init-variables pt. 13 (#2043)
2021-10-26 19:16:56 -05:00
Frank Aurich d9277d4b93
transmission-remote: Fix size display for torrents > 4GB (#2029)
* As size_t is not 64-bit on all platforms, explicitly use uin64_t when dealing with byte sizes to support torrents > 4GB
2021-10-26 16:06:47 -05:00
Charles Kerr b797b4c94f
refactor: cppcoreguidelines-init-variables pt. 13 (#2043)
* refactor: fix uninit var warnings in ptrarray

* refactor: fix uninit var warnings in bitfield

* refactor: fix uninit var warnings in handshake

* refactor: fix uninit var warnings in tr-dht

* refactor: fix uninit var warnings in natpmp

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2021-10-26 13:02:07 -05:00
Charles Kerr a1c5a215bf
refactor: remove peer-mgr replication info (#2021)
* refactor: remove peer-mgr replication info

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2021-10-25 10:29:19 -05:00
Charles Kerr 775e30eefd
refactor: getPeerCandidates returns a std::vector (#2042)
Previously was a manually-malloced and freed array.
2021-10-25 00:15:04 -05:00
Charles Kerr 93d8a03d55
refactor: remove outvar args from tr_torGetFooBlockRange() functions (#2041) 2021-10-24 22:39:19 -05:00
Dzmitry Neviadomski 3a966a77d1
Remove C-style STD headers in watchdir-kqueue.cc (#2037)
`string.h` is unused, `cerrno` is needed for `errno` macro.
2021-10-24 17:30:31 -05:00
Charles Kerr 3008a992ca
fix: Bitfield.getRaw() regression (#2023)
* fix: Bitfield.getRaw() regression
2021-10-24 15:43:36 -05:00
Mike Gelfand 5edbcb3740
Add CommonCrypto-based crypto utils implementation (#2032)
* Add CommonCrypto-based crypto utils implementation

Ported and adapted from an old (circa 2014-2015) branch of mine.

DH helpers are based on CCBigNum since CCDH doesn't provide acceptable error
reporting, and SecDH interface is a bit weird and limiting. Given that all
mentioned APIs are private, it doesn't seem to matter which one we're using as
any of them could be changed/removed by Apple at any point.

* Switch Xcode project to CommonCrypto backend
2021-10-24 21:19:57 +03:00
Charles Kerr 3ec312dee8
refactor: cppcoreguidelines-init-variables pt. 12 (#2022)
* refactor: cppcoreguidelines-init-variables pt. 12 (#2022)
2021-10-24 12:40:15 -05:00
Charles Kerr c472cbd88d
refactor: only use [[maybe_unused]] if arg might be used (#2033)
* refactor: [[maybe_unused]] iff arg _might_ be used

If the arg is never used, comment out its name.
If the arg is _sometimes_ used e.g. with ifdefs, use [[maybe_unused]].
2021-10-24 11:41:54 -05:00
Charles Kerr a127826d76
refactor: cppcoreguidelines-init-variables pt. 11 (#2012)
* refactor: uninit vars in bandwidth.cc

* refactor: uninit vars in cache.cc

* refactor: uninit vars in fdlimit.cc

* refactor: uninit vars in inout.cc

* refactor: uninit vars in platform.cc

* refactor: uninit vars in log.cc

* refactor: uninit vars in tr-utp.cc

* refactor: uninit vars in stats.cc

* refactor: uninit vars in trevent.cc

* refactor: uninit vars in session-id.cc

* fixup! refactor: uninit vars in cache.cc

* refactor: uninit vars in upnp.cc

* refactor: uninit vars in file.cc

* refactor: uninit vars in tr-lpd.cc

* refactor: uninit vars in tr-udp.cc
2021-10-23 10:43:15 -05:00
Charles Kerr b9e8a11793
fixup! refactor: use std::string in tr_scrape_response (#1866) (#2018)
fix leaked errmsg introduced in 3fd5c81 (#1866)
2021-10-22 18:14:46 -05:00
Charles Kerr 91a447e3ea
fixup! refactor: use std::string in tau_tracker (#1867) (#2017)
fix: memory leak regression
2021-10-22 17:01:55 -05:00
Charles Kerr 94ee81f98d
fixup! refactor: add tr_peer_id_t (#2004) (#2016)
fix: array bounds read error introduced yesterday
2021-10-22 15:24:30 -05:00
Charles Kerr 9e716bb9dc
refactor: cppcoreguidelines-init-variables pt. 10 (#2006)
* refactor: uninit vars in peer-io.cc

* refactor: uninit vars in rpc-server.cc

* refactor: uninit vars in port-forwarding.cc

* refactor: uninit vars in torrent-ctor.cc
2021-10-22 08:51:36 -05:00
Charles Kerr b491da0ce4
refactor: add tr_peer_id_t (#2004)
* refactor: move handshake_done args into a convenience struct

* refactor: move peer_id from peerIo to tr_handshake

tr_handshake is a short-term object and tr_peerIo is long-term, so this
effectively narrows the scope of this field.

* chore: remove unused field tr_peerIo.isEncrypted

* refactor: add tr_peer_id_t type to hold peer ids.

this is a 'using' alias to a std::array<> so that code passing peer-ids
around doesn't have to memcmp / memcpy PEER_ID_LEN anymore. Also removes
the now-unused PEER_ID_LEN macro.
2021-10-21 21:40:55 -05:00
Charles Kerr 3b019ada3d
refactor: remove redundant assertions (#2009) 2021-10-21 19:02:38 -05:00
Charles Kerr 8cdc2c633e
refactor: replace tr_torrentFiles() with tr_torrentFileProgress() (#1994)
* refactor: s/tr_torrentFiles/tr_torrentFileProgress

Replace tr_torrentFiles() with a new function, tr_torrentFileProgress().

tr_torrentFiles() heap-allocated an array of progress structs. There is
nothing intrinsic in tr_torrent making batch computation more efficient,
so this PR replaces it with tr_torrentFileProgress(), a per-file variant
that doesn't use the heap.
2021-10-21 13:31:03 -05:00
Charles Kerr b0fd4b474a
refactor: cppcoreguidelines-init-variables pt. 9 (#1997)
* refactor: fix uninit variable warnings in getopt, torrent-magnet
2021-10-21 12:40:36 -05:00
Charles Kerr 850b3caa61
refactor: prefer constexpr over enum for non enumerated constants (#1996)
refactor: prefer constexpr over enum for non-enumerated constants
2021-10-20 19:39:05 -05:00
Charles Kerr 32395056e2
refactor: cppcoreguidelines-init-variables pt. 8 (#1993)
* refactor: fix uninit var warnings in rpcimpl
2021-10-20 11:31:20 -05:00
Charles Kerr 236a0965fa
refactor: tr_variant*Str() functions now take a std::string_view (#1990)
* refactor tr_variant*Str functions now take a std::string_view

* refactor: tr_torrentPrimaryMimeType returns a string-view
2021-10-19 21:30:50 -05:00
Charles Kerr 0b1e12ac5b
refactor: fix uninit var warnings in upnp, utils, verify, watchdir (#1989) 2021-10-19 11:09:38 -05:00
Charles Kerr d7773c47b6
fix: crash on torrent with 65536 blocks per piece (#1988)
Fixes #1411.
2021-10-18 19:25:00 -05:00
Daniel Kamil Kozar 77b11232f2
Add support for creating torrents with a source flag (#443)
* Add support for creating torrents with a source flag

* Add the source flag functionality for Mac OSX

* Source flag should be a part of the info dictionary

* Address review comments

* Rename "sourceFlag" to "source" since "Flag" is usually reserved for booleans.
* Free the "source" pointer in tr_metainfoFree.
* Add information about transmission-create argument to its manpage.

* Replace all occurences of "sourceFlag" with "source" and use "Source tag" in UI

* Settle on just "Source" in UI

* The last usage of "flag" hopefully bites the dust! ;-)

* Add a missing free for the source in tr_metainfoFree

* Add a "source" field to the torrent-get RPC method

* uncrustify

* Test for torrents having different infohashes due to different source flags.

This is the whole point of this feature, so it makes sense to test it.

* case is important

* try to incorporate the macosx xml changes
2021-10-18 18:05:39 -05:00
Mike Gelfand bf41e1487a
Switch from gtk to gtkmm (#1969)
* Gtk to gtkmm: main.cc

* Gtk to gtkmm: details.cc

* Gtk to gtkmm: tr-window.cc

* Gtk to gtkmm: tr-prefs.cc

* Gtk to gtkmm: open-dialog.cc

* Gtk to gtkmm: file-list.cc

* Gtk to gtkmm: filter.cc

* Gtk to gtkmm: torrent-cell-renderer.cc

* Gtk to gtkmm: msgwin.cc

* Gtk to gtkmm: makemeta-ui.cc

* Gtk to gtkmm: relocate.cc

* Gtk to gtkmm: stats.cc

* Gtk to gtkmm: dialogs.cc

* Gtk to gtkmm: hig.cc

* Gtk to gtkmm: favicon.cc

* Gtk to gtkmm: icons.cc

* Gtk to gtkmm: tr-icon.cc

* Gtk to gtkmm: actions.cc

* Gtk to gtkmm: notify.cc

* Gtk to gtkmm: util.cc

* Gtk to gtkmm: tr-core.cc

* Gtk to gtkmm: conf.cc

* Glibmm <2.62 compatibility (missing Glib::ustring::sprintf)

* Glibmm <2.56 compatibility (missing Glib::RefPtr<>::get)

* Bump glibmm to 2.50.1+ (C++17 fix in Glib::Variant)

* Fix empty timestamps on message log export (broken by #1444)

* Fix LGTM build issues

* Review fixes
2021-10-18 23:22:31 +03:00
Charles Kerr 462651bb8e
refactor: rpcimpl.cc getTorrents() returns a std::vector (#1986)
* refactor: rpcimpl.cc getTorrents() returns a std::vector

* refactor: tr_torrentQueueMove*() uses std::vector
2021-10-18 09:48:45 -05:00
Charles Kerr 2e50383760
refactor: cppcoreguidelines-init-variables pt. 6 (#1979)
* refactor: fix uninit var warnings in magnet.cc

* refactor: fix uninit var warnings in completion.cc

* refactor: fix uninit var warnings in session.cc
2021-10-18 07:51:02 -05:00
Charles Kerr 4739fd0959
fixup! Add total disk space to free-space RPC request (#1682) (#1984)
fix: unused variable warning in free-space code
2021-10-17 22:04:20 -05:00
Charles Kerr 8be7f774db
fixup! tr_quark_new() now takes a std::string_view (#1961) (#1983) 2021-10-17 20:59:08 -05:00
Charles Kerr c6501c655c
refactor: add performance-* to libt .clang-tidy (#1981) 2021-10-17 16:09:58 -05:00
Charles Kerr 16e9a99fe9
refactor: clang-tidy --fix modernize-deprecated-headers (#1980) 2021-10-17 15:17:18 -05:00
Charles Kerr 2bc9959dc9
refactor: cppcoreguidelines-init-variables pt. 5 (#1970)
* fix: uninitialized variables in torrent.cc
2021-10-17 12:06:00 -05:00
Charles Kerr 4aba9b623f
fix: assertion failure in bitfield::bitfield(flags, n) (#1976)
* fix: bitfield construct-from-bool-array regression
2021-10-17 10:34:36 -05:00
Charles Kerr 290f7fc71a
fix: cppcoreguidelines-init-variables pt. 4 (#1965)
* fix: uninitialized variables in resume
2021-10-16 11:17:34 -05:00
Dmytro Lytovchenko 953f07375a
Modernize bitfield.cc: Storage changes and refactor (#1927)
* Modernize bitfield.cc: Storage changed to vector of bytes, return vector from getRaw, new Span readonly memory view
Modernize bitfield.cc: Code style/review notes
Modernize bitfield.cc: Code format

* Modernize bitfield.cc: Swap end and begin in bit counting code assertion

* Modernize bitfield.cc: Rewrite states and simplify code

* Modernize bitfield.cc: Fixing the code and tests

* Modernize bitfield.cc: Fixing tests

* Modernize bitfield.cc: Formatting; +std::size, +const
2021-10-16 09:04:19 -05:00
Charles Kerr 43ad1346eb
refactor: tr_torrentInfoGetMagnetLink now takes a std::string_view (#1968)
* refactor: tr_torrentInfoGetMagnetLink now takes a std::string_view
2021-10-16 08:20:04 -05:00
Charles Kerr 7b423b7e0d
refactor: tr_utf8clean now takes a std::string_view (#1967) 2021-10-15 20:02:40 -05:00
Charles Kerr 7e5e1f3812
refactor: tr_rpc_parse_list_str() takes a std::string_view (#1966) 2021-10-15 18:34:22 -05:00
Charles Kerr 3e7b8eb7bb
refactor: tr_parseNumberRange() takes a std::string_view (#1962)
* tr_parseNumberRange() now takes a std::string_view
2021-10-15 17:15:33 -05:00
Sander van Kasteel d11ccf113c
Added primitive CORS header support (#1885)
* Copied over patch from github user fecristovao

* Added nullptr check
2021-10-15 15:10:09 -05:00
Charles Kerr fb39c4663c
Fix/benc zero length dict key (#1964)
* fix: benc decoding bug that failed to parse hybrid torrents
2021-10-15 13:13:33 -05:00
Charles Kerr 23d85458f8
fix: cppcoreguidelines-init-variables pt. 3 (#1954)
* refactor: fix uninitialized variable warnings in variant code

* refactor: fix uninitialized variable warnings in web, webseed
2021-10-15 12:27:12 -05:00
Charles Kerr 567f1e48c8
tr_quark_new() now takes a std::string_view (#1961) 2021-10-15 08:28:47 -05:00
Charles Kerr c98b4d33c3
refactor: use C++'s [[noreturn]] atrribute (#1960) 2021-10-14 22:16:52 -05:00
Charles Kerr f0171668c6
refactor: use C++ static_assert; remove TR_STATIC_ASERT (#1959) 2021-10-14 15:40:35 -05:00
Charles Kerr fd5804fbb7
refactor: add readability-else-after-return to clang-tidy (#1956)
* refactor: add readability-else-after-return to clang-tidy
2021-10-14 14:26:38 -05:00
Johan 04f8b82308
Add total disk space to free-space RPC request (#1682)
* Add total space to free-space endpoint

* Update docs
2021-10-14 12:07:16 -05:00
Charles Kerr ab82e155be
build: add clang tidy modernize loop convert (#1949)
* build: add clang-tidy check modernize-pass-by-value

* build: add clang-tidy check modernize-loop-convert

* refactor: constexpr

* refactor: make preallocGuess a std::array
2021-10-14 10:36:49 -05:00
Charles Kerr 5df6e4f88f
fix: uninitialized variables in announcer (#1936) 2021-10-14 09:22:28 -05:00
Rosen Penev 1f48884726
fix runtime with wolfSSL and fastmath (#1950)
wolfSSL's fastmath support requires options.h to be included before
anything else. Otherwise bad codepaths get taken and a crash occurs
during DH initialization.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-10-13 22:48:04 -05:00
Charles Kerr af2af2a57e
build: add clang-tidy check modernize-pass-by-value (#1946) 2021-10-13 19:14:27 -05:00
Charles Kerr 65a3a7d042
build: have clang-tidy check for NULL in libtransmission (#1945) 2021-10-13 18:12:51 -05:00
Charles Kerr 306f0c4b80
fix: uninitialized variables pt 1: peer-mgr.cc (#1932)
* fix: uninitialized variables in peer-mgr.cc
2021-10-13 10:08:37 -05:00
Charles Kerr 98e16a178f
refactor: add an enumeration of the script types (#1934)
* refactor: add an enumeration of the script types

This simplifies the API by having a single set of functions that can be
used for getting/setting all the script types.
2021-10-12 22:46:12 -05:00
Charles Kerr 16dcc224ec
feat: add rpc-version-semver to RPC's session-get (#1935)
* feat: add rpc-version-semver to RPC's session-get
2021-10-12 22:03:28 -05:00
Charles Kerr ba6513ed4a
feat: add an option to run a script when a torrent is added (#1896)
Co-authored-by: cfpp2p <cfpp2p>
2021-10-12 16:32:32 -05:00
Kirill Ovchinnikov 4daaea9ff1
Replace NULL back with nullptr (mistake after auto-rebase) (#1933) 2021-10-12 14:45:18 -05:00
Kirill Ovchinnikov 53e5200968
Slashes fixes (#857)
* Fix 409/404 error when request URI is exactly equal with server URL

* Fix 409/404 error when user requests "/web" path without trailing slash

* Fix errors when "rpc_url" setting has no trailing slash

* Code style fixes

* rpc-server.c: code refactoring and minor fixes

* Minor code style fix

* rpc-server.c: handle_request refactoring

Co-Authored-By: uprt <15909793+uprt@users.noreply.github.com>

* rpc-server.c: minor refactoring

Co-Authored-By: uprt <15909793+uprt@users.noreply.github.com>

* Fix clang-format warning

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-10-12 09:28:46 -05:00
Charles Kerr 62372602b4
refactor: run clang-tidy on bandwidth.h, .cc (#1930)
* chore: allow vararg calls in qt/.clang-tidy

An awkward PR since this isn't intended for the qt/ codebase at all, but
rather for use with libtransmission instead. But libtransmission is *so*
noncompilant at this point that this config can't be promoted higher up
the tree yet. Instead, it needs to be callable on-request by devs.

* refactor: make clang-tidy happy with bandwidth.h, .cc

* refactor: use getFooSpeedBytesPerSecond()
2021-10-12 01:04:22 -05:00
Charles Kerr 02b9e17207
refactor: make tr_peerIo a class (#1928)
* refactor: make tr_peerIo a class

No behavioral changes.

Use `new` and `delete` and change `struct` references to `class`.

* refactor: make some tr_peerIo fields const

* refactor: reorganize tr_peerIo fields to remove padding holes

* refactor: remove redundant field tr_peerIo.isIncoming

* refactor: make tr_peerIo.inbuf, .outbuf fields const*
2021-10-11 16:54:16 -05:00
Charles Kerr 8f8d6e5db2
refactor: remove padding holes from Bandwidth (#1926)
Another pahole patch. No functional changes; just rearranging fields.

old sizeof(Bandwidth): 848
new sizeof(Bandwidth): 816
2021-10-11 13:11:24 -05:00
Dmytro Lytovchenko 39376f2105
Modernize/bitfield.cc: Make into C++ (#1917)
* Modernize bitfield.cc: Grouped member functions into the struct; C++ construction

* Modernize bitfield.cc: Naming style similar to qt/ C++ source

* Modernize bitfield.cc: Bitfield test updated to new API

* Modernize bitfield.cc: Renames for private functions

* Modernize bitfield.cc: Formatting

* Modernize bitfield.cc: Remove struct in 'struct Bitfield' and update commented code too

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-10-11 12:29:14 -05:00
Charles Kerr 1fb5a79813
refactor: use maybe unused attribute (#1918)
* refactor: replace TR_UNUSED with [[maybe_unused]]
2021-10-10 11:52:26 -05:00
Dmytro Lytovchenko a4d7e11a14
Bandwidth.cc bring naming closer to C++ style of code in qt/ (#1914)
* Modernize bitfield.cc: Rename tr_bandwidth to Bandwidth; Move dependent structs and consts into it

* Modernize bitfield.cc: Rename internal fields to lower_snake_case_ with suffix underscore

* Modernize bitfield.cc: Remove struct in 'struct Bandwidth' type usages

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-10-09 20:12:03 -05:00
Charles Kerr 0783e9691d
refactor: make tr_swarm a class (#1915) 2021-10-09 19:13:40 -05:00
Dmytro Lytovchenko c287b82c00
Modernize bandwidth.cc: Moved functions inside struct (#1895)
* Modernize bandwidth.cc: Move functions inside struct

* Modernize bandwidth.cc: Review notes - remove extraneous checks, move small functions into .H file, etc

* Modernize bandwidth.cc: Construction and destruction is now via C++ new/delete

* Modernize bandwidth.cc: Rename used() to notifyBandwidthConsumed()

* Modernize bandwidth.cc: Children is now unordered_set

* Modernize bandwidth.cc: Allocation functions for peer bandwidth are now using std::vector instead of ptrArrays

* Modernize bandwidth.cc: Code formatting

* Modernize bandwidth.cc: Private fields after public; Minor review notes

* Modernize bandwidth.cc: Ungroup enums into constants; Docs minor update

* Modernize bitfield.cc: Docs comments changes; Using constexpr instead of const

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-10-09 07:52:09 -05:00
Charles Kerr 1ba64684f9
refactor: C++ify clients.cc (#1907)
* refactor: use C++17 for clients.cc
2021-10-08 21:46:10 -05:00
Charles Kerr e9a264f29d
fix: minor dead store assignment warning in buildHandshakeMessage() (#1901) 2021-10-08 10:41:57 -05:00
Charles Kerr 454f55a9a2
fixup! refactor: prefer constexpr functions over static inline ones (#1887) (#1899)
do not declare tr_peerMsgs as both a struct and a class
2021-10-07 20:12:53 -05:00
Charles Kerr 93f5ad8767
fix: dead store warning in torrent.cc when building without assertions (#1898) 2021-10-07 18:44:43 -05:00
Dmytro Lytovchenko 2312965285
Suggested modernization steps for each *.CC module (#1801)
* Suggested modernization steps
2021-10-07 12:18:44 -05:00
Charles Kerr 3b72a1feea
refactor: use C++ inheritance for tr_peer, tr_peerMsgs, and tr_webseed (#1877)
* refactor: use C++ inheritance for tr_peer, tr_peerMsgs, and tr_webseed
2021-10-07 08:33:55 -05:00
Charles Kerr 83f21b8e0e
refactor: prefer constexpr functions over static inline ones (#1887)
* refactor: prefer constexpr functions over static inline ones
2021-10-06 17:24:04 -05:00
Charles Kerr f876a100a0
refactor: add [[fallthrough]] annotation (#1886) 2021-10-06 12:24:02 -05:00
Charles Kerr 003685b40a
refactor: use nullptr instead of NULL (#1884)
* refactor: use nullptr instead of NULL.

No functional changes; just more C++ification
2021-10-06 11:32:17 -05:00
Charles Kerr cc204e0b2c
refactor: prefer "using" over "typedef" (#1883)
* refactor: prefer "using" over "typedef"
2021-10-06 09:26:07 -05:00
Charles Kerr 035ca23226
fix: sonarcloud false error from O_SEQUENTIAL use. (#1882)
Xref: https://sonarcloud.io/project/issues?id=transmission_transmission&issues=AXvcFXmBqMngl89XhIRU&open=AXvcFXmBqMngl89XhIRU
2021-10-06 08:09:16 -05:00
Charles Kerr 396afd8a42
refactor: remove unused tr_variant_string.session (#1881)
This was assigned but never used. Shrinks sizeof(tr_bandwidth) by 8 bytes.
2021-10-05 19:06:18 -05:00
Charles Kerr 3b49fa993c
refactor: remove unused tr_variant_string.quark (#1880)
This was assigned but never used. Shrinks sizeof(tr_variant) by 8 bytes.
2021-10-05 14:33:02 -05:00
Charles Kerr 8983af7e46
refactor: make some tr_session methods private (#1879)
These public methods weren't used anywhere except in tr_session, so make
them private.

tr_sessionGetAltSpeed_Bps()
tr_sessionGetPieceSpeed_Bps()
tr_sessionGetRawSpeed_Bps()
tr_sessionSetAltSpeed_Bps()
tr_sessionSetSpeedLimit_Bps()
2021-10-05 13:54:02 -05:00
Charles Kerr 6b7f2f9e53
refactor: make tr_info.errorString a const char*. (#1878)
this field now points to tr_torrent.errorString instead of copying into
a standalone char array.

old: sizeof(tr_torrent) 2640
new: sizeof(tr_torrent) 2136
2021-10-05 12:23:07 -05:00
Charles Kerr 976fec6e94
refactor: make mime-type array inline constexpr (#1872)
* refactor: make mime-type array inline constexpr

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

* fix: remove newly-unused variable in mime-types.js
2021-10-01 17:55:19 -05:00
Charles Kerr 6b71050000
fix: recent regressions (#1873)
* fixup! refactor: use std::set in tr_webseed (#1847)

fix: use placement new to instantiate tr_webseeds.tasks

* fixup! refactor: use std::string in tr_scrape_response (#1866)

fix: avoid assigning a nullptr to std::string

* fixup! refactor: use std::string in tr_scrape_response (#1866)

fix: avoid assigning a nullptr to std::string
2021-10-01 16:57:30 -05:00
Charles Kerr b546fd423f
fix: sonarcloud getopt warnings (#1871)
* fix: sonarcloud out-of-bound memory access warning

* fix: sonarcloud out-of-bound memory access warning

* fix: sonarcloud 64-to-32 narrowing warning
2021-10-01 12:47:23 -05:00
Charles Kerr c87d22d53f
fix: coverity regressions reported on 2021-10-01 (#1869)
leaks introduced by 3fd5c81a
2021-10-01 08:21:05 -05:00
Charles Kerr 392c375b17
refactor: use std::vector in tau_announce_request (#1868) 2021-10-01 07:18:49 -05:00
Charles Kerr d8af31a866
refactor: use std::string in tau_tracker (#1867) 2021-10-01 06:29:53 -05:00
Charles Kerr 3fd5c81a22
refactor: use std::string in tr_scrape_response (#1866) 2021-09-30 16:33:31 -05:00
Charles Kerr 14fc626943
refactor: use std::vector for tau_scrape_request.payload (#1865) 2021-09-30 14:00:02 -05:00
Charles Kerr a76cf22211
refactor: use std::map for tr_announcer.scrape_info (#1864)
* refactor: use std::map for tr_announcer.scrape_info
2021-09-30 13:18:46 -05:00
Charles Kerr 7c4f66c44e
refactor: use a std:: container in getBlockRequestPeers() (#1863)
* refactor: use std::vector in getBlockRequestPeers()
2021-09-30 10:08:34 -05:00
Charles Kerr 766d95b352
refactor: use std::vector in rechokeUploads() (#1862) 2021-09-30 09:20:55 -05:00
Charles Kerr 5395e2e545
refactor: use std::vector and std::array in quark.cc (#1861)
* refactor: use std::vector and std::array in quark.cc
2021-09-30 07:01:04 -05:00
Charles Kerr e47762c7ca
refactor: use std::vector in extract_parts_from_multipart() (#1860)
* refactor: use std::vector in extract_parts_from_multipart()
2021-09-29 21:14:31 -05:00
Charles Kerr 78e571d6f2
refactor: use std::set in tr_announcer.stops (#1859)
* refactor: use std::set for tr_announcer.stops
2021-09-29 18:42:50 -05:00
Charles Kerr 20b5a8c62b
refactor: use std::vector in tr_sessionGetNextQueuedTorrents (#1858) 2021-09-29 17:21:04 -05:00
Charles Kerr 27068cb4a6
refactor: use std::unordered_set in loadBlocklists (#1857)
* refactor: use std::unordered_set in loadBlocklists
2021-09-29 16:23:34 -05:00
Charles Kerr baafb68bfd
refactor: use std::unordered_set for tr_torrent.labels (#1856) 2021-09-29 14:52:19 -05:00
Charles Kerr e03bc8e5bc
refactor: replace tr_ptrArray with std::unordered_set in tr_watchdir_scan() (#1854)
* replace tr_ptrArray with std:: in tr_watchdir_scan
2021-09-29 12:25:52 -05:00
Charles Kerr 055a8ecb4d
refactor: use std::set in deleteLocalData() (#1853) 2021-09-29 10:22:04 -05:00
Charles Kerr b413e934ba
in variant-benc, use std::deque not tr_ptrArray (#1851) 2021-09-28 19:09:01 -05:00
Charles Kerr e2f0432146
in variant-json, use std::deque not tr_ptrArray (#1850) 2021-09-28 08:56:46 -05:00
Charles Kerr 7d2f65455c
refactor: remove unused tr_list code (#1849) 2021-09-27 17:57:20 -05:00
Charles Kerr 16a70e57d2
refactor: use std::set in verify.cc's verifyList (#1848)
* refactor: use std::set in verify.cc
2021-09-27 17:07:58 -05:00