Commit Graph

69 Commits

Author SHA1 Message Date
Charles Kerr bf156a97cf
refactor: port forwarding (#3850)
* refactor: rename state enum type as tr_port_forwarding_state

* chore: use snake_case for tr_shared struct fields

* refactor: replace tr_shared with tr_port_forwarding

* refactor: make tr_natpmp_state an enum class

* refactor: uniform naming for port-forwarding module

* refactor: move output-only parameters in tr_natpmp::pulse() to return struct

* fix: use a nullptr multicastif if bindaddr is empty

* chore: use PascalCase for enum class values

* chore: clean up port-forwarding #includes

* chore: remove unused tr_port_forwarding::peerPort()
2022-09-30 08:59:10 -05:00
Dmitry Antipov 243ab1058d
refactor: fold session UDP innards into C++ class (#3794)
* Use std::unique_ptr to manage UDP core object

N.B.: it's no longer valid to call socket adjustments quirks from
tr_sessionSetUTPEnabled() because the corresponding object may be
not created yet. We have to create (or re-create) it explicitly
(like it's done in tr_sessionSetDHTEnabled()) or just set
is_utp_enabled_ flag of the session and assume that socket
adjustments will be done later when the object is constructed.
2022-09-21 13:25:53 -05:00
Charles Kerr e8686095ed
refactor: local peer discovery (#3696) 2022-08-24 16:03:30 -05:00
Charles Kerr 5bcbb7e34b
refactor: aggregate arc4 into libtransmission (#3684) 2022-08-20 13:41:40 -05:00
Charles Kerr c66303fae2
refactor: watchdir (#3606) 2022-08-10 08:34:51 -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 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 34cb56b2af
refactor: remove unused tr_ptrArray class (#3262)
* refactor: remove unused tr_ptrArray class

* fixup! build: add sanitizer CI runs when libtransmission-test changes (#3260)
2022-06-11 21:45:00 -05:00
Charles Kerr 19db28c04d
perf: faster detection of invalid filenames (#3126)
* refactor: move file_info into tr_torrent_files

* chore: rename files-test as torrent-files-test.cc

* test: add tests for tr_torrent_files::isSubpathPortable()
2022-05-23 17:53:26 -05:00
Charles Kerr 2293f4336a
perf: use fast_float to parse floating-point numbers (#3092) 2022-05-16 00:06:17 -05:00
Charles Kerr 5dbe1f4669
refactor: replace tr_fdlimit with tr_open_files (#3016) 2022-04-28 21:35:47 -05:00
Charles Kerr 2866638e1b
refactor: add tr_torrent_files::move() and remove() (#2919) 2022-04-15 18:39:04 -05:00
Charles Kerr 4a65956cc9
refactor: extract some file management into tr_files class (#2906) 2022-04-12 10:00:02 -05:00
Charles Kerr 6e8f9f3ff0
feat: add tr_strbuf (#2810)
* feat: add tr_strbuf class for building tmp strings

Based on fmt::basic_memory_buf, this is a growable string buffer that
has an initial size that's large enough to build most filenames or URLs
without needing heap allocations.

Adds a couple of extra helpers such as a `c_str()` method to make dealing
with old zero-terminated string APIs easier.
2022-03-24 16:41:29 -05:00
Charles Kerr a942c67199
refactor: use fmt (#2758)
* deps: use fmt (8.1.1 tag) to build log strings

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2022-03-13 23:43:35 -05:00
Charles Kerr 60ef1abadf
refactor: tr_torrents (#2722)
* refactor: add tr_torrents container
2022-03-01 15:06:29 -08:00
Charles Kerr cfb92c47f0
feat: warn when creating torrents with nonportable filenames (#2695)
* feat: check new torrents for nonportable filenames

* fix: parse torrents even if they have nonportable filenames in the info dict's 'file' string
2022-02-23 17:38:07 -06:00
Charles Kerr e14c7f38e5
feat: use libpsl (#2575)
Use libpsl to calculate public and private parts of URL hosts.
2022-02-12 11:30:27 -06:00
bkuhls a8818148e2
fix cross build (#2576)
Remove redundant include, ${UTP_INCLUDE_DIRS} is included already to fix
cross build error with buildroot:

x86_64-linux-g++: ERROR: unsafe header/library path used in cross-compilation: '-isystem' '/libutp'
2022-02-06 01:17:03 -06:00
Charles Kerr 5efec26a3b
refactor: SAX-like benc parser pt. 1 (#2490)
* refactor: add SAX-like benc parser

This is the first part of a series of PRs whose end goal is to avoid
the overhead of tr_variant when parsing bencoded data, e.g. when
parsing .torrent files on startup or when parsing announce/scrape
tracker responses.

This PR introduces a SAX-like benc parser, reimplements variant-benc
to use the SAX benc parser (so that we don't have two benc parsers),
and updates the benc + variant tests.
2022-01-24 00:30:00 -06:00
FX Coudert a2e30235c4
Make macOS crash reports provide more information (#2471)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2022-01-23 18:10:06 -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 db23ca4c6b
refactor: replace tr_info with tr_torrent_metainfo (#2397)
* refactor: replace tr_info with tr_torrent_metafo
2022-01-15 13:33:57 -06:00
Charles Kerr 7c87cb36eb
refactor: tr_torrent_metainfo (#2340)
* refactor: add tr_torrent_metainfo class

Can be used for parsing bencoded .torrent data without instantiating
a tr_torrent. This will be used in all the places where client code
needs to test a .torrent file for validity / to add a preview window
before adding the torrent.
2021-12-25 15:21:13 -06:00
Charles Kerr 656df477f2
refactor: add tr_announce_list (#2308)
* refactor: add tr_announce_list (#2308)
2021-12-14 14:59:40 -06:00
Charles Kerr bbe49639d6
refactor: use cpputf for utf8 validation and conversion (#2251)
* refactor: use cpputf for utf8 validation and conversion
2021-11-30 15:13:56 -06:00
Charles Kerr 35fe175f2a
refactor: add file-piece-map (#2246)
* refactor: add file-piece-map

* refactor: use tr_file_priorities

* refactor: use tr_files_wanted
2021-11-28 19:12:54 -06:00
Charles Kerr 843e486d2a
refactor: tr_block_info class (#2210)
* refactor: add tr_block_info with tests
2021-11-24 08:48:52 -06:00
Charles Kerr 073c6af1d6
refactor: swarm (#2103)
* refactor: encapsulate request tracking in a class

Introduces a new class to peer-mgr, `ClientRequests`, which tracks what
active requests we've got pending: which blocks, when the requests were
sent, and who they were sent to.

This shouldn't change peer-mgr behavior. Its goal is to carve out some
of peer-mgr's data structures and encapsulte them behind an API that's
simpler to understand.

* refactor: move ActiveRequests to its own file

* perf: avoid duplicate call to tr_cpMissingBlocksInPiece
2021-11-19 12:37:38 -06:00
Charles Kerr 7693ef69bf
refactor: magnet metainfo (#2124)
* refactor: magnet-metainfo
2021-11-09 20:42:18 -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
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 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 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 7d2f65455c
refactor: remove unused tr_list code (#1849) 2021-09-27 17:57:20 -05:00
Charles Kerr f3a97b13ef
build: use CXX_WARNING_FLAGS in libtransmission (#1824) 2021-09-21 08:56:34 -05:00
Charles Kerr 4c1b627647
refactor: port libtransmission to C++ (#1787)
Port libtransmission to C++. This PR doesn't refactor everything to c++.
Its code changes are only what was necessary to compile and link as c++.
See libtransmission/README.md for details on how to submit modernization 
patches!

Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
2021-09-12 12:41:49 -05:00
Mike Gelfand a459e5e11b
Switch to a standalone ARC4 implementation (#1788)
* Switch to a standalone ARC4 implementation

This frees us from expecting it being provided by one of the crypto
libraries we support, all of which deprecated and/or removed it at this
point.

Fixes: #1103
Fixes: #1777

* Suppress lgtm warnings about RC4 being weak (we don't care)
2021-09-12 06:47:29 +03:00
Mike Gilbert 409f59889b
Restore support for the INSTALL_LIB option (#1756)
It appears this was removed by accident.

Fixes: 677dc73eac
2021-08-13 21:26:38 +03:00
Charles Kerr f59118d1fe
feat: add torrent-get 'primary-mime-type' to RPC. (#1464)
* feat: add torrent-get 'primary-mime-type' to RPC.

This is a cheap way for RPC clients to know what type of content is in a
torrent. This info can be used to display the torrent, e.g. by using an
icon that corresponds to the mime type.

* use size_t for content byte count

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit boolean expressions

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* use uint64_t for content byte counts

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* avoid unnecessary logic branches

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit cast

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* refactor: add an autogenerated mime-type.h header

* chore: maybe fix the win32 FTBFS

* chore: add mime-types.[ch] to xcode

* Squashed commit of the following:

commit 4c7153fa48
Author: Mike Gelfand <mikedld@users.noreply.github.com>
Date:   Tue Oct 13 03:15:19 2020 +0300

    Remove autotools-based build system (#1465)

    * Support .git files (e.g. for worktrees, submodules)
    * Fix symlinks in source tarball, switch to TXZ, adjust non-release name
    * Remove autotools stuff

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2020-10-13 10:33:56 -05:00
Charles Kerr 677dc73eac
refactor: use GTest for running tests (#1383)
* refactor: use google-test on libtransmission tests
2020-08-11 13:11:55 -05:00
Charles Kerr abac811dd2
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings

* fix: implicit fallthrough warning

* fixup! fix: implicit fallthrough warning

* fix: disable warnings for 3rd party code

Since we want to leave upstream code as-is

* fixup! fix: disable warnings for 3rd party code

* fixup! fix: disable warnings for 3rd party code

* silence spurious alignment warning

Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: 90ac46f710/f/src/util/util_safealign.h (_35)

* fixup! fix: disable warnings for 3rd party code

* fixup! fix: implicit fallthrough warning

* make uncrustify happy

* remove uncrustify-test.sh

that's probably off-topic for this PR

* fixup! fix: __attribute__(__printf__) warnings

* Update libtransmission/CMakeLists.txt

Co-Authored-By: ckerr <ckerr@github.com>

* fixup! silence spurious alignment warning

* use -w for DISABLE_WARNINGS in Clang

* refactor: fix libtransmission deprecation warnings

* fix: pthread_create's start_routine's return value

This was defined as `void` on non-Windows but should have been `void*`

* chore: uncrustify

* fix: add DISABLE_WARNINGS option for SunPro Studio

* fix "unused in lambda capture" warnings by clang++

* fix 'increases required alignment' warning

Caused from storing int16_t's in a char array.

* fix net.c 'increases required alignment' warning

The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.

* make building quieter so warnings are more visible

* fixup! fix 'increases required alignment' warning

* Fix -Wcast-function-type warnings in GTK+ app code

https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.

GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.

Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.

In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).

* fixup! fix "unused in lambda capture" warnings by clang++

* fixup! fix "unused in lambda capture" warnings by clang++

* fix two more libtransmission compiler warnings

* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 11:27:03 -06:00
Mike Gelfand f3968b7708 Load CA certs from system store on Windows / OpenSSL
Fixes: #446
2019-06-23 11:59:53 +03:00
LaserEyess 750589101a Parse session-id header case-insensitively (#765)
RFC 2616 defines headers as case-insensitive, so if rpc is behind a
reverse proxy that lowers the case of headers, transmission will not
parse them correctly.

A new wrapper function, `tr_strcasestr` is added to
libtransmission/utils.c to allow for comparisons of headers case
insensitively, and checks in cmake and autogen are included.
2019-03-17 17:37:52 +03:00
Mike Gelfand ffcca3964d Adjust test names in CMake to be in line with autoconf ones 2017-12-02 17:58:15 +03:00
Mike Gelfand 30c7c05cbb Refactor completion scripts execution
There're still a few issues here and there, but overall I believe it's now
better than it was before.
2017-11-28 10:03:08 +03:00
Mike Gelfand 18aabdeb06 Introduce peer socket struct to improve readability 2017-06-28 18:50:05 +03:00
Mike Gelfand f701d501a8 Move generic macros to a separate tr-macros.h file 2017-06-18 17:11:20 +03:00
Mike Gelfand 98695fe3c1 Introduce our own assertion macros with finer control 2017-06-08 10:24:12 +03:00
Mike Gelfand 1e3d20422a Reduce for loop variables scope 2017-05-14 01:38:31 +03:00