Commit Graph

4701 Commits

Author SHA1 Message Date
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
Charles Kerr 97a6f1232e
fixup! perf: prioritize announces based on scrape stats (#1782) (#1786)
* fixup! perf: prioritize announces based on scrape stats (#1782)
2021-09-11 08:11:46 -05:00
Charles Kerr 40868d1621
perf: faster tr_sessionCountQueueFreeSlots() (#1785)
The previous code had some redundant calculations, e.g. calling 
tr_torrentGetActivity() a couple of times per torrent, once in 
tr_sessionCountQueueFreeSlots() and once in tr_torrentIsStalled(). 
Only one call is necessary.

tr_sessionCountQueueFreeSlots() used to keep iterating through all 
torrents even if the number of free slots had already been decremented 
to zero, even though further iteration does not change the zero return 
value :) This PR checks the return value while looping to prevent this.
2021-09-10 15:15:35 -05:00
Charles Kerr a673c49bd6
perf: do not generate address strings as log name if logging is disabled (#1784)
* perf: if logs are disabled, don't build log names

handshake.c and peer-io.c call tr_peerIoGetAddrStr() to build a name for
passing to tr_logAddDeepNamed(). Since tr_peerIoGetAddrStr() isn't free,
make sure deep logging is enabled before building the name.
2021-09-10 12:22:46 -05:00
Charles Kerr 756bb349d6
perf: prioritize announces based on scrape stats (#1782)
* perf: prioritize announces based on scrape stats

This change is to improve responsiveness when starting a large batch of
torrents, e.g. when starting up a seedbox, but is also generally useful.

First, try to scrape as many torrents as as quickly as possible, giving
preference to that even over announces. Thanks to multiscrape we can run
through scrapes an order of magnitude faster than announces. Then scrape
responses tell us which swarms have leechers and we can prioritize those
torrents' announces.

Second, increase how many scrapes and announces we start at a time. This
limit probably hasn't been needed since 2da97b25 and by scraping faster,
the sooner we'll know which torrents to announce first.

* chore: remove printf() tracer
2021-09-09 19:28:22 -05:00
Charles Kerr d6cb99e57c
perf: use scrape to know when a private swarm is all-seeds (#1780)
* perf: use scrape to know when a swarm is all-seeds

For private torrents, the tracker is the sole source of peers. So when a
private torrent's tracker responds that there are 0 leechers, we can use
that information to mark the entire swarm as seeders and to not initiate
connections to those peers if we are seeding. This can help seedboxes to
more efficiently pick which swarms to prioritize.

This strategy is not used on public torrents, since new seeder-to-seeder
connections can be useful there for pex.

This PR changes tr_peerMgrAddPex() to (1) remove tr_atom.seedProbability
field (which was not as robust as intended) and (2) add batches of peers
instead of a single peer.

* fix: only use all-seeds check for private torrents
2021-09-09 15:25:30 -05:00
Charles Kerr f83e07e2a0
perf: do not rechoke in tr_peerMgrStartTorrent() (#1779)
tr_peerMgrStartTorrent() is called once per torrent on startup, so this
can be expensive if the user has a lot of torrents.

Instead, enqueue a pending rechoke that will happen on idle. This way,
all the added torrents can be handled by a single rechoke call.
2021-09-09 07:36:10 -05:00
Charles Kerr c0ed82533c
perf: lookup tables for faster torrent searching. (#1778)
* perf: lookup tables for faster torrent searching.

tr_torrentFindFromId(), tr_torrentFindFromHashString(), and
tr_torrentFindFromHash() are now O(log N) instead of O(N) where
N is the number of torrents.

* build: fix clang-tidy warning

error: integer to pointer cast pessimizes optimization opportunities
[performance-no-int-to-ptr,-warnings-as-errors] from TR_BAD_SYS_FILE
which expands to INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
2021-09-09 00:22:29 -05:00
Mitch Livingston e9a39fb608
Merge branch 'master' into prefetch-magnet 2021-08-22 18:56:58 -04:00
Mike Gelfand db3d40d0ed Switch to clang-format for code formatting, include Mac client 2021-08-16 00:38: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
RobCrowston 0155252823
Add in-kernel file copying for several platforms. (#1092)
* Add in-kernel copying support for Linux (sendfile64(2), copy_file_range(2)), FreeBSD 13 (copy_file_range(2)), MacOS (copyfile(2)), and Windows (CopyFileExA).

* Fix macro name USE_COPY_FILE_RANGE.

* Minor bugfixes for userspace fallback.

* Fix linux sendfile64 bugs.

* Remove some overzealous asserts.

* Allow transmission-test-copy to take an optional argument for an external reference file.

* Fix return value error of tr_sys_path_copy.

* Use COPYFILE_ALL for Macs without COPYFILE_CLONE.

* Add in-kernel file copying for several platforms.

Numerous operating systems now have support for copying files directly in the
kernel, which is generally more efficient than copying in a userspace read(2)/
write(2) loop. (This becomes particularly relevant for 4th gen PCI-E storage,
which approaches the latency of DRAM.) For Linux I use sendfile64(2), and, for
later kernels, copy_file_range(2). FreeBSD 13 will also support
copy_file_range(2). MacOS has copyfile(2), and Windows has CopyFileExA.
Operating systems lacking such a syscall continue to use the existing
read(2)/write(2) loop.

* Appease uncrustify.

* Appease uncrustify.

* copy-test: generate random content at run time.

* copy-test: Stylistic changes and more check()s.

* copy-test: files_are_identical should follow test idioms

* tr_sys_path_copy: numerous tweaks as requested by review.

* s/old file/source file; s/new file/destination file.

* tr_sys_path_copy: handle win32 wide characters in paths.

* Uncrustify.

* test-copy: Use non-string create_file_with_contents.

* tr_sys_path_copy: numerous fixes.

Per review: generate test file content at runtime; tidy use of check();
fix style; re-measure file sizes in the copy; define a macro when the
system does not provide it; use Unicode APIs on Windows; and fix
documentation.

* Updated as per comments.

* Rebase kernel-copy changes onto 3.0 with gtest.

* Undo irrelevant comment change.

* Fix syntax error.

* Use tr_malloc() instead of tr_valloc().

* Use EXPECT instead of TR_ASSERT in gtest.

* Add error handling.

* Acceptable coding style has changed again.

Now it's camelCase. Also use nullptr instead of NULL, etc.

* Fix east/west const.

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2021-08-07 12:04:03 +03:00
Charles Kerr 07d385cf44
refactor: torrent-complete-sound-command is a list (#1710)
* refactor: torrent-complete-sound-command is a list
2021-05-25 11:21:41 -05:00
Lucas Clemente Vella 1194b88258
Renaming variables to better reflect what they do. (#1660)
Because bound IPv4 is hardly ever a public address.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2021-05-19 15:45:03 -05:00
Mark Deepwell c7feedcf45
Support uTorrent Web with both azureus style and the one without the dash at the end 2021-05-11 21:39:09 -07:00
Mark Deepwell d57f575892
Retain full BitLord build number 2021-04-27 20:47:37 -07:00
Mark Deepwell 7ff6d8cf36
Add unrecognized client names #1363
This is based off of PR#1526 by azy5030 to add in: Torrent Web, BiglyBT, and FrostWire. I made the additional change requested by livings124.

In addition this also adds support for: HTTP Seed, aria2 (#532), and BitLord.
2021-04-27 20:47:33 -07:00
Norbert Papke d2c8137518 Fixes transmission/transmission#564
Per analysis by cfpp2p
(https://github.com/transmission/transmission/issues/564#issuecomment-377612224),
a duplicate search is not an error.
2021-02-06 10:56:09 -08:00
Charles Kerr 41f225df7b
Remove posix memalign (#1520)
* refactor: remove unnecessary func tr_valloc()

We're only using it in a handful of places, and none of them need the
kind of alignment that posix_memalign() provide. So we can drop a few
dozen lines by removing the portability wrapper.
2020-11-15 15:53:42 -06:00
Chrool cfce6e2e3a
configure anti brute force (#1447)
* add brute force configuration options
2020-11-14 12:43:42 -06:00
Charles Kerr 9d313a8816
sonarcloud warnings 9 (#1511)
* refactor: const correctness 

* refactor: fix some implicit conversions

* refactor: make local pointers const if their objects are not modified

* refactor: do not cast away const in torrent-cell-renderer

* refactor: remove call to deprecated gtk_icon_size_lookup_for_settings

* refactor: member functions that do not mutate their objects should be declared const

* chore: do not end comments with a semicolon
2020-11-08 21:31:02 -06:00
Charles Kerr 6b0408b320
refactor: fix more sonarcloud warnings (#1509)
* chore: simplify loop logic

* refactor: simplify isValidUtf8()

* refactor: use std::make_unique in Application::Application

* refactor: avoid raw pointers in DetailsDialog

* refactor: simplify DetailsDialog::refreshPref()

* refactor: make Application methods const

* refactor: reduce cognitive complexity of buildTrackerSummary()
2020-11-08 13:54:40 -06:00
Charles Kerr 7f147c65fb
refactor: fix more sonarcloud warnings (#1508)
* refactor: const correctness

* refactor: use getpwuid_r instead of getpwuid

* chore: simplify dict walking loop logic

* refactor: remove dead store assignment in announcer

* refactor: use std::make_shared
2020-11-05 16:46:21 -06:00
Charles Kerr e74b3bad8b
chore: fix more sonarcloud warnings (#1507)
* refactor: don't let realpath() alloc return memory

* chore: silence array-bounds-read warning

* chore: tidy memcmp of union
2020-11-03 21:23:53 -06:00
Charles Kerr 46cb0b5e65
refactor: sonarcloud warnings about overly-complex looping logic (#1503)
* chore: simplify loop logic
2020-11-03 18:59:19 -06:00
Charles Kerr 0bfbc3eba7
Sonarcloud warnings 4 (#1499)
* chore: fix some sonarcloud html warnings (e.g. deprecated attribute use)

* chore: uppercase literal suffixes

* chore: remove redundant casts

* chore: remove commented-out code

* chore: use qInfo() instead of std::cerr
2020-11-02 09:16:12 -06:00
Charles Kerr 73fdd722a7
Sonarcloud warnings 3 (#1498)
* chore: use ClassName:: for calling static methods

* chore: prefer to initialize member data in the class initializer
2020-11-01 19:13:32 -06:00
Charles Kerr 19e52d8b9a
chore: sonarcloud warnings 2 (#1496)
* fix "merge nested if" sonarcloud warnings

* fix explicit constructor warnings in qt client
2020-11-01 15:47:57 -06:00
Charles Kerr e59fe7daaf
fix: silence some sonarcloud warnings (#1493)
* refactor: add null ptr check in initPeerRow()

* refactor: add a nullptr gurad in icon_cache_get_mime_type_icon

* chore: silence two "break notreached" warnings

* chore: silence sonarcloud html warnings

* chore: silence sonarcloud uninitialized var warning

* chore: silence sonarcloud nullptr warning
2020-10-31 16:23:43 -05:00
Charles Kerr 61d221c8bb
Web client add licensing info (#1481)
* chore: add '@license' tag to web sources' comments

Webpack's tersify plugin looks for that JSDoc tag in order to decide
which comments to extract into the generated license file.

* chore: address sonarcloud.io warnings

* chore: address sonarcloud.io code smells

* fixup! chore: address sonarcloud.io warnings
2020-10-25 16:13:48 -05:00
Charles Kerr cd453764b1
feat: web client refresh (#1476)
Give the web client a major overhaul.

User-visible highlights include:

* Mobile is now fully supported.
* Added fullscreen support on mobile.
* Better support for dark mode.
* Added mime icons to the torrent list.
* Improved theme consistency across the app.

Maintainer highlights include:

* Updated code to use ES6 APIs.
* No longer uses jQuery UI.
* No longer uses jQuery.
* Use Webpack to bundle the Javascript, CSS, and assets together -- the entire bundle size is now 68K gzipped.
* Added eslint / prettier / stylelint tooling.
* Uses torrent-get's 'table' mode for more efficient RPC calls.
2020-10-23 20:04:25 -05: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
Mike Gelfand 4c7153fa48
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
2020-10-13 03:15:19 +03:00
Charles Kerr a4dd67ae45
chore: fix some fixmes (#1449)
* chore: remove assertions that were flagged for removal

* chore: remove unneeded check

* refactor: move tr_peerIoAddrStr to net.h

* refactor: formatter API now takes size_t args

* chore: remove out-of-date FIXME comment

* refactor: cleanup logging win32 ifdefs
2020-09-13 16:43:29 -05:00
Charles Kerr 83cc7e04c8
Fix more coverity warnings (#1445)
cast intentionally-ignored function retval to null

remove superfluous JSON polyfill from web client.
2020-09-12 08:17:18 -05:00
Charles Kerr efaa66a920
fix: resolve some lgtm warnings (#1444)
* fix: warnings found by LGTM static analyzer
2020-09-11 16:07:45 -05:00
Charles Kerr d3323ddee0
fix: Coverity warnings (#1443)
* fix: coverity warnings
2020-09-10 18:50:46 -05:00
Charles Kerr e127b20c05
chore: fix compiler warnings (#1412)
* chore: fix compiler warnings
2020-08-27 18:41:26 -05:00
Mike Gelfand b7a8bd45b7 Reformat affected code after recent changes 2020-08-18 20:31:06 +03:00
Mike Gelfand 75458d6be3 Make use of TR_UNUSED macro where cast-to-void was used before 2020-08-18 14:34:49 +03:00
Mike Gelfand ff8d0dbf3b Switch from UNUSED macro to TR_UNUSED macro
Since there is no way to mark parameters as [potentially] unused in
standard C and when using MSVC compiler, use the widely accepted
cast-to-void approach instead.
2020-08-18 14:19:55 +03:00
Mike Gelfand 077f4d8d2b Require C11, switch to standard static_assert 2020-08-18 14:19:55 +03: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
RobCrowston 6fee8724ab
Allow the operating system to set the size of the listen queue connection backlog. (#922)
* Allow the operating system to determine the size of the listen queue connection backlog.

* On Windows, set the listen queue backlog to SOMAXCONN, as advised in https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-listen.
2020-07-28 22:14:07 -05:00
Vitaly Potyarkin 2da97b25fa
Lift 1024 open files limit (switch to curl polling API) (#893)
* Switch to new libcurl's polling interface

* Drop unused includes

* Use NOFILE limit value defined by operating system

* Avoid tight loops, ensure blocking for a small timeout

When there are no file descriptors to wait for, select() would work the
same as sleep(). But curl_multi_wait() returns immediately in this case,
so we need to add explicit wait to avoid tight loops.

Documentation: https://curl.haxx.se/libcurl/c/curl_multi_timeout.html
Discussion: https://curl.haxx.se/mail/lib-2018-03/0074.html

* Bump libcurl minimum version to 7.28.0
2020-07-28 21:38:27 -05:00
Pedro Scarapicchia Junior 5be8bd50f9
Check if log deep is enabled before tr_logAddDeep (#1329)
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2020-07-28 12:31:36 -05:00
Charles Kerr 00be8d00d7
refactor: make variant_headers reusable to qt app. (#1369)
* refactor: make variant_headers reusable to qt app.

Torrent.cc's `change()` template methods are generically useful to deal
with tr_variant wrangling, but previously were only used in Torrent.cc.
This PR moves them into a new API `VariantHelpers.h` for use by Prefs,
Session, TorrentModel, etc.
2020-07-26 23:30:58 -05:00
Charles Kerr fcda077cdd
chore: remove extraneous/default class destructors (#1317)
* chore: remove extraneous/default class destructors

* fixup! chore: remove extraneous/default class destructors
2020-06-15 09:30:29 -05:00
Mike Gelfand 0c10308e06
Add missing files that fail build from tarball (#1247)
Fixes: #1246, #1138
2020-05-23 02:13:59 +03:00
qu1ck 2fab317040
Add TR_TORRENT_LABELS to env variables available to scripts (#868)
* Add TR_TORRENT_LABELS to env variables available to scripts

* Add unit test for tr_strjoin

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2020-05-13 18:54:44 -05:00