Commit Graph

55 Commits

Author SHA1 Message Date
Antoine Cœur bdac708762
docs: fix various typos and misspellings (#2955) 2022-04-21 09:28:38 -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 31c65eec1f
refactor: remove tr_strvJoin() (#2896) 2022-04-07 17:26:59 -05:00
Charles Kerr 977b2a1bab
refactor: tr_loadFile() tr_saveFile() take a std::string_view filename arg (#2822)
* refactor: tr_saveFile takes a string_view

* refactor: tr_saveFile, tr_loadFile take string_view filename
2022-03-25 19:31:27 -05:00
Charles Kerr fa8aaf7631
refactor: remove remaining vararg log messages (#2776) 2022-03-17 17:39:06 -05:00
Charles Kerr 54ef7341a2
refactor: fmt pt 4 (#2774)
Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-03-16 19:23:44 -05:00
Charles Kerr 0be920156b
refactor: fmt part 3 (#2773) 2022-03-15 19:51:36 -05:00
Charles Kerr 72a67054ea
refactor: fmt part 2 (#2771) 2022-03-15 09:52:16 -05:00
Charles Kerr af339a15ed
refactor: remove deep logging (#2749)
* refactor: remove "deep logging"
2022-03-09 23:51:14 -06:00
Charles Kerr 7a227917ff
fix: rpc-server shutdown assertion failure (#2747)
Fixes #2742.
2022-03-09 11:13:51 -06:00
Charles Kerr cdd819772d
feat: tr_runInEventThread() now takes std::function, typesafe args (#2739) 2022-03-04 20:26:03 -08:00
LaserEyess 377c335d0f
fix broken ip address string size on windows (#2733)
Make sure the buffer is at least as big as an ipv6 address

Co-authored-by: LaserEyess <LaserEyess@users.noreply.github.com>
2022-03-03 21:17:28 -08:00
LaserEyess 3bc21fe8a6
fixup: unix socket implementation changes (#2707)
* Use std::unique_ptr for bindAddress

* fixup: unix socket implementation changes

Assortment of changes and comments from #2574

- actually assign variables in the tr_rpc_address union for ipv4 and
  ipv6
- use std::size() instead of std::string.length()
- add [[maybe_unused]] to bindUnixSocket() args for Windows
- fix error log for windows to to actually print a string instead of
  an enum int
- use C++ style cast for ecvonnlistener_new_bind()
- refactor rpc URL log line to only substitute a single string
- remove redundant tr_rpc+address_is_valid() check

* change TrUnixSocketPrefix to std::string_view

This allows for removing runtime overhead of strlen() in a few places.

Co-authored-by: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com>
Co-authored-by: LaserEyess <LaserEyess@users.noreply.github.com>
2022-02-27 14:05:08 -08:00
LaserEyess 706735ca88
Support binding the RPC to a Unix socket on *nix platforms (#2574)
* Support binding the RPC to a Unix socket on *nix

This commit adds unix socket support for a RPC. Some refactoring was
required in order to split out the RPC server's address struct from the
normal network address struct used for peers. It would cause
unacceptable overhead to add the unix socket length to the union.

Co-authored-by: Malte Voos <malte@malvo.org>

* add RPC socket mode to control unix socket perms

Unix socket permissions are important to control for security reasons,
and libevent defaults to 0755, which may not be what users want.

Co-authored-by: LaserEyess <LaserEyess@users.noreply.github.com>
Co-authored-by: Malte Voos <malte@malvo.org>
2022-02-23 15:09:54 -06:00
Charles Kerr ba14ffa74c
refactor: sonarcloud "use if init" statements (#2587) 2022-02-07 23:44:31 -06:00
Charles Kerr ebb2ab6aee
chore: update license spdx abbreviations (#2582)
Use SPDX license list 3.0 terminology: replace deprecated identifiers
GPL-2.0" and "GPL-3.0" with "GPL-3.0-only" and "GPL-3.0-only".
2022-02-07 10:25:02 -06:00
Charles Kerr ecef0feb0c
refactor: clang-tidy in libtransmission (#2578)
* chore: enable cppcoreguidelines-slicing warning

* chore: enable readability-named-parameter warning

* chore: enable bugprone-reserved-identifier check

* chore: enable bugprone-not-null-terminated-result check

* chore: enable bugprone-sizeof-expression check

* chore: enable bugprone-incorrect-roundings check

* chore: enable misc-misplaced-const check

* chore: enable bugprone-suspicious-include check

* chore: enable bugprone-signed-char-misuse check

* chore: enable modernize-raw-string-literal check

* chore: enable readability-static-accessed-through-instance check

* chore: enable readability-implicit-bool-conversion check

* fixup! Merge branch 'main' into refactor/clang-tidy
2022-02-06 22:28:36 -06:00
Charles Kerr 878405f862
Revert "fix: sonarcloud (#2558)" (#2562)
This reverts commit 8b9483f7fb.
2022-02-01 11:30:51 -06:00
Charles Kerr 8b9483f7fb
fix: sonarcloud (#2558)
* fix: add const modifier for functions

* fix: many sonarcloud use-init-statement warnings
2022-01-31 22:46:27 -06:00
Charles Kerr 253f4fe009
chore: remove /upload endpoint from rpc-server (#2550)
It's never been documented or supported and is unused by the web client.

In the unlikely case that a 3rd party app is using it, use 'torrent-add'
instead; it's documented + supported.
2022-01-31 14:54:21 -06:00
Charles Kerr 02e9fd6b59
fix: use libdeflate_gzip_compress in rpc-server.cc (#2507) 2022-01-24 23:40:01 -06:00
Charles Kerr df1cca9b57
chore: update copyright years, make notices consistent (#2463) 2022-01-20 12:27:56 -06:00
Charles Kerr 3036a76beb
fix: sonarcloud code smells (#2421) 2022-01-17 12:39:50 -06:00
Charles Kerr d8d765c595
refactor: use libdeflate instead of zlib's deflate() (#2405)
Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-01-17 10:20:12 -06:00
Charles Kerr b0ee4007ff
refactor: include cleanups (#2392)
* refactor: include <memory> when using shared_ptr or unique_ptr

* refactor: include <cstdio> iff we use it

* refactor: include <cstring> iff we use it

* refactor: include <cstdlib> iff we use it

* refactor: include <string_view> or <string> iff we use it

* refactor: include <array> iff we use it

* refactor: include <ctime> iff we use it

* refactor: include <cctype> iff we use it

* refactor: misc #include cleanups in libtransmission
2022-01-12 20:13:58 -06:00
Charles Kerr 0c16c454ba
refactor: base64 utils (#2381)
base64 encode/decode now take std::string_views and return std::strings
2022-01-08 06:46:25 -06:00
Charles Kerr bd68d3a2fd
refactor: use tr_sha1_digest_t everywhere (#2330) 2021-12-21 16:14:15 -06:00
Charles Kerr 2277fde4e0
refactor: prefer tr_strv*() funcs (#2317) 2021-12-15 20:09:46 -06:00
Charles Kerr 42b1362760
refactor: tidy libtransmission includes (#2316) 2021-12-15 15:25:42 -06:00
Charles Kerr a79a868257
refactor: make tr_variantFromBuf() public (#2187)
* refactor: add tr_variantFromBuf() and support inplace json/benc parsing
2021-11-17 23:37:35 -06:00
Charles Kerr f14e741052
fix: some sonarcloud warnings (#2189)
* fix: pass-large-object-by-reference-to-const warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0Gz8ze7dx8i2lkKEvq\&open\=AX0Gz8ze7dx8i2lkKEvq

* fix: use-std-array-instead-of-C-array warning

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5B-\&open\=AX0L8qcgUnpKTxYiu5B-

* fix: extract-assignment-from-expression

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5CH\&open\=AX0L8qcgUnpKTxYiu5CH

* fix: move-include-directives-to-top

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qlYUnpKTxYiu5CQ\&open\=AX0L8qlYUnpKTxYiu5CQ

* fix: use-init-statement

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0L8qcgUnpKTxYiu5CK\&open\=AX0L8qcgUnpKTxYiu5CK

* fix: use-init-statement

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlmBwxvzFbF6whWh\&open\=AX0WPlmBwxvzFbF6whWh

* fix: ensure-move-constructor-is-noexcept

https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlWzwxvzFbF6whWU\&open\=AX0WPlWzwxvzFbF6whWU

* fix: use-init-statement

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP20jI_aUyxGBxCD\&open\=AX0bZP20jI_aUyxGBxCD

* fix: replace-redundant-type-with-auto

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP0rjI_aUyxGBxCB\&open\=AX0bZP0rjI_aUyxGBxCB

* fix: make-parameter-const

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0gkQqqPDVGqE4PY-io\&open\=AX0gkQqqPDVGqE4PY-io

* fix: use-init-statement

https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0rARJbfJ-O-YIDS9xM\&open\=AX0rARJbfJ-O-YIDS9xM

* fix: use-init-statement

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0WPlmBwxvzFbF6whWh\&open\=AX0WPlmBwxvzFbF6whWh

* fix: explicitly-delete-copy-ctor

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0gkQr6PDVGqE4PY-i4\&open\=AX0gkQr6PDVGqE4PY-i4

* fix: use-init-statement

Xref: https://sonarcloud.io/project/issues\?id\=transmission_transmission\&issues\=AX0bZP9wjI_aUyxGBxCF\&open\=AX0bZP9wjI_aUyxGBxCF
2021-11-17 18:17:09 -06:00
Charles Kerr ec94c90da9
fix: coverity warnings (#2186)
* fix: silence check_return warning

Xref: https://scan5.coverity.com/reports.htm\#v48014/p10174/fileInstanceId\=203924665\&defectInstanceId\=52245209\&mergedDefectId\=1494152

* fix: silence check_return warning

Xref: https://scan5.coverity.com/reports.htm\#v48014/p10174/fileInstanceId\=203924692\&defectInstanceId\=52245241\&mergedDefectId\=1493826

* fix: silence check_return warning

Xref: https://scan5.coverity.com/reports.htm\#v48014/p10174/fileInstanceId\=203924667\&defectInstanceId\=52245260\&mergedDefectId\=1493825

* fix: silence nullptr dereference warning

Xref: https://scan5.coverity.com/reports.htm\#v48014/p10174/fileInstanceId\=203924667\&defectInstanceId\=52245260\&mergedDefectId\=1493825

* fix: uninitialized variable in rpc-server z_stream

Xref: https://scan5.coverity.com/reports.htm\#v48014/p10174/fileInstanceId\=203924665\&defectInstanceId\=52245249\&mergedDefectId\=1494151

* fix: silence check_return warning

Xref: https://scan5.coverity.com/reports.htm\#v48014/p10174/fileInstanceId\=203924665\&defectInstanceId\=52245261\&mergedDefectId\=1492904

* fix: silence nullptr dereference warning

https://scan5.coverity.com/reports.htm\#v48014/p10174/fileInstanceId\=203924689\&defectInstanceId\=52245236\&mergedDefectId\=1492890

* fix: silence unchecked return value warning

Xref: https://scan5.coverity.com/reports.htm\#v48014/p10174/fileInstanceId\=203924666\&defectInstanceId\=52245259\&mergedDefectId\=1491888
2021-11-17 15:56:50 -06:00
Charles Kerr 250a2e3cc5
refactor: remove unused pieces of str to variant (#2166)
* feat: add tr_variantInitStrView()

* refactor: remove unused function tr_variantFromJsonFull

* refactor: tr_variantFromJson() now takes a string_view

* refactor: tr_variantFromBenc() now takes a string_view

* refactor: remove unused source arg from tr_variantFromBencFull()

* refactor: make tr_variantFromBuf() private
2021-11-15 01:21:57 -06:00
Charles Kerr af8e9e66b9
fixup! refactor: rpc-server.cc (#2152) (#2164)
fixup: rpc-server auth regression; fix tests
2021-11-14 21:54:48 -06:00
Charles Kerr 6dda4f2b5f
refactor: remove tr_variantDictFindStr() from rpc-server.cc (#2159)
* refactor: use FindStrview for rpc username

* refactor: use tr_variantDictFindStrView for rpc bind address
2021-11-14 16:06:32 -06:00
Charles Kerr 3bab6f02dc
refactor: rpc-server.cc (#2152)
* refactor: first baby steps towards C++ifying rpc_server
2021-11-14 15:14:37 -06:00
Charles Kerr d55474161e
refactor: rpc whitelist (#2150)
* refactor: make rpc-whitelist string_view-friendly
2021-11-14 00:02:45 -06:00
Charles Kerr 99aeaa0eaf
refactor: tr_ssha1(), tr_ssha1_matches() (#2148)
* refactor: make tr_ssha1 and tr_ssha1_matches string_view-friendly
2021-11-13 20:03:01 -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 be22677f10
refactor: prefer string_view over raw char* (#2097) 2021-11-05 01:29:19 -05:00
Charles Kerr 790b0bb2b5
feat: add tr_quark_get_string_view() (#2083) 2021-11-01 20:01:27 -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 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 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 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
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
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 1fb5a79813
refactor: use maybe unused attribute (#1918)
* refactor: replace TR_UNUSED with [[maybe_unused]]
2021-10-10 11:52:26 -05:00